diff --git a/include/zh_bh1750.h b/include/zh_bh1750.h index 52026f3..5a4966e 100644 --- a/include/zh_bh1750.h +++ b/include/zh_bh1750.h @@ -76,10 +76,8 @@ extern "C" * @return * - ESP_OK if read was success * - ESP_ERR_INVALID_ARG if parameter error - * - ESP_ERR_NOT_FOUND if BH1750 is not initialized - * - ESP_FAIL if sending command error or slave has not ACK the transfer - * - ESP_ERR_INVALID_STATE if I2C driver not installed or not in master mode - * - ESP_ERR_TIMEOUT if operation timeout because the bus is busy + * - ESP_ERR_NOT_FOUND if sensor is not initialized + * - ESP_ERR_INVALID_RESPONSE if I2C driver error */ esp_err_t zh_bh1750_read(float *data); @@ -95,10 +93,8 @@ extern "C" * @return * - ESP_OK if adjust was success * - ESP_ERR_INVALID_ARG if parameter error - * - ESP_ERR_NOT_FOUND if BH1750 is not initialized or auto adjust is enabled - * - ESP_FAIL if sending command error or slave has not ACK the transfer - * - ESP_ERR_INVALID_STATE if I2C driver not installed or not in master mode - * - ESP_ERR_TIMEOUT if operation timeout because the bus is busy + * - ESP_ERR_NOT_FOUND if sensor is not initialized or auto adjust is enabled + * - ESP_ERR_INVALID_RESPONSE if I2C driver error */ esp_err_t zh_bh1750_adjust(const uint8_t value); diff --git a/version.txt b/version.txt index e6d5cb8..e4c0d46 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.0.2 \ No newline at end of file +1.0.3 \ No newline at end of file diff --git a/zh_bh1750.c b/zh_bh1750.c index 9a00675..85ca4f7 100644 --- a/zh_bh1750.c +++ b/zh_bh1750.c @@ -113,8 +113,8 @@ REPEATE:; #endif if (esp_err != ESP_OK) { - ESP_LOGE(TAG, "BH1750 read fail. I2C driver error."); - return esp_err; + ESP_LOGE(TAG, "BH1750 read fail. I2C driver error at line %d.", __LINE__); + return ESP_ERR_INVALID_RESPONSE; } vTaskDelay(_time / portTICK_PERIOD_MS); READ: @@ -132,8 +132,8 @@ READ: #endif if (esp_err != ESP_OK) { - ESP_LOGE(TAG, "BH1750 read fail. I2C driver error."); - return esp_err; + ESP_LOGE(TAG, "BH1750 read fail. I2C driver error at line %d.", __LINE__); + return ESP_ERR_INVALID_RESPONSE; } uint32_t raw_data = sensor_data[0] << 8 | sensor_data[1]; if (raw_data == 65535 || raw_data == 0) @@ -204,8 +204,8 @@ esp_err_t _adjust(const uint8_t value) i2c_cmd_link_delete(i2c_cmd_handle); if (esp_err != ESP_OK) { - ESP_LOGE(TAG, "BH1750 adjust fail. I2C driver error."); - return esp_err; + ESP_LOGE(TAG, "BH1750 adjust fail. I2C driver error at line %d.", __LINE__); + return ESP_ERR_INVALID_RESPONSE; } i2c_cmd_handle = i2c_cmd_link_create(); i2c_master_start(i2c_cmd_handle); @@ -220,8 +220,8 @@ esp_err_t _adjust(const uint8_t value) #endif if (esp_err != ESP_OK) { - ESP_LOGE(TAG, "BH1750 adjust fail. I2C driver error."); - return esp_err; + ESP_LOGE(TAG, "BH1750 adjust fail. I2C driver error at line %d.", __LINE__); + return ESP_ERR_INVALID_RESPONSE; } if (_init_config.work_mode == CONTINUOUSLY) {