Jonas Gartmann
/
Heap_Test
Test program to fill up the heap
Fork of BLE_BatteryLevel by
main.cpp@0:395932faedf1, 2014-01-09 (annotated)
- Committer:
- ktownsend
- Date:
- Thu Jan 09 10:53:09 2014 +0000
- Revision:
- 0:395932faedf1
- Child:
- 1:54fe327e5d0a
First commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ktownsend | 0:395932faedf1 | 1 | #include "mbed.h" |
ktownsend | 0:395932faedf1 | 2 | #include "uuid.h" |
ktownsend | 0:395932faedf1 | 3 | #include "hw/nrf51822.h" |
ktownsend | 0:395932faedf1 | 4 | |
ktownsend | 0:395932faedf1 | 5 | /* Radio HW */ |
ktownsend | 0:395932faedf1 | 6 | nRF51822 radio; |
ktownsend | 0:395932faedf1 | 7 | |
ktownsend | 0:395932faedf1 | 8 | int main(void) |
ktownsend | 0:395932faedf1 | 9 | { |
ktownsend | 0:395932faedf1 | 10 | GattService battService ( 0x180F ); |
ktownsend | 0:395932faedf1 | 11 | GattCharacteristic battLevel ( 0x2A19, 1, 1, BLE_GATT_CHAR_PROPERTIES_NOTIFY | BLE_GATT_CHAR_PROPERTIES_READ); |
ktownsend | 0:395932faedf1 | 12 | |
ktownsend | 0:395932faedf1 | 13 | /* Make sure we get a clean start */ |
ktownsend | 0:395932faedf1 | 14 | radio.reset(); |
ktownsend | 0:395932faedf1 | 15 | |
ktownsend | 0:395932faedf1 | 16 | /* Add the characteristic to our service */ |
ktownsend | 0:395932faedf1 | 17 | battService.addCharacteristic(battLevel); |
ktownsend | 0:395932faedf1 | 18 | |
ktownsend | 0:395932faedf1 | 19 | /* Pass the service into the radio */ |
ktownsend | 0:395932faedf1 | 20 | radio.addService(battService); |
ktownsend | 0:395932faedf1 | 21 | |
ktownsend | 0:395932faedf1 | 22 | /* Configure the radio and start advertising with default values */ |
ktownsend | 0:395932faedf1 | 23 | /* Make sure you've added all of your services before calling this function! */ |
ktownsend | 0:395932faedf1 | 24 | radio.start(); |
ktownsend | 0:395932faedf1 | 25 | |
ktownsend | 0:395932faedf1 | 26 | /* Now that we're live, update the battery level characteristic */ |
ktownsend | 0:395932faedf1 | 27 | uint8_t batt = 72; |
ktownsend | 0:395932faedf1 | 28 | radio.writeCharacteristic(battLevel.handle, (uint8_t*)&batt, sizeof(batt)); |
ktownsend | 0:395932faedf1 | 29 | |
ktownsend | 0:395932faedf1 | 30 | while(1); |
ktownsend | 0:395932faedf1 | 31 | } |