How can I add scan response data to the SDK example ble_app_beacon?
How can I add scan response data to the SDK example ble_app_beacon?
Hi!
The approach might vary depending on what version of the SDK you are working with.
Maybe you could provide a little more information?
SDK version, what device, softdevice version etc. is useful information to add in your questions.
However, you can take a look at our advertising tutorial, and the chapter about the Scan response data.
The tutorial is from one of the older SDK but the approach will be similiar.
Also, the ble_app_uart example adds data to the scan reponse packet, so you can get an idea of how it's done.
Let me know if you have any further questions.
Best regards,
Joakim.
I have looked into the ble_app_uart example, but I cannot find the line(s) where the scan response data is set.
I receive
Advertisement data: 02:01:05:0C:09:4E:6F:72:64:69:63:5F:55:41:52:54 (here at the end is Nordic_UART)
Scan response data: 11:07:9E:CA:DC:24:0E:E5:A9:E0:93:F3:A3:B5:01:00:40:6E
But where is the scan response data in the code?
Thanks for your help!
I forgot a few lines of code:
#define APP_BEACON_INFO_LENGTH 0x17 /**< Total length of information advertised by the Beacon. */ #define APP_ADV_DATA_LENGTH 0x15 /**< Length of manufacturer specific data in the advertisement. */ #define APP_DEVICE_TYPE 0x02 /**< 0x02 refers to Beacon. */ #define APP_MEASURED_RSSI 0xC3 /**< The Beacon's measured RSSI at 1 meter distance in dBm. */ #define APP_COMPANY_IDENTIFIER 0x0059 /**< Company identifier for Nordic Semiconductor ASA. as per www.bluetooth.org. */ #define APP_MAJOR_VALUE 0x01, 0x02 /**< Major value used to identify Beacons. */ #define APP_MINOR_VALUE 0x03, 0x04 /**< Minor value used to identify Beacons. */ #define APP_BEACON_UUID 0x01, 0x12, 0x23, 0x34, \ 0x45, 0x56, 0x67, 0x78, \ 0x89, 0x9a, 0xab, 0xbc, \ 0xcd, 0xde, 0xef, 0xf0 /**< Proprietary UUID for Beacon. */ #define MAJ_VAL_OFFSET_IN_BEACON_INFO 18 /**< Position of the MSB of the Major Value in m_beacon_info array. */ static uint8_t m_beacon_info[APP_BEACON_INFO_LENGTH] = /**< Information advertised by the Beacon. */ { APP_DEVICE_TYPE, // Manufacturer specific information. Specifies the device type in this // implementation. APP_ADV_DATA_LENGTH, // Manufacturer specific information. Specifies the length of the // manufacturer specific data in this implementation. APP_BEACON_UUID, // 128 bit UUID value. APP_MAJOR_VALUE, // Major arbitrary value that can be used to distinguish between Beacons. APP_MINOR_VALUE, // Minor arbitrary value that can be used to distinguish between Beacons. APP_MEASURED_RSSI // Manufacturer specific information. The Beacon's measured TX power in // this implementation. };
Hi.
Thanks for sharing your solution, so that others might benefit from it.
Best regards,
Joakim.
Also do not forget to change these lines (if not yet done):
static ble_gap_adv_data_t m_adv_data = { .adv_data = { .p_data = m_enc_advdata, .len = BLE_GAP_ADV_SET_DATA_SIZE_MAX }, .scan_rsp_data = { .p_data = m_enc_scan_response_data, //was NULL, .len = BLE_GAP_ADV_SET_DATA_SIZE_MAX // was 0 } };
In this code when it says m_enc_scan_response_data is undeclared.
If possible can you please share your main.c file, would greatly help indeed.
Added m_enc_scan_response_data by:
static uint8_t m_enc_scan_response_data[BLE_GAP_ADV_SET_DATA_SIZE_MAX];
#define APP_ADV_INTERVAL 64 /**< The advertising interval (in units of 0.625 ms. This value corresponds to 40 ms). */ #define APP_ADV_DURATION 18000
err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG); APP_ERROR_CHECK(err_code);
err_code = nrf_sdh_ble_enable(&ram_start); APP_ERROR_CHECK(err_code);
Added m_enc_scan_response_data by:
static uint8_t m_enc_scan_response_data[BLE_GAP_ADV_SET_DATA_SIZE_MAX];
#define APP_ADV_INTERVAL 64 /**< The advertising interval (in units of 0.625 ms. This value corresponds to 40 ms). */ #define APP_ADV_DURATION 18000
err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG); APP_ERROR_CHECK(err_code);
err_code = nrf_sdh_ble_enable(&ram_start); APP_ERROR_CHECK(err_code);