Skip to content
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

Latest changes after implement on Curie #14

Closed
wants to merge 4 commits into from

Conversation

@sgbihu
Copy link

@sgbihu sgbihu commented Oct 28, 2016

Hi @sandeepmistry

I have a draft implementation about new API. But I found some questions. I will list it and need discuss with you to close it.

* @note The BLE may connected multiple devices.
* This call will disconnect all conected devices.
*/
bool disconnect();

This comment has been minimized.

@sgbihu

sgbihu Oct 28, 2016
Author

The BLE may connected multiple devices. Does this call disconnect all connected devices if the device object is BLE?

For peer device object, it only connect it self.

This comment has been minimized.

@sandeepmistry

sandeepmistry Oct 28, 2016
Contributor

That sounds like the right behaviour to me.

For peer device object, it only connect it self.

You been disconnect itself, right?

This comment has been minimized.

@sgbihu

sgbihu Oct 31, 2016
Author

Yes. But how to handle the local BLE device? That's my concern.

This comment has been minimized.

@sgbihu

sgbihu Oct 31, 2016
Author

How to handle local device? The BLE object.

This comment has been minimized.

@SidLeung

SidLeung Nov 1, 2016

BLE.Disconnect of Device == disconnect all connected peripherals/central. Disconnect per object.

This comment has been minimized.

@sgbihu

sgbihu Nov 9, 2016
Author

Done

* @note This method must be called before the begin method
* Only for peripheral mode.
*/
void setAdvertisedService(const BLEService& service);

This comment has been minimized.

@sgbihu

sgbihu Oct 28, 2016
Author

What's different with setAdvertisedServiceUuid in line 156? Does this only set service UUID in the ADV?

This comment has been minimized.

@sandeepmistry

sandeepmistry Oct 28, 2016
Contributor

This is more of a convenience API my colleague proposed.

Basically the following are equivalent:

BLE.setAdvertisedServiceUuid(service.uuid());

BLE.setAdvertisedService(service);

It's so the user doesn't have to call service.uuid().

This comment has been minimized.

@SidLeung

SidLeung Nov 1, 2016

This has been resolved.

This comment has been minimized.

@sgbihu

sgbihu Nov 9, 2016
Author

done

* @note This method must be called before the begin method
* Only for peripheral mode.
*/
void setServiceSolicitationUuid(const char* serviceSolicitationUuid);

This comment has been minimized.

@sgbihu

sgbihu Oct 28, 2016
Author

Does this only be used in ADV? And the type in ADV is BT_DATA_SOLICIT16 (0x14) and BT_DATA_SOLICIT128 (0x15).

Am I correct?

This comment has been minimized.

@sandeepmistry

sandeepmistry Oct 28, 2016
Contributor

That is correct.

This comment has been minimized.

@SidLeung

SidLeung Nov 1, 2016

Sandeep will provide detail info on this topic.

This comment has been minimized.

@sandeepmistry

sandeepmistry Nov 1, 2016
Contributor

One application of service solicitation in the new Bluetooth SIG HTTP Proxy Service (HPS): https://www.bluetooth.org/docman/handlers/downloaddoc.ashx?doc_id=308344 - see page 16 of PDF

This comment has been minimized.

@sgbihu

sgbihu Nov 9, 2016
Author

Done

