Skip to content

ScanResponse Data #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dwilday opened this issue Aug 6, 2019 · 10 comments
Closed

ScanResponse Data #11

dwilday opened this issue Aug 6, 2019 · 10 comments
Labels
status: waiting for information More information must be provided before work can proceed

Comments

@dwilday
Copy link

dwilday commented Aug 6, 2019

Can you add support for sending Scan Response Data?

@per1234 per1234 added the type: enhancement Proposed improvement label Aug 6, 2019
@sandeepmistry
Copy link
Contributor

Hi @dwilday,

The scan response currently is sent, with the value of the local name if set.

@dwilday
Copy link
Author

dwilday commented Aug 27, 2019

Right, I guess I should have been more specific. Can we add support for passing custom data in the Scan Response Data? For example with Adafruit's Bluefruit Library I'm able to call Bluefruit.ScanResponse.addData to add additional data to the scan response.

@NimaaZx
Copy link

NimaaZx commented Aug 28, 2019

Hey. Why don't use Ble 5 feature, Secondary advertising channel method instead of scan response and request method ?

@theBASTI0N
Copy link

With the scan response is their a method to get the advertised data?

Once I can get that adding additional data, or decoding depending on type of advertisement will be possible?

@sandeepmistry
Copy link
Contributor

Hi @dwilday,

Is there something specific you want to put in the scan response, in the sense should we have a nice friendly API to do that instead of a generic API for raw scan response data?

For a work around for now you could try to use HCI. leSetScanResponseData(length, data);: https://github.com/arduino-libraries/ArduinoBLE/blob/master/src/utility/HCI.h#L53

@sandeepmistry sandeepmistry added status: waiting for information More information must be provided before work can proceed and removed type: enhancement Proposed improvement labels Sep 18, 2019
@marcrupprath
Copy link

Hello,
i tried, but it seams that is will be ignored ?
Dou you have a working example for cutom SCAN response data

@polldo
Copy link
Contributor

polldo commented Jul 24, 2020

Hi @marcrupprath ,
a working example for scan response data is already in this library:

if (HCI.leSetScanResponseData(scanResponseDataLen, scanResponseData) != 0) {

As you can see, currently the local name of the device is not directly advertised but it is sent as a scan response data.

@marcrupprath
Copy link

To make a long story short i will tr direct you to the discussion:
What are the requirements to use , in our case. the Arduino BLE33 as compatible device for LEGO apps.
We did it for ESP32 as you can see: Think about what is missing to do same with ArduinoBLE

https://www.eurobricks.com/forum/index.php?/forums/topic/179180-powered-up-hub-emulator-with-esp32/
https://github.com/GianCann/ATS/blob/master/ESP32_LEGO/PUPHubEmulator.ino

Have a special Look for advertising data, local name and manucaturer data used in this example.

@polldo
Copy link
Contributor

polldo commented Jul 27, 2020

Hi @marcrupprath ,
currently it is only possible to insert the local name into the scan response data. I will work on extending the possible parameters in the scan response.
However, as a temporarily workaround, you can directly use the HCI.leSetScanResponseData function in this way:

#include "ArduinoBLE.h"

#define SERVICE_UUID "00001623-1212-EFDE-1623-785FEABCD123"

uint8_t scanData[] = {0x02,0x01,0x06,0x09,0xFF,0x97,0x03,0x00,0x41,0x07,0xB2,0x43,0x00};        

void setup()
{ 
  BLE.begin();
  
  // exploit the already existing functions to advertise the service
  BLE.setAdvertisedServiceUuid(SERVICE_UUID);
  BLE.advertise();
  
  // disable advertising to insert the custom scan response data
  HCI.leSetAdvertiseEnable(0x00);
  HCI.leSetScanResponseData(sizeof(scanData), scanData);
  
  // enable advertising
  HCI.leSetAdvertiseEnable(0x01);
}

void loop()
{

}

Also, to access HCI functions you should add #include "utility/HCI.h" in 'ArduinoBLE.h' file

cparata added a commit to cparata/ArduinoBLE that referenced this issue Sep 30, 2020
Improve STM32duinoBLE robustness and flexibility
@polldo
Copy link
Contributor

polldo commented Nov 2, 2020

@marcrupprath @dwilday
It is now possible to configure both advertising and scan response data given an already encoded raw data packet.
Also scan response data can be configured in a more flexible way
Implemented here #117
Examples here #134

@polldo polldo closed this as completed Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting for information More information must be provided before work can proceed
Projects
None yet
Development

No branches or pull requests

7 participants