remove all ESP_ERROR_CHECK(x)

This commit is contained in:
cyberman54 2020-12-21 19:41:25 +01:00
parent 62132030b7
commit 5edb904d7c
6 changed files with 48 additions and 50 deletions

View File

@ -128,7 +128,7 @@ IRAM_ATTR void gap_callback_handler(esp_gap_ble_cb_event_t event,
switch (event) { switch (event) {
case ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT: case ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT:
// restart scan // restart scan
ESP_ERROR_CHECK(esp_ble_gap_start_scanning(BLESCANTIME)); esp_ble_gap_start_scanning(BLESCANTIME);
break; break;
case ESP_GAP_BLE_SCAN_RESULT_EVT: case ESP_GAP_BLE_SCAN_RESULT_EVT:
@ -136,7 +136,7 @@ IRAM_ATTR void gap_callback_handler(esp_gap_ble_cb_event_t event,
if (p->scan_rst.search_evt == if (p->scan_rst.search_evt ==
ESP_GAP_SEARCH_INQ_CMPL_EVT) // Inquiry complete, scan is done ESP_GAP_SEARCH_INQ_CMPL_EVT) // Inquiry complete, scan is done
{ // restart scan { // restart scan
ESP_ERROR_CHECK(esp_ble_gap_start_scanning(BLESCANTIME)); esp_ble_gap_start_scanning(BLESCANTIME);
return; return;
} }
@ -219,8 +219,8 @@ esp_err_t register_ble_callback(bool unregister = false) {
if (unregister) { if (unregister) {
ESP_LOGI(TAG, "Unregister GAP callback..."); ESP_LOGI(TAG, "Unregister GAP callback...");
ESP_ERROR_CHECK(esp_ble_gap_stop_scanning()); esp_ble_gap_stop_scanning();
ESP_ERROR_CHECK(esp_ble_gap_register_callback(NULL)); esp_ble_gap_register_callback(NULL);
} }
@ -230,23 +230,25 @@ esp_err_t register_ble_callback(bool unregister = false) {
// This function is called when gap event occurs, such as scan result. // This function is called when gap event occurs, such as scan result.
// register the scan callback function to the gap module // register the scan callback function to the gap module
ESP_ERROR_CHECK(esp_ble_gap_register_callback(&gap_callback_handler)); esp_ble_gap_register_callback(&gap_callback_handler);
static esp_ble_scan_params_t ble_scan_params = { static esp_ble_scan_params_t ble_scan_params = {
.scan_type = BLE_SCAN_TYPE_PASSIVE, .scan_type = BLE_SCAN_TYPE_PASSIVE,
.own_addr_type = BLE_ADDR_TYPE_RANDOM, .own_addr_type = BLE_ADDR_TYPE_RANDOM,
.scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL, .scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL,
/* /*
#if (MACFILTER) #if (MACFILTER)
.scan_filter_policy = BLE_SCAN_FILTER_ALLOW_WLIST_PRA_DIR, .scan_filter_policy = BLE_SCAN_FILTER_ALLOW_WLIST_PRA_DIR,
// ADV_IND, ADV_NONCONN_IND, ADV_SCAN_IND packets are used for broadcasting // ADV_IND, ADV_NONCONN_IND, ADV_SCAN_IND packets are used
// data in broadcast applications (e.g., Beacons), so we don't want them in for broadcasting
// macfilter mode // data in broadcast applications (e.g., Beacons), so we
#else don't want them in
.scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL, // macfilter mode
#endif #else
*/ .scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL,
#endif
*/
.scan_interval = .scan_interval =
(uint16_t)(cfg.blescantime * 10 / 0.625), // Time = N * 0.625 msec (uint16_t)(cfg.blescantime * 10 / 0.625), // Time = N * 0.625 msec
@ -257,7 +259,7 @@ esp_err_t register_ble_callback(bool unregister = false) {
ESP_LOGI(TAG, "Set GAP scan parameters"); ESP_LOGI(TAG, "Set GAP scan parameters");
// This function is called to set scan parameters. // This function is called to set scan parameters.
ESP_ERROR_CHECK(esp_ble_gap_set_scan_params(&ble_scan_params)); esp_ble_gap_set_scan_params(&ble_scan_params);
} }
return ESP_OK; return ESP_OK;
@ -269,11 +271,11 @@ void start_BLEscan(void) {
ESP_LOGI(TAG, "Initializing bluetooth scanner ..."); ESP_LOGI(TAG, "Initializing bluetooth scanner ...");
// Initialize BT controller to allocate task and other resource. // Initialize BT controller to allocate task and other resource.
if (btStart()) { // enable bt_controller if (btStart()) { // enable bt_controller
ESP_ERROR_CHECK(esp_coex_preference_set(ESP_COEX_PREFER_BT)); esp_coex_preference_set(ESP_COEX_PREFER_BT);
ESP_ERROR_CHECK(esp_bluedroid_init()); esp_bluedroid_init();
ESP_ERROR_CHECK(esp_bluedroid_enable()); esp_bluedroid_enable();
// Register callback function for capturing bluetooth packets // Register callback function for capturing bluetooth packets
ESP_ERROR_CHECK(register_ble_callback(false)); register_ble_callback(false);
ESP_LOGI(TAG, "Bluetooth scanner started"); ESP_LOGI(TAG, "Bluetooth scanner started");
#endif // BLECOUNTER #endif // BLECOUNTER
} else { } else {
@ -286,16 +288,16 @@ void start_BLEscan(void) {
void stop_BLEscan(void) { void stop_BLEscan(void) {
#if (BLECOUNTER) #if (BLECOUNTER)
ESP_LOGI(TAG, "Shutting down bluetooth scanner ..."); ESP_LOGI(TAG, "Shutting down bluetooth scanner ...");
ESP_ERROR_CHECK(register_ble_callback(true)); // unregister capture function register_ble_callback(true); // unregister capture function
ESP_LOGD(TAG, "bluedroid disable..."); ESP_LOGD(TAG, "bluedroid disable...");
ESP_ERROR_CHECK(esp_bluedroid_disable()); esp_bluedroid_disable();
ESP_LOGD(TAG, "bluedroid deinit..."); ESP_LOGD(TAG, "bluedroid deinit...");
ESP_ERROR_CHECK(esp_bluedroid_deinit()); esp_bluedroid_deinit();
if (!btStop()) { // disable bt_controller if (!btStop()) { // disable bt_controller
ESP_LOGE(TAG, "Bluetooth controller stop failed. Resetting device"); ESP_LOGE(TAG, "Bluetooth controller stop failed. Resetting device");
do_reset(true); do_reset(true);
} }
ESP_ERROR_CHECK(esp_coex_preference_set(ESP_COEX_PREFER_WIFI)); esp_coex_preference_set(ESP_COEX_PREFER_WIFI);
ESP_LOGI(TAG, "Bluetooth scanner stopped"); ESP_LOGI(TAG, "Bluetooth scanner stopped");
#endif // BLECOUNTER #endif // BLECOUNTER
} // stop_BLEscan } // stop_BLEscan

View File

@ -106,7 +106,7 @@ breaking change
// DevEUI generator using devices's MAC address // DevEUI generator using devices's MAC address
void gen_lora_deveui(uint8_t *pdeveui) { void gen_lora_deveui(uint8_t *pdeveui) {
uint8_t *p = pdeveui, dmac[6]; uint8_t *p = pdeveui, dmac[6];
ESP_ERROR_CHECK(esp_efuse_mac_get_default(dmac)); esp_efuse_mac_get_default(dmac);
// deveui is LSB, we reverse it so TTN DEVEUI display // deveui is LSB, we reverse it so TTN DEVEUI display
// will remain the same as MAC address // will remain the same as MAC address
// MAC is 6 bytes, devEUI 8, set middle 2 ones // MAC is 6 bytes, devEUI 8, set middle 2 ones

View File

@ -304,9 +304,9 @@ void setup() {
#else #else
// remove bluetooth stack to gain more free memory // remove bluetooth stack to gain more free memory
btStop(); btStop();
ESP_ERROR_CHECK(esp_bt_mem_release(ESP_BT_MODE_BTDM)); esp_bt_mem_release(ESP_BT_MODE_BTDM);
ESP_ERROR_CHECK(esp_coex_preference_set( esp_coex_preference_set(
ESP_COEX_PREFER_WIFI)); // configure Wifi/BT coexist lib ESP_COEX_PREFER_WIFI); // configure Wifi/BT coexist lib
#endif #endif
// initialize gps // initialize gps

View File

@ -171,11 +171,11 @@ void calibrate_voltage(void) {
#ifdef BAT_MEASURE_ADC #ifdef BAT_MEASURE_ADC
// configure ADC // configure ADC
#ifndef BAT_MEASURE_ADC_UNIT // ADC1 #ifndef BAT_MEASURE_ADC_UNIT // ADC1
ESP_ERROR_CHECK(adc1_config_width(ADC_WIDTH_BIT_12)); adc1_config_width(ADC_WIDTH_BIT_12);
ESP_ERROR_CHECK(adc1_config_channel_atten(adc_channel, atten)); adc1_config_channel_atten(adc_channel, atten);
#else // ADC2 #else // ADC2
// ESP_ERROR_CHECK(adc2_config_width(ADC_WIDTH_BIT_12)); // adc2_config_width(ADC_WIDTH_BIT_12);
ESP_ERROR_CHECK(adc2_config_channel_atten(adc_channel, atten)); adc2_config_channel_atten(adc_channel, atten);
#endif #endif
// calibrate ADC // calibrate ADC
esp_adc_cal_value_t val_type = esp_adc_cal_characterize( esp_adc_cal_value_t val_type = esp_adc_cal_characterize(
@ -210,7 +210,7 @@ uint16_t read_voltage(void) {
#else // ADC2 #else // ADC2
int adc_buf = 0; int adc_buf = 0;
for (int i = 0; i < NO_OF_SAMPLES; i++) { for (int i = 0; i < NO_OF_SAMPLES; i++) {
ESP_ERROR_CHECK(adc2_get_raw(adc_channel, ADC_WIDTH_BIT_12, &adc_buf)); adc2_get_raw(adc_channel, ADC_WIDTH_BIT_12, &adc_buf);
adc_reading += adc_buf; adc_reading += adc_buf;
} }
#endif // BAT_MEASURE_ADC_UNIT #endif // BAT_MEASURE_ADC_UNIT

View File

@ -91,8 +91,7 @@ void spi_slave_task(void *param) {
// wait until spi master clocks out the data, and read results in rx buffer // wait until spi master clocks out the data, and read results in rx buffer
ESP_LOGI(TAG, "Prepared SPI transaction for %zu byte(s)", transaction_size); ESP_LOGI(TAG, "Prepared SPI transaction for %zu byte(s)", transaction_size);
ESP_LOG_BUFFER_HEXDUMP(TAG, txbuf, transaction_size, ESP_LOG_DEBUG); ESP_LOG_BUFFER_HEXDUMP(TAG, txbuf, transaction_size, ESP_LOG_DEBUG);
ESP_ERROR_CHECK_WITHOUT_ABORT( spi_slave_transmit(HSPI_HOST, &spi_transaction, portMAX_DELAY);
spi_slave_transmit(HSPI_HOST, &spi_transaction, portMAX_DELAY));
ESP_LOG_BUFFER_HEXDUMP(TAG, rxbuf, transaction_size, ESP_LOG_DEBUG); ESP_LOG_BUFFER_HEXDUMP(TAG, rxbuf, transaction_size, ESP_LOG_DEBUG);
ESP_LOGI(TAG, "Transaction finished with size %zu bits", ESP_LOGI(TAG, "Transaction finished with size %zu bits",
spi_transaction.trans_len); spi_transaction.trans_len);

View File

@ -64,15 +64,13 @@ void wifi_sniffer_init(void) {
WIFI_PROMIS_FILTER_MASK_MGMT | WIFI_PROMIS_FILTER_MASK_MGMT |
WIFI_PROMIS_FILTER_MASK_DATA}; WIFI_PROMIS_FILTER_MASK_DATA};
ESP_ERROR_CHECK(esp_wifi_init(&wifi_cfg)); // start Wifi task esp_wifi_init(&wifi_cfg); // start Wifi task
ESP_ERROR_CHECK( esp_wifi_set_country(&wifi_country); // set locales for RF and channels
esp_wifi_set_country(&wifi_country)); // set locales for RF and channels esp_wifi_set_storage(WIFI_STORAGE_RAM);
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM)); esp_wifi_set_mode(WIFI_MODE_NULL);
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_NULL)); esp_wifi_set_ps(WIFI_PS_NONE); // no modem power saving
ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE)); // no modem power saving esp_wifi_set_promiscuous_filter(&wifi_filter); // set frame filter
ESP_ERROR_CHECK( esp_wifi_set_promiscuous_rx_cb(&wifi_sniffer_packet_handler);
esp_wifi_set_promiscuous_filter(&wifi_filter)); // set frame filter
ESP_ERROR_CHECK(esp_wifi_set_promiscuous_rx_cb(&wifi_sniffer_packet_handler));
// setup wifi channel hopping timer // setup wifi channel hopping timer
WifiChanTimer = WifiChanTimer =
@ -85,10 +83,9 @@ void wifi_sniffer_init(void) {
void switch_wifi_sniffer(uint8_t state) { void switch_wifi_sniffer(uint8_t state) {
if (state) { if (state) {
// start sniffer // start sniffer
ESP_ERROR_CHECK(esp_wifi_start()); esp_wifi_start();
ESP_ERROR_CHECK(esp_wifi_set_promiscuous(true)); esp_wifi_set_promiscuous(true);
ESP_ERROR_CHECK( esp_wifi_set_channel(WIFI_CHANNEL_MIN, WIFI_SECOND_CHAN_NONE);
esp_wifi_set_channel(WIFI_CHANNEL_MIN, WIFI_SECOND_CHAN_NONE));
// start channel hopping timer // start channel hopping timer
if (cfg.wifichancycle > 0) if (cfg.wifichancycle > 0)
xTimerStart(WifiChanTimer, (TickType_t)0); xTimerStart(WifiChanTimer, (TickType_t)0);
@ -97,7 +94,7 @@ void switch_wifi_sniffer(uint8_t state) {
if (xTimerIsTimerActive(WifiChanTimer) != pdFALSE) if (xTimerIsTimerActive(WifiChanTimer) != pdFALSE)
xTimerStop(WifiChanTimer, (TickType_t)0); xTimerStop(WifiChanTimer, (TickType_t)0);
// stop sniffer // stop sniffer
ESP_ERROR_CHECK(esp_wifi_set_promiscuous(false)); esp_wifi_set_promiscuous(false);
ESP_ERROR_CHECK(esp_wifi_stop()); esp_wifi_stop();
} }
} }