* @note This method must be called before the begin method
* Only for peripheral mode.
*/
void setManufacturerData(const unsigned char manufacturerData[],

This comment has been minimized.

@sgbihu

sgbihu Oct 28, 2016
Author

To support this area, the central need add callback to allow user handle the data. Line 374 and Line 385 has the defined the API for local name and services.
If user want set Manufacturer data, or other data in the ADV, how we allow user to establish the connection.

This comment has been minimized.

@sandeepmistry

sandeepmistry Oct 28, 2016
Contributor

I'm unclear about your comment, please clarify. The manufacturer data is only for advertisement and it is independent from the connection.

This comment has been minimized.

@sgbihu

sgbihu Oct 31, 2016
Author

How to handle the manufacture data in the sketches?

This comment has been minimized.

@sgbihu

sgbihu Oct 31, 2016
Author

How user to access the manufacturer data? The manufacturer data is self defined. The BLE lib can't recognized the format.

This comment has been minimized.

@SidLeung

SidLeung Nov 1, 2016

Manufacture data == defined in BlueTooth spec. Sandeep will provide a link and iBeacon spec, if possible.

Baseline testing - use iBeacon.

Need to API, in Central, to provide the app for processing the manufacturer data. This is feature.

This comment has been minimized.

@sandeepmistry

sandeepmistry Nov 1, 2016
Contributor

The iBeacon specification can be downloaded from the following link: https://developer.apple.com/ibeacon/ - see page 6/7 for the payload value put in the manufacturer section of the advertisement data.

* @note none //TODO: The implementation doesn't save the ADV's local name.
*/
bool hasLocalName() const;

bool hasAdvertisedServiceUuid() const; // does the peripheral advertise a service
bool hasAdvertisedServiceUuid(int index) const; // does the peripheral advertise a service n
int advertisedServiceUuidCount() const; // number of services the peripheral is advertising

This comment has been minimized.

@sgbihu

sgbihu Oct 28, 2016
Author

I think Line 431 to 435 are not necessary. Those API are designed for verify the scanned device, for we can set the critical to filter the device and decrease the memory load. What's your idea?

This comment has been minimized.

@sandeepmistry

sandeepmistry Oct 28, 2016
Contributor

We should keep them for the user to process advertisement and scan response data.

We can discuss memory concerns in the 101 core.

This comment has been minimized.

@SidLeung

SidLeung Nov 1, 2016

With buffering of ADV data, these APIs are needed.

This comment has been minimized.

@sgbihu

sgbihu Nov 9, 2016
Author

Done

*
* @note Peer devices only. Do nothing if local BLE device called.
*/
void linkLost();

This comment has been minimized.

@sgbihu

sgbihu Oct 28, 2016
Author

Not used. Need delete.

This comment has been minimized.

@SidLeung

SidLeung Nov 1, 2016

Agree. Removed,

// Does this necessory? This will take more memory to store the ADV
// I suggest delete it.
*/
void startScanningWithDuplicates();

This comment has been minimized.

@sgbihu

sgbihu Oct 28, 2016
Author

Does this necessary? What different between startScanning?

This comment has been minimized.

@sandeepmistry

sandeepmistry Oct 28, 2016
Contributor

I'll start a more detailed discussion for scanning.

startScanning will only report the discovered BT address once (it is filtered out after the first time), startScanningWithDuplicates will report the BT address continuously.

This comment has been minimized.

@sgbihu

sgbihu Oct 31, 2016
Author

How many ADV devices we need to buffered?

This comment has been minimized.

@sgbihu

sgbihu Nov 9, 2016
Author

done

*
* @note none
*/
void startScanning(BLEService& service);

This comment has been minimized.

@sgbihu

sgbihu Oct 28, 2016
Author

How to make user process the ADV RAW data?

This comment has been minimized.

@sandeepmistry

sandeepmistry Oct 28, 2016
Contributor

We should not expose the raw advertisement data.

Please see the following example sketch for the public facing API for the user to access the combine advertisement and scan response data: https://github.com/arduino/ArduinoCore-API/blob/master/api/BLE/examples/central/scan/scan.ino

This comment has been minimized.

@SidLeung

SidLeung Nov 1, 2016

Need to determine if the Nordic stack is capable of filtering BT addr.

@@ -27,7 +27,8 @@ enum BLECharacteristicEvent {
BLEWritten = 0,
BLESubscribed = 1,
BLEUnsubscribed = 2,
BLEValueUpdated = 3
BLEValueUpdated = 3,

This comment has been minimized.

@sgbihu

sgbihu Oct 28, 2016
Author

Now only notify the Written event. ValueUpdated event need be implemented.

This comment has been minimized.

@sandeepmistry

sandeepmistry Oct 28, 2016
Contributor

Sorry, can you please expand on what you mean by this?

This comment has been minimized.

@sgbihu

sgbihu Oct 31, 2016
Author

Only notify the written event to user. The valueUpdated doesn't notify to user.

This comment has been minimized.

@SidLeung

SidLeung Nov 1, 2016

Will add the update event to baseline.

This comment has been minimized.

@sgbihu

sgbihu Nov 9, 2016
Author

Done

bool writeValue(const char* value);

// peripheral mode
bool broadcast(); // broadcast the characteristic value in the advertisement data

This comment has been minimized.

@sgbihu

sgbihu Oct 28, 2016
Author

What's this mean? Do you give me some background?

This comment has been minimized.

@sandeepmistry

sandeepmistry Oct 28, 2016
Contributor

Broadcast will add the characteristics value to the advertisement as a service data entry.

For example for the Eddystone protocol: https://github.com/google/eddystone/blob/master/protocol-specification.md#common-elements

Service data has the EIR type of 0x16.

This comment has been minimized.

@sgbihu

sgbihu Oct 31, 2016
Author

So when return value is true?

This comment has been minimized.

@SidLeung

SidLeung Nov 1, 2016

Sandeep will provide an example sketch.

Will not in the baseline and will be a feature.

This comment has been minimized.

@sandeepmistry

sandeepmistry Nov 1, 2016
Contributor

Here's a example sketch for a simple counter that updates every second:

#include <ArduinoBLE.h>

BLEService testService("abcd"); // must be 16-bit UUID for broadcasting service
BLEIntCharacteristic testCharacteristic("ed12", BLERead);

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0;        // will store last time LED was updated

// constants won't change :
const long interval = 1000;           // interval at which to blink (milliseconds)

int counter = 0;

void setup() {
  BLE.begin();

  // add the characteristic to the service
  testService.addCharacteristic(testCharacteristic);

  // add the service to the GATT server
  BLE.addService(testService);

  // start advertising
  BLE.startAdvertising();

  // initialize the characteristc value
  testCharacteristic.setValue(0);

  // broadcast the characteristic, this will make it appear in the advertisement as service data
  //
  // 06 16 cd ab 00 00 00 00
  // -> 0x06: EIR length
  // -> 0x16: service data EIR type
  // -> 0xabcd: service UUID
  // -> 0x00000000: service data value (same as characteristic value)

  testCharacteristic.broadcast();
}

void loop() {
  // check to see if it's time to update the counter
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;

    // increment the counter
    counter++;

    // update the characteristic value
    // the value will be updated in the GATT server attribute table
    // as well as in the advertisement data, since the value is broadcasted
    testCharacteristic.setValue(counter);
  }
}

When scanning with nRF Master control panel on Android, you should be able to see the service data field when you look at a particular device's advertisement data (without connecting).

This comment has been minimized.

@sgbihu

sgbihu Nov 9, 2016
Author

Done

*
* @note What different with canUnsubscribe?
*/
bool canSubscribe();

This comment has been minimized.

@sgbihu

sgbihu Oct 28, 2016
Author

What all those can* API mean? Does this only based on properties?
If yes, how we explain the canSubscribe and canUnsubscribe?
If not, what different with subscribed method?

This comment has been minimized.

@sandeepmistry

sandeepmistry Oct 28, 2016
Contributor

They are same really.

It's based on properties and connection status of the device. For example, if the device is disconnected can* should return false. Also, for scenarios like this it should be false:

BLECharacteristic simpleKeyCharacteristic = peripheral.characteristic("ffe1");

if (!simpleKeyCharacteristic) {
  // should be false, because the characteristic does not exist on the peripheral
  simpleKeyCharacteristic.canSubscribe();
}

This comment has been minimized.

@sgbihu

sgbihu Oct 31, 2016
Author

I don't think so. We can delete some duplicated APIs in you description. The subscribe method are called in the sketches. So the user need to know the property and the subscribe state. And the sketch will subscribe/unsubscribe based on the state. The property is based on the discovered/user setup, the subscribe is online.

This comment has been minimized.

@sgbihu

sgbihu Nov 9, 2016
Author

Done

{
public:
BLEDescriptor();
BLEDescriptor(const char* uuid, const unsigned char value[], unsigned char valueLength); // create a descriptor the specified uuid and value
BLEDescriptor(const char* uuid, const unsigned char value[], unsigned short valueLength); // create a descriptor the specified uuid and value

This comment has been minimized.

@sgbihu

sgbihu Oct 31, 2016
Author

BLEDescriptor also need property.

This comment has been minimized.

@SidLeung

SidLeung Nov 1, 2016

This is a future feature for the app to change the descriptor of a peripheral. The Nordic stack does not allow descriptor to be changed.

This is an example for a changeable descriptor,

https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.descriptor.gatt.server_characteristic_configuration.xml

This comment has been minimized.

@sgbihu

sgbihu Nov 9, 2016
Author

Done

*
* @note Central mode only. How to distinguish the peripheral?
*/
BLEDevice peripheral();

This comment has been minimized.

@sgbihu

sgbihu Nov 15, 2016
Author

In multiple connection scenario, this method will auto return the next connected peripheral devices. Does this acceptable?

This comment has been minimized.

@sandeepmistry

sandeepmistry Nov 16, 2016
Contributor

I don't think I had this call in the original spec.

What are the use cases for it? I think it can be removed all together actually.

@facchinm facchinm force-pushed the arduino:master branch from 141b283 to 8ad0c60 Oct 30, 2018
@facchinm facchinm force-pushed the arduino:master branch from f920643 to 7f8de58 Apr 10, 2020
@aentinger
Copy link
Contributor

@aentinger aentinger commented Oct 7, 2020

@facchinm another candidate for closing up?

@facchinm
Copy link
Member

@facchinm facchinm commented Oct 8, 2020

Yup!

@facchinm facchinm closed this Oct 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.