esp32-snippets
esp32-snippets copied to clipboard
Is it possible increase the size of the Scan Response data for setBeacon()?
For a modified version method of SetBeacon based on the eddystone examples, I am trying to advertise more than 20 bytes for the Scan Response Data from an ESP32 peripheral device to a mobile device. I read that it is possible to send 31 bytes for the scan response data but I am having trouble getting past 20 bytes. After testing around, I found that I can send 20 bytes or less without any issues when I call setServiceData with 20 bytes or less, but anything bigger and it does not send the advertisement data, or at least I do not see it on my phone.
Is there somewhere in the source files that I need to change/set the size of the scan response data?
Code: `void setBeacon() { char beacon_data[31]; uint16_t beconUUID = 0xFEAA;
BLEAdvertisementData oAdvertisementData = BLEAdvertisementData();
oAdvertisementData.setFlags(0x06); // GENERAL_DISC_MODE 0x02 | BR_EDR_NOT_SUPPORTED 0x04 oAdvertisementData.setCompleteServices(BLEUUID(beconUUID)); beacon_data[0] = 0x20; beacon_data[1] = 0x0D; . . .
oAdvertisementData.setServiceData(BLEUUID(beconUUID), std::string(beacon_data, 31));
pAdvertising->setScanResponseData(oAdvertisementData);
}`
Output log:
[V][BLEUtils.cpp:1036] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT [D][BLEAdvertising.cpp:169] setScanResponseData(): >> setScanResponseData [V][BLEUtils.cpp:1251] dumpGapEvent(): *** dumpGapEvent: Logger not coded *** [D][BLEAdvertising.cpp:177] setScanResponseData(): << setScanResponseData [D][BLEDevice.cpp:557] getAdvertising(): get advertising [D][BLEAdvertising.cpp:479] handleGAPEvent(): handleGAPEvent [event no: 17] [I][BLEAdvertising.cpp:495] handleGAPEvent(): STOP advertising [D][BLEAdvertising.cpp:186] start(): >> start: customAdvData: 0, customScanResponseData: 1 [D][BLEAdvertising.cpp:205] start(): - no services advertised [D][BLEAdvertising.cpp:246] start(): << start [V][BLEUtils.cpp:1036] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT [V][BLEUtils.cpp:1251] dumpGapEvent(): *** dumpGapEvent: Logger not coded *** [D][BLEDevice.cpp:557] getAdvertising(): get advertising [D][BLEAdvertising.cpp:479] handleGAPEvent(): handleGAPEvent [event no: 5] [V][BLEUtils.cpp:1036] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT [V][BLEUtils.cpp:1251] dumpGapEvent(): *** dumpGapEvent: Logger not coded *** [D][BLEDevice.cpp:557] getAdvertising(): get advertising [D][BLEAdvertising.cpp:479] handleGAPEvent(): handleGAPEvent [event no: 0] [V][BLEUtils.cpp:1036] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_ADV_START_COMPLETE_EVT [V][BLEUtils.cpp:1251] dumpGapEvent(): *** dumpGapEvent: Logger not coded *** [D][BLEDevice.cpp:557] getAdvertising(): get advertising [D][BLEAdvertising.cpp:479] handleGAPEvent(): handleGAPEvent [event no: 6] [D][BLEAdvertising.cpp:256] stop(): >> stop [D][BLEAdvertising.cpp:262] stop(): << stop