Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API mbed nRF51822
Fork of BLE_BatteryLevel by
main.cpp
- Committer:
- sam_grove
- Date:
- 2014-01-09
- Revision:
- 2:a872df2e051e
- Parent:
- 1:54fe327e5d0a
- Child:
- 3:288b2baffd14
File content as of revision 2:a872df2e051e:
#include "mbed.h"
#include "UUID.h"
#include "nRF51822.h"
/* Radio HW */
nRF51822 radio(p9, p10, p30, p29); // tx, rx, rts, cts
int main(void)
{
GattService battService ( 0x180F );
GattCharacteristic battLevel ( 0x2A19, 1, 1, BLE_GATT_CHAR_PROPERTIES_NOTIFY | BLE_GATT_CHAR_PROPERTIES_READ);
/* Make sure we get a clean start */
radio.reset();
/* Add the characteristic to our service */
battService.addCharacteristic(battLevel);
/* Pass the service into the radio */
radio.addService(battService);
/* Configure the radio and start advertising with default values */
/* Make sure you've added all of your services before calling this function! */
radio.start();
/* Now that we're live, update the battery level characteristic */
uint8_t batt = 72;
radio.writeCharacteristic(battLevel.handle, (uint8_t*)&batt, sizeof(batt));
while(1);
}
