Fortran
Fortran

Reputation: 593

ESP-IDF BLE scanning an advertisement package

i am working on the ESP32 chip and am trying to get the all avaliable information from advertising. For this purpose I use the nRF connect app by NORDIC with prepare advertiser enter image description here

I scan for the device and successfully only read the complete name but i want to extract all the information from advertising.

case ESP_GAP_BLE_SCAN_RESULT_EVT:           
            if(param->scan_rst.search_evt == ESP_GAP_SEARCH_INQ_RES_EVT) {


                if(!alreadyDiscovered(param->scan_rst.bda)) {
                    
                    printf("##############################\n");
                     esp_log_buffer_hex("!!!!", param->scan_rst.ble_adv, 62);
                    printf("##############################\n");
                    printf("ESP_GAP_BLE_SCAN_RESULT_EVT\n");
                    printf("Device found: ADDR=");
                    for(int i = 0; i < ESP_BD_ADDR_LEN; i++) {
                        printf("%02X", param->scan_rst.bda[i]);
                        if(i != ESP_BD_ADDR_LEN -1) printf(":");
                    }
                    
                    // try to read the complete name
                    uint8_t *adv_name = NULL;
                    uint8_t adv_name_len = 0;
                    adv_name = esp_ble_resolve_adv_data(param->scan_rst.ble_adv, ESP_BLE_AD_TYPE_NAME_CMPL, &adv_name_len);
                    if(adv_name) {
                        printf("\nFULL NAME=");
                        for(int i = 0; i < adv_name_len; i++) printf("%c", adv_name[i]);
                    }
                    
                    printf("\n\n");
                    addDevice(param->scan_rst.bda);
                }
                
            }

Do you know why esp_log_buffer_hex("!!!!", param->scan_rst.ble_adv, 62); doesn't work

Upvotes: 1

Views: 1025

Answers (1)

romkey
romkey

Reputation: 7044

esp_log_buffer_hex() logs at the INFO level. If you don't set the log level for the service being logged, you won't see messages.

Make sure that you run

esp_log_level_set("!!!!", ESP_LOG_INFO)

before your call to esp_log_buffer_hex() to enable the messages you're trying to log.

Upvotes: 1

Related Questions