code sanitizations

This commit is contained in:
Verkehrsrot 2019-07-21 19:21:11 +02:00
parent bb7b8b90f8
commit 7057b59b0f
3 changed files with 19 additions and 18 deletions

View File

@ -146,7 +146,7 @@ IRAM_ATTR void gap_callback_handler(esp_gap_ble_cb_event_t event,
break; break;
} }
#if(VENDORFILTER) #if (VENDORFILTER)
if ((p->scan_rst.ble_addr_type == BLE_ADDR_TYPE_RANDOM) || if ((p->scan_rst.ble_addr_type == BLE_ADDR_TYPE_RANDOM) ||
(p->scan_rst.ble_addr_type == BLE_ADDR_TYPE_RPA_RANDOM)) { (p->scan_rst.ble_addr_type == BLE_ADDR_TYPE_RPA_RANDOM)) {
@ -162,6 +162,7 @@ IRAM_ATTR void gap_callback_handler(esp_gap_ble_cb_event_t event,
/* to be improved in vendorfilter if: /* to be improved in vendorfilter if:
// you can search for elements in the payload using the // you can search for elements in the payload using the
// function esp_ble_resolve_adv_data() // function esp_ble_resolve_adv_data()
// //
@ -207,21 +208,21 @@ esp_err_t register_ble_callback(void) {
ESP_ERROR_CHECK(esp_ble_gap_register_callback(&gap_callback_handler)); ESP_ERROR_CHECK(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,
#if(VENDORFILTER) #if (VENDORFILTER)
.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 for broadcasting
// data in broadcast applications (e.g., Beacons), so we don't want them in // data in broadcast applications (e.g., Beacons), so we don't want them in
// vendorfilter mode // vendorfilter mode
#else #else
.scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL, .scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL,
#endif #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
.scan_window = (uint16_t)(BLESCANWINDOW / 0.625) // Time = N * 0.625 msec .scan_window = (uint16_t)(BLESCANWINDOW / 0.625) // Time = N * 0.625 msec
}; };
ESP_LOGI(TAG, "Set GAP scan parameters"); ESP_LOGI(TAG, "Set GAP scan parameters");
@ -234,12 +235,11 @@ esp_err_t register_ble_callback(void) {
} // register_ble_callback } // register_ble_callback
void start_BLEscan(void) { void start_BLEscan(void) {
#if(BLECOUNTER) #if (BLECOUNTER)
ESP_LOGI(TAG, "Initializing bluetooth scanner ..."); ESP_LOGI(TAG, "Initializing bluetooth scanner ...");
ESP_ERROR_CHECK(esp_coex_preference_set( ESP_ERROR_CHECK(esp_coex_preference_set(
(esp_coex_prefer_t) ESP_COEX_PREFER_BALANCE)); // configure Wifi/BT coexist lib
ESP_COEX_PREFER_BALANCE)); // configure Wifi/BT coexist lib
// Initialize BT controller to allocate task and other resource. // Initialize BT controller to allocate task and other resource.
btStart(); btStart();
@ -254,14 +254,14 @@ void start_BLEscan(void) {
} // start_BLEscan } // start_BLEscan
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(esp_ble_gap_register_callback(NULL)); ESP_ERROR_CHECK(esp_ble_gap_register_callback(NULL));
ESP_ERROR_CHECK(esp_bluedroid_disable()); ESP_ERROR_CHECK(esp_bluedroid_disable());
ESP_ERROR_CHECK(esp_bluedroid_deinit()); ESP_ERROR_CHECK(esp_bluedroid_deinit());
btStop(); // disable bt_controller btStop(); // disable bt_controller
ESP_ERROR_CHECK(esp_coex_preference_set(( ESP_ERROR_CHECK(esp_coex_preference_set(
esp_coex_prefer_t)ESP_COEX_PREFER_WIFI)); // configure Wifi/BT coexist lib ESP_COEX_PREFER_WIFI)); // configure Wifi/BT coexist lib
ESP_LOGI(TAG, "Bluetooth scanner stopped"); ESP_LOGI(TAG, "Bluetooth scanner stopped");
#endif // BLECOUNTER #endif // BLECOUNTER
} // stop_BLEscan } // stop_BLEscan

View File

@ -80,11 +80,12 @@ void IRAM_ATTR gps_storetime(gpsStatus_t &gps_store) {
if (gps.time.isUpdated() && gps.date.isValid() && (gps.time.age() < 1000)) { if (gps.time.isUpdated() && gps.date.isValid() && (gps.time.age() < 1000)) {
// nmea telegram serial delay compensation; not sure if we need this? // nmea telegram serial delay compensation; not sure if we need this?
/*
if (gps.time.age() > nmea_txDelay_ms) if (gps.time.age() > nmea_txDelay_ms)
gps_store.timedate.Second = gps.time.second() + 1; gps_store.timedate.Second = gps.time.second() + 1;
else else
gps_store.timedate.Second = gps.time.second(); gps_store.timedate.Second = gps.time.second();
*/
gps_store.timedate.Second = gps.time.second(); gps_store.timedate.Second = gps.time.second();
gps_store.timedate.Minute = gps.time.minute(); gps_store.timedate.Minute = gps.time.minute();

View File

@ -262,8 +262,8 @@ void setup() {
// 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_ERROR_CHECK(esp_bt_mem_release(ESP_BT_MODE_BTDM));
ESP_ERROR_CHECK(esp_coex_preference_set(( ESP_ERROR_CHECK(esp_coex_preference_set(
esp_coex_prefer_t)ESP_COEX_PREFER_WIFI)); // configure Wifi/BT coexist lib ESP_COEX_PREFER_WIFI)); // configure Wifi/BT coexist lib
#endif #endif
// initialize gps // initialize gps