moving toward ESPIDF events for BLE actions
This commit is contained in:
parent
6467f21fca
commit
0b4522bf7e
1 changed files with 8 additions and 3 deletions
|
|
@ -226,19 +226,24 @@ static int ble_gap_event(struct ble_gap_event *event, void *arg) {
|
|||
ESP_ERROR_CHECK(ble_hs_adv_parse_fields(&fields, event->disc.data, event->disc.length_data));
|
||||
|
||||
if(fields.name != NULL) {
|
||||
char *name = (char*)malloc(fields.name_len);
|
||||
memcpy(name, (uint8_t*)fields.name, fields.name_len);
|
||||
name[fields.name_len] = '\0';
|
||||
char *name = (char*)malloc(fields.name_len + 1);
|
||||
snprintf(name, fields.name_len + 1, "%s", fields.name);
|
||||
ESP_LOGI(TAG, "DISCOVERY: %s", name);
|
||||
|
||||
// we'll party at any bar
|
||||
if(strstr(name, "BAR") >= 0) {
|
||||
ESP_LOGI(TAG, "Let's Party!");
|
||||
/*
|
||||
* No longer want to automatically connect
|
||||
* Actions can be taken based on discovery
|
||||
uint8_t addr_type;
|
||||
ble_gap_disc_cancel();
|
||||
|
||||
ESP_ERROR_CHECK(ble_hs_id_infer_auto(0, &addr_type));
|
||||
ESP_ERROR_CHECK(ble_gap_connect(addr_type, &event->disc.addr, 30000, NULL, ble_gap_event, NULL));
|
||||
*/
|
||||
|
||||
esp_event_post(EVENT_BAROS_BLE, BAROS_BLE_DISC, name, fields.name_len + 1, portMAX_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue