sandeepmistry / arduino-BLEPeripheral

An Arduino library for creating custom BLE peripherals with Nordic Semiconductor's nRF8001 or nR51822.
MIT License
462 stars 179 forks source link

Advertise multiple services and different data types #104

Closed chiararuggeri closed 7 years ago

chiararuggeri commented 7 years ago

Hi Sandeep, I added to the advertising module the capability to advertise more than a service, the appearance and the tx power. Take a look at the code and, if it can help you, add it to your repo. Here is a little example to try the new feature:

include

BLEPeripheral blePeripheral = BLEPeripheral();

BLEService serviceOne = BLEService("19b10001e8f2537e4f6cd104768a1214"); BLEService serviceTwo = BLEService("aaaa"); BLEService serviceThree = BLEService("bbbb");

void setup() { blePeripheral.setLocalName("AdvTest"); blePeripheral.setAdvertisedServiceUuid(serviceOne.uuid()); blePeripheral.setAdvertisedServiceUuid(serviceTwo.uuid()); blePeripheral.setAdvertisedServiceUuid(serviceThree.uuid()); blePeripheral.setAppearance(BLE_APPEARANCE_GENERIC_COMPUTER); blePeripheral.setTxPower(-40); blePeripheral.begin(); }

void loop() {}

Please notice that I tested this feature only with the nRF52 microcontroller. Regards, Chiara

urish commented 7 years ago

I would also love to see this supported (advertising multiple services). Is there anything I can do to help make this feature a reality ?

sandeepmistry commented 7 years ago

I'm going this PR for now, as the following issues exist:

1) It reverts some changes 2) The Travis CI build is failing 3) setAdvertisedServiceUuid is unclear now because it actually adds not sets (this is a breaking change IMO) 4) There is no nRF8001 board support.