Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 11 months ago.
Are there some examples about creating 128bit uuid service?
Hi, all I'm sorry to ask such a simple question, i wanna create a 128bit-uuid service, my code doesn't work. Here is my code:
- include "mbed.h"
- include "blecommon.h"
- include "hw/nRF51822s/nRF51822s.h"
DigitalOut led(P1_5); nRF51822s nrf ( P0_19, P0_18, P1_26, P1_27); /* (tx, rx, rts, cts) */ GattService battService ( 0x180F ); GattCharacteristic battLevel ( 0x2A19, 1, 1, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ);
uint8_t my_base_uuid[16] = {0,1,0,0,4,5,6,7,8,9,0,0,0,0,4,5}; UUID custom_uuid(my_base_uuid);
GattService myService(my_base_uuid);
int main(void) { led = 0; /* Make sure we get a clean start */ nrf.reset();
/* Add the characteristic to our service */ battService.addCharacteristic(battLevel); myService.addCharacteristic(battLevel);
/* Pass the service into the radio */ nrf.getGattServer().addService(battService);
nrf.getGattServer().addService(myService);
if(myService.primaryServiceID.type) { led = 1; } /* Configure the radio and start advertising with default values */ /* Make sure you've added all of your services before calling this function! */ nrf.getGap().startAdvertising();
/* Now that we're live, update the battery level characteristic */ uint8_t batt = 72; nrf.getGattServer().updateValue(battLevel.handle, (uint8_t*)&batt, sizeof(batt));
while(1); }
Best Regards YutingYou
Question relating to:
![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
1 Answer
10 years, 11 months ago.
Hi,
These examples are based around an early serialisation version of the API that talks over UART (ergo the 's' in nRF51822s), whereas the current API we are just finalizing is purely native, and is much more feature complete. If you can wait a week or two, the final API will be made available for testers and feedback running purely in native mode, and this should solve some of the limitations in the currently published code.