This project contains two type of beacons: Eddystone and iBeacon.
Dependencies: microbit-iBeacon
Fork of BTW_ComboBeacon_Solution by
main.cpp@18:eeea3e01140c, 2018-08-01 (annotated)
- Committer:
- krenbluetoothsig
- Date:
- Wed Aug 01 14:02:32 2018 +0000
- Revision:
- 18:eeea3e01140c
- Parent:
- 17:6715daf92c78
- Child:
- 19:8c3dd0a6a0a1
1. NEW: main.cpp as the template, beacon_src.txt includes code snippet.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
krenbluetoothsig | 17:6715daf92c78 | 1 | #include "MicroBit.h" |
krenbluetoothsig | 17:6715daf92c78 | 2 | |
krenbluetoothsig | 17:6715daf92c78 | 3 | /****************************************************** |
krenbluetoothsig | 17:6715daf92c78 | 4 | * Macros |
krenbluetoothsig | 17:6715daf92c78 | 5 | ******************************************************/ |
krenbluetoothsig | 17:6715daf92c78 | 6 | // TODO: add ADV on and off flag |
krenbluetoothsig | 18:eeea3e01140c | 7 | |
krenbluetoothsig | 17:6715daf92c78 | 8 | |
krenbluetoothsig | 17:6715daf92c78 | 9 | /****************************************************** |
krenbluetoothsig | 17:6715daf92c78 | 10 | * Constants |
krenbluetoothsig | 17:6715daf92c78 | 11 | ******************************************************/ |
krenbluetoothsig | 17:6715daf92c78 | 12 | // TODO: constants, used for iBeacon UUID(MSB first), Major, Minor and txpower setting |
krenbluetoothsig | 17:6715daf92c78 | 13 | |
krenbluetoothsig | 17:6715daf92c78 | 14 | |
krenbluetoothsig | 17:6715daf92c78 | 15 | /****************************************************** |
krenbluetoothsig | 17:6715daf92c78 | 16 | * Variables |
krenbluetoothsig | 17:6715daf92c78 | 17 | ******************************************************/ |
krenbluetoothsig | 17:6715daf92c78 | 18 | //microbit object |
krenbluetoothsig | 17:6715daf92c78 | 19 | MicroBit uBit; |
krenbluetoothsig | 17:6715daf92c78 | 20 | //Initial USB-to-Serial, baud rate is 9600-8-N-1 |
krenbluetoothsig | 17:6715daf92c78 | 21 | Serial pcCom(USBTX, USBRX); |
krenbluetoothsig | 17:6715daf92c78 | 22 | |
krenbluetoothsig | 17:6715daf92c78 | 23 | // TODO: global data and functions |
krenbluetoothsig | 17:6715daf92c78 | 24 | |
krenbluetoothsig | 17:6715daf92c78 | 25 | |
krenbluetoothsig | 17:6715daf92c78 | 26 | |
krenbluetoothsig | 17:6715daf92c78 | 27 | /****************************************************** |
krenbluetoothsig | 17:6715daf92c78 | 28 | * Functions |
krenbluetoothsig | 17:6715daf92c78 | 29 | ******************************************************/ |
krenbluetoothsig | 17:6715daf92c78 | 30 | // TODO: functions, startAdvertising and stopAdvertising |
krenbluetoothsig | 17:6715daf92c78 | 31 | |
krenbluetoothsig | 17:6715daf92c78 | 32 | |
krenbluetoothsig | 17:6715daf92c78 | 33 | // TODO: functions, used for ButtonA and ButtonB interrupt callbacks |
krenbluetoothsig | 17:6715daf92c78 | 34 | |
krenbluetoothsig | 17:6715daf92c78 | 35 | |
krenbluetoothsig | 17:6715daf92c78 | 36 | int main() |
krenbluetoothsig | 17:6715daf92c78 | 37 | { |
krenbluetoothsig | 17:6715daf92c78 | 38 | // Serial output after a reset |
krenbluetoothsig | 17:6715daf92c78 | 39 | pcCom.printf("mBit Beacon.\n\r"); |
krenbluetoothsig | 17:6715daf92c78 | 40 | |
krenbluetoothsig | 17:6715daf92c78 | 41 | // Initialize the micro:bit runtime. |
krenbluetoothsig | 17:6715daf92c78 | 42 | uBit.init(); |
krenbluetoothsig | 17:6715daf92c78 | 43 | |
krenbluetoothsig | 17:6715daf92c78 | 44 | // TODO: Register the interrupt and callback for ButtonA and ButtonB |
krenbluetoothsig | 18:eeea3e01140c | 45 | |
krenbluetoothsig | 17:6715daf92c78 | 46 | |
krenbluetoothsig | 17:6715daf92c78 | 47 | //TODO: First Advertisment, adv name only |
krenbluetoothsig | 18:eeea3e01140c | 48 | |
krenbluetoothsig | 17:6715daf92c78 | 49 | |
krenbluetoothsig | 17:6715daf92c78 | 50 | release_fiber(); |
krenbluetoothsig | 17:6715daf92c78 | 51 | } |