To Be Deploy
Dependencies: BLE_API mbed nRF51822 X_NUCLEO_IDB0XA1
Fork of BLE_EddystoneBeacon_Serviceprod by
main.cpp@31:bdd03742096a, 2015-08-11 (annotated)
- Committer:
- mbedAustin
- Date:
- Tue Aug 11 18:13:46 2015 +0000
- Revision:
- 31:bdd03742096a
- Parent:
- 30:6c2db8bf5b17
- Child:
- 32:41840b78597e
cleaned up code prior to public release.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
screamer | 0:c04d932e96c9 | 1 | /* mbed Microcontroller Library |
mbedAustin | 31:bdd03742096a | 2 | * Copyright (c) 2006-2015 ARM Limited |
screamer | 0:c04d932e96c9 | 3 | * |
screamer | 0:c04d932e96c9 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
screamer | 0:c04d932e96c9 | 5 | * you may not use this file except in compliance with the License. |
screamer | 0:c04d932e96c9 | 6 | * You may obtain a copy of the License at |
screamer | 0:c04d932e96c9 | 7 | * |
screamer | 0:c04d932e96c9 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
screamer | 0:c04d932e96c9 | 9 | * |
screamer | 0:c04d932e96c9 | 10 | * Unless required by applicable law or agreed to in writing, software |
screamer | 0:c04d932e96c9 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
screamer | 0:c04d932e96c9 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
screamer | 0:c04d932e96c9 | 13 | * See the License for the specific language governing permissions and |
screamer | 0:c04d932e96c9 | 14 | * limitations under the License. |
screamer | 0:c04d932e96c9 | 15 | */ |
screamer | 0:c04d932e96c9 | 16 | |
screamer | 0:c04d932e96c9 | 17 | #include "mbed.h" |
mbedAustin | 31:bdd03742096a | 18 | #include "ble/BLE.h" |
mbedAustin | 31:bdd03742096a | 19 | #include "ble/services/EddystoneService.h" |
screamer | 0:c04d932e96c9 | 20 | |
rgrover1 | 8:1a21308e5008 | 21 | BLE ble; |
mbedAustin | 26:2896fbdd0450 | 22 | uint8_t UIDnamespace[] = {0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xAA}; // 10Bytes for Namespace UUID |
mbedAustin | 26:2896fbdd0450 | 23 | uint8_t UIDinstance[] = {0xbb,0xcc,0xdd,0xee,0xff,0x00}; // 6Bytes for Instance UUID |
mbedAustin | 30:6c2db8bf5b17 | 24 | char Url[] = "http://www.mbed.org"; |
mbedAustin | 31:bdd03742096a | 25 | int8_t txPower = -40; |
mbedAustin | 30:6c2db8bf5b17 | 26 | uint16_t beaconPeriodus = 1000; |
mbedAustin | 30:6c2db8bf5b17 | 27 | |
mbedAustin | 30:6c2db8bf5b17 | 28 | //Callbacks for temperature / battery updates |
mbedAustin | 30:6c2db8bf5b17 | 29 | Ticker tlmBattery; |
mbedAustin | 30:6c2db8bf5b17 | 30 | Ticker tlmTemperature; |
mbedAustin | 30:6c2db8bf5b17 | 31 | int battery = 0; |
mbedAustin | 30:6c2db8bf5b17 | 32 | int temp = 0; |
mbedAustin | 30:6c2db8bf5b17 | 33 | |
mbedAustin | 31:bdd03742096a | 34 | // Add Eddystone service to BLE device, can pass NULL for UID and URL parameters to disable those frames |
mbedAustin | 30:6c2db8bf5b17 | 35 | EddystoneService eddyBeacon(ble, beaconPeriodus, txPower ,UIDnamespace, UIDinstance, Url, sizeof(Url)); |
mbedAustin | 30:6c2db8bf5b17 | 36 | |
mbedAustin | 31:bdd03742096a | 37 | // Optional Function to update Eddystone beacon TLM frame battery voltage |
mbedAustin | 30:6c2db8bf5b17 | 38 | void tlmBatteryCallback(void){ |
mbedAustin | 30:6c2db8bf5b17 | 39 | eddyBeacon.updateTlmBatteryVoltage(battery++); |
mbedAustin | 30:6c2db8bf5b17 | 40 | } |
mbedAustin | 30:6c2db8bf5b17 | 41 | |
mbedAustin | 31:bdd03742096a | 42 | // Optional Function to update Eddystone beacon TLM frame temperature |
mbedAustin | 30:6c2db8bf5b17 | 43 | void tlmTemperatureCallback(void){ |
mbedAustin | 30:6c2db8bf5b17 | 44 | eddyBeacon.updateTlmBeaconTemp(temp++); |
mbedAustin | 30:6c2db8bf5b17 | 45 | } |
screamer | 0:c04d932e96c9 | 46 | |
screamer | 0:c04d932e96c9 | 47 | int main(void) |
screamer | 0:c04d932e96c9 | 48 | { |
mbedAustin | 15:af8c24f34a9f | 49 | printf("Starting Example\r\n"); |
mbedAustin | 30:6c2db8bf5b17 | 50 | tlmTemperature.attach(tlmTemperatureCallback,2.0f); |
mbedAustin | 30:6c2db8bf5b17 | 51 | tlmBattery.attach(tlmBatteryCallback, 1.0f); |
mbedAustin | 15:af8c24f34a9f | 52 | printf("Running...\r\n"); |
screamer | 0:c04d932e96c9 | 53 | while (true) { |
screamer | 0:c04d932e96c9 | 54 | ble.waitForEvent(); |
screamer | 0:c04d932e96c9 | 55 | } |
screamer | 0:c04d932e96c9 | 56 | } |