remove all ESP_ERROR_CHECK(x)
This commit is contained in:
parent
62132030b7
commit
5edb904d7c
@ -128,7 +128,7 @@ IRAM_ATTR void gap_callback_handler(esp_gap_ble_cb_event_t event,
|
||||
switch (event) {
|
||||
case ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT:
|
||||
// restart scan
|
||||
ESP_ERROR_CHECK(esp_ble_gap_start_scanning(BLESCANTIME));
|
||||
esp_ble_gap_start_scanning(BLESCANTIME);
|
||||
break;
|
||||
|
||||
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 ==
|
||||
ESP_GAP_SEARCH_INQ_CMPL_EVT) // Inquiry complete, scan is done
|
||||
{ // restart scan
|
||||
ESP_ERROR_CHECK(esp_ble_gap_start_scanning(BLESCANTIME));
|
||||
esp_ble_gap_start_scanning(BLESCANTIME);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -219,8 +219,8 @@ esp_err_t register_ble_callback(bool unregister = false) {
|
||||
if (unregister) {
|
||||
|
||||
ESP_LOGI(TAG, "Unregister GAP callback...");
|
||||
ESP_ERROR_CHECK(esp_ble_gap_stop_scanning());
|
||||
ESP_ERROR_CHECK(esp_ble_gap_register_callback(NULL));
|
||||
esp_ble_gap_stop_scanning();
|
||||
esp_ble_gap_register_callback(NULL);
|
||||
|
||||
}
|
||||
|
||||
@ -230,7 +230,7 @@ esp_err_t register_ble_callback(bool unregister = false) {
|
||||
|
||||
// This function is called when gap event occurs, such as scan result.
|
||||
// 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 = {
|
||||
.scan_type = BLE_SCAN_TYPE_PASSIVE,
|
||||
@ -240,8 +240,10 @@ esp_err_t register_ble_callback(bool unregister = false) {
|
||||
/*
|
||||
#if (MACFILTER)
|
||||
.scan_filter_policy = BLE_SCAN_FILTER_ALLOW_WLIST_PRA_DIR,
|
||||
// ADV_IND, ADV_NONCONN_IND, ADV_SCAN_IND packets are used for broadcasting
|
||||
// data in broadcast applications (e.g., Beacons), so we don't want them in
|
||||
// ADV_IND, ADV_NONCONN_IND, ADV_SCAN_IND packets are used
|
||||
for broadcasting
|
||||
// data in broadcast applications (e.g., Beacons), so we
|
||||
don't want them in
|
||||
// macfilter mode
|
||||
#else
|
||||
.scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL,
|
||||
@ -257,7 +259,7 @@ esp_err_t register_ble_callback(bool unregister = false) {
|
||||
ESP_LOGI(TAG, "Set GAP 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;
|
||||
@ -269,11 +271,11 @@ void start_BLEscan(void) {
|
||||
ESP_LOGI(TAG, "Initializing bluetooth scanner ...");
|
||||
// Initialize BT controller to allocate task and other resource.
|
||||
if (btStart()) { // enable bt_controller
|
||||
ESP_ERROR_CHECK(esp_coex_preference_set(ESP_COEX_PREFER_BT));
|
||||
ESP_ERROR_CHECK(esp_bluedroid_init());
|
||||
ESP_ERROR_CHECK(esp_bluedroid_enable());
|
||||
esp_coex_preference_set(ESP_COEX_PREFER_BT);
|
||||
esp_bluedroid_init();
|
||||
esp_bluedroid_enable();
|
||||
// Register callback function for capturing bluetooth packets
|
||||
ESP_ERROR_CHECK(register_ble_callback(false));
|
||||
register_ble_callback(false);
|
||||
ESP_LOGI(TAG, "Bluetooth scanner started");
|
||||
#endif // BLECOUNTER
|
||||
} else {
|
||||
@ -286,16 +288,16 @@ void start_BLEscan(void) {
|
||||
void stop_BLEscan(void) {
|
||||
#if (BLECOUNTER)
|
||||
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_ERROR_CHECK(esp_bluedroid_disable());
|
||||
esp_bluedroid_disable();
|
||||
ESP_LOGD(TAG, "bluedroid deinit...");
|
||||
ESP_ERROR_CHECK(esp_bluedroid_deinit());
|
||||
esp_bluedroid_deinit();
|
||||
if (!btStop()) { // disable bt_controller
|
||||
ESP_LOGE(TAG, "Bluetooth controller stop failed. Resetting device");
|
||||
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");
|
||||
#endif // BLECOUNTER
|
||||
} // stop_BLEscan
|
||||
|
@ -106,7 +106,7 @@ breaking change
|
||||
// DevEUI generator using devices's MAC address
|
||||
void gen_lora_deveui(uint8_t *pdeveui) {
|
||||
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
|
||||
// will remain the same as MAC address
|
||||
// MAC is 6 bytes, devEUI 8, set middle 2 ones
|
||||
|
@ -304,9 +304,9 @@ void setup() {
|
||||
#else
|
||||
// remove bluetooth stack to gain more free memory
|
||||
btStop();
|
||||
ESP_ERROR_CHECK(esp_bt_mem_release(ESP_BT_MODE_BTDM));
|
||||
ESP_ERROR_CHECK(esp_coex_preference_set(
|
||||
ESP_COEX_PREFER_WIFI)); // configure Wifi/BT coexist lib
|
||||
esp_bt_mem_release(ESP_BT_MODE_BTDM);
|
||||
esp_coex_preference_set(
|
||||
ESP_COEX_PREFER_WIFI); // configure Wifi/BT coexist lib
|
||||
#endif
|
||||
|
||||
// initialize gps
|
||||
|
@ -171,11 +171,11 @@ void calibrate_voltage(void) {
|
||||
#ifdef BAT_MEASURE_ADC
|
||||
// configure ADC
|
||||
#ifndef BAT_MEASURE_ADC_UNIT // ADC1
|
||||
ESP_ERROR_CHECK(adc1_config_width(ADC_WIDTH_BIT_12));
|
||||
ESP_ERROR_CHECK(adc1_config_channel_atten(adc_channel, atten));
|
||||
adc1_config_width(ADC_WIDTH_BIT_12);
|
||||
adc1_config_channel_atten(adc_channel, atten);
|
||||
#else // ADC2
|
||||
// ESP_ERROR_CHECK(adc2_config_width(ADC_WIDTH_BIT_12));
|
||||
ESP_ERROR_CHECK(adc2_config_channel_atten(adc_channel, atten));
|
||||
// adc2_config_width(ADC_WIDTH_BIT_12);
|
||||
adc2_config_channel_atten(adc_channel, atten);
|
||||
#endif
|
||||
// calibrate ADC
|
||||
esp_adc_cal_value_t val_type = esp_adc_cal_characterize(
|
||||
@ -210,7 +210,7 @@ uint16_t read_voltage(void) {
|
||||
#else // ADC2
|
||||
int adc_buf = 0;
|
||||
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;
|
||||
}
|
||||
#endif // BAT_MEASURE_ADC_UNIT
|
||||
|
@ -91,8 +91,7 @@ void spi_slave_task(void *param) {
|
||||
// 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_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_LOGI(TAG, "Transaction finished with size %zu bits",
|
||||
spi_transaction.trans_len);
|
||||
|
@ -64,15 +64,13 @@ void wifi_sniffer_init(void) {
|
||||
WIFI_PROMIS_FILTER_MASK_MGMT |
|
||||
WIFI_PROMIS_FILTER_MASK_DATA};
|
||||
|
||||
ESP_ERROR_CHECK(esp_wifi_init(&wifi_cfg)); // start Wifi task
|
||||
ESP_ERROR_CHECK(
|
||||
esp_wifi_set_country(&wifi_country)); // set locales for RF and channels
|
||||
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
|
||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_NULL));
|
||||
ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE)); // no modem power saving
|
||||
ESP_ERROR_CHECK(
|
||||
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_init(&wifi_cfg); // start Wifi task
|
||||
esp_wifi_set_country(&wifi_country); // set locales for RF and channels
|
||||
esp_wifi_set_storage(WIFI_STORAGE_RAM);
|
||||
esp_wifi_set_mode(WIFI_MODE_NULL);
|
||||
esp_wifi_set_ps(WIFI_PS_NONE); // no modem power saving
|
||||
esp_wifi_set_promiscuous_filter(&wifi_filter); // set frame filter
|
||||
esp_wifi_set_promiscuous_rx_cb(&wifi_sniffer_packet_handler);
|
||||
|
||||
// setup wifi channel hopping timer
|
||||
WifiChanTimer =
|
||||
@ -85,10 +83,9 @@ void wifi_sniffer_init(void) {
|
||||
void switch_wifi_sniffer(uint8_t state) {
|
||||
if (state) {
|
||||
// start sniffer
|
||||
ESP_ERROR_CHECK(esp_wifi_start());
|
||||
ESP_ERROR_CHECK(esp_wifi_set_promiscuous(true));
|
||||
ESP_ERROR_CHECK(
|
||||
esp_wifi_set_channel(WIFI_CHANNEL_MIN, WIFI_SECOND_CHAN_NONE));
|
||||
esp_wifi_start();
|
||||
esp_wifi_set_promiscuous(true);
|
||||
esp_wifi_set_channel(WIFI_CHANNEL_MIN, WIFI_SECOND_CHAN_NONE);
|
||||
// start channel hopping timer
|
||||
if (cfg.wifichancycle > 0)
|
||||
xTimerStart(WifiChanTimer, (TickType_t)0);
|
||||
@ -97,7 +94,7 @@ void switch_wifi_sniffer(uint8_t state) {
|
||||
if (xTimerIsTimerActive(WifiChanTimer) != pdFALSE)
|
||||
xTimerStop(WifiChanTimer, (TickType_t)0);
|
||||
// stop sniffer
|
||||
ESP_ERROR_CHECK(esp_wifi_set_promiscuous(false));
|
||||
ESP_ERROR_CHECK(esp_wifi_stop());
|
||||
esp_wifi_set_promiscuous(false);
|
||||
esp_wifi_stop();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user