Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upLatest changes after implement on Curie #14
Conversation
* @note The BLE may connected multiple devices. | ||
* This call will disconnect all conected devices. | ||
*/ | ||
bool disconnect(); |
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.
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.
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?
That sounds like the right behaviour to me.
For peer device object, it only connect it self.
You been disconnect itself, right?
sgbihu
Oct 31, 2016
Author
Yes. But how to handle the local BLE device? That's my concern.
Yes. But how to handle the local BLE device? That's my concern.
sgbihu
Oct 31, 2016
Author
How to handle local device? The BLE object.
How to handle local device? The BLE object.
SidLeung
Nov 1, 2016
BLE.Disconnect of Device == disconnect all connected peripherals/central. Disconnect per object.
BLE.Disconnect of Device == disconnect all connected peripherals/central. Disconnect per object.
sgbihu
Nov 9, 2016
Author
Done
Done
* @note This method must be called before the begin method | ||
* Only for peripheral mode. | ||
*/ | ||
void setAdvertisedService(const BLEService& service); |
sgbihu
Oct 28, 2016
Author
What's different with setAdvertisedServiceUuid in line 156? Does this only set service UUID in the ADV?
What's different with setAdvertisedServiceUuid in line 156? Does this only set service UUID in the ADV?
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 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()
.
SidLeung
Nov 1, 2016
This has been resolved.
This has been resolved.
sgbihu
Nov 9, 2016
Author
done
done
* @note This method must be called before the begin method | ||
* Only for peripheral mode. | ||
*/ | ||
void setServiceSolicitationUuid(const char* serviceSolicitationUuid); |
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?
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?
sandeepmistry
Oct 28, 2016
Contributor
That is correct.
That is correct.
SidLeung
Nov 1, 2016
Sandeep will provide detail info on this topic.
Sandeep will provide detail info on this topic.
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
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
sgbihu
Nov 9, 2016
Author
Done
Done
* @note This method must be called before the begin method | ||
* Only for peripheral mode. | ||
*/ | ||
void setManufacturerData(const unsigned char manufacturerData[], |
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.
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.
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.
I'm unclear about your comment, please clarify. The manufacturer data is only for advertisement and it is independent from the connection.
sgbihu
Oct 31, 2016
Author
How to handle the manufacture data in the sketches?
How to handle the manufacture data in the sketches?
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.
How user to access the manufacturer data? The manufacturer data is self defined. The BLE lib can't recognized the format.
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.
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.
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.
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 |
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?
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?
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.
We should keep them for the user to process advertisement and scan response data.
We can discuss memory concerns in the 101 core.
SidLeung
Nov 1, 2016
With buffering of ADV data, these APIs are needed.
With buffering of ADV data, these APIs are needed.
sgbihu
Nov 9, 2016
Author
Done
Done
* | ||
* @note Peer devices only. Do nothing if local BLE device called. | ||
*/ | ||
void linkLost(); |
sgbihu
Oct 28, 2016
Author
Not used. Need delete.
Not used. Need delete.
SidLeung
Nov 1, 2016
Agree. Removed,
Agree. Removed,
// Does this necessory? This will take more memory to store the ADV | ||
// I suggest delete it. | ||
*/ | ||
void startScanningWithDuplicates(); |
sgbihu
Oct 28, 2016
Author
Does this necessary? What different between startScanning?
Does this necessary? What different between startScanning?
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.
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.
sgbihu
Oct 31, 2016
Author
How many ADV devices we need to buffered?
How many ADV devices we need to buffered?
sgbihu
Nov 9, 2016
Author
done
done
* | ||
* @note none | ||
*/ | ||
void startScanning(BLEService& service); |
sgbihu
Oct 28, 2016
Author
How to make user process the ADV RAW data?
How to make user process the ADV RAW data?
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
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
SidLeung
Nov 1, 2016
Need to determine if the Nordic stack is capable of filtering BT addr.
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, |
sgbihu
Oct 28, 2016
Author
Now only notify the Written event. ValueUpdated event need be implemented.
Now only notify the Written event. ValueUpdated event need be implemented.
sandeepmistry
Oct 28, 2016
Contributor
Sorry, can you please expand on what you mean by this?
Sorry, can you please expand on what you mean by this?
sgbihu
Oct 31, 2016
Author
Only notify the written event to user. The valueUpdated doesn't notify to user.
Only notify the written event to user. The valueUpdated doesn't notify to user.
SidLeung
Nov 1, 2016
Will add the update event to baseline.
Will add the update event to baseline.
sgbihu
Nov 9, 2016
Author
Done
Done
bool writeValue(const char* value); | ||
|
||
// peripheral mode | ||
bool broadcast(); // broadcast the characteristic value in the advertisement data |
sgbihu
Oct 28, 2016
Author
What's this mean? Do you give me some background?
What's this mean? Do you give me some background?
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.
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.
sgbihu
Oct 31, 2016
Author
So when return value is true?
So when return value is true?
SidLeung
Nov 1, 2016
Sandeep will provide an example sketch.
Will not in the baseline and will be a feature.
Sandeep will provide an example sketch.
Will not in the baseline and will be a feature.
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).
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).
sgbihu
Nov 9, 2016
Author
Done
Done
* | ||
* @note What different with canUnsubscribe? | ||
*/ | ||
bool canSubscribe(); |
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?
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?
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();
}
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();
}
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.
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.
sgbihu
Nov 9, 2016
Author
Done
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 |
sgbihu
Oct 31, 2016
Author
BLEDescriptor also need property.
BLEDescriptor also need property.
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,
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,
sgbihu
Nov 9, 2016
Author
Done
Done
* | ||
* @note Central mode only. How to distinguish the peripheral? | ||
*/ | ||
BLEDevice peripheral(); |
sgbihu
Nov 15, 2016
Author
In multiple connection scenario, this method will auto return the next connected peripheral devices. Does this acceptable?
In multiple connection scenario, this method will auto return the next connected peripheral devices. Does this acceptable?
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.
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 another candidate for closing up? |
Yup! |
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.