Run on TY51822r3 board with ACC sensor (LIS3DH or BMC050)

Dependencies:   BLE_API LIS3DH mbed nRF51822 BMC050 nRF51_LowPwr nRF51_Vdd

Fork of BLE_EddystoneBeacon_Service by Bluetooth Low Energy

Revision:
32:41840b78597e
Parent:
31:bdd03742096a
Child:
33:862e6e0831ea
--- a/main.cpp	Tue Aug 11 18:13:46 2015 +0000
+++ b/main.cpp	Thu Oct 01 16:28:22 2015 +0000
@@ -1,5 +1,5 @@
 /* mbed Microcontroller Library
- * Copyright (c) 2006-2015 ARM Limited
+ * Copyright (c) 2006-2013 ARM Limited
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,15 +15,18 @@
  */
 
 #include "mbed.h"
-#include "ble/BLE.h"
+#include "BLE.h"
 #include "ble/services/EddystoneService.h"
 
 BLE ble;
 uint8_t UIDnamespace[] = {0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xAA}; // 10Bytes for Namespace UUID
 uint8_t UIDinstance[]  = {0xbb,0xcc,0xdd,0xee,0xff,0x00}; // 6Bytes for Instance UUID
 char Url[] = "http://www.mbed.org";
-int8_t txPower = -40;
+int8_t radioTxPower = 20;
+int8_t advTxPower = -20;
 uint16_t beaconPeriodus = 1000;
+uint8_t tlmVersion = 0x00;
+
 
 //Callbacks for temperature / battery updates
 Ticker tlmBattery;
@@ -31,24 +34,36 @@
 int battery = 0;
 int temp = 0;
 
-// Add Eddystone service to BLE device, can pass NULL for UID and URL parameters to disable those frames
-EddystoneService eddyBeacon(ble, beaconPeriodus, txPower ,UIDnamespace, UIDinstance, Url, sizeof(Url));
+// Setup Eddystone Service 
+EddystoneService eddyBeacon(ble,beaconPeriodus,radioTxPower);
 
-// Optional Function to update Eddystone beacon TLM frame battery voltage
+
+// Function to update beacon battery voltage
 void tlmBatteryCallback(void){
     eddyBeacon.updateTlmBatteryVoltage(battery++);
 }
 
-// Optional Function to update Eddystone beacon TLM frame temperature
+// Function to update Beacon Temperature
 void tlmTemperatureCallback(void){
     eddyBeacon.updateTlmBeaconTemp(temp++);
 }
 
 int main(void)
 {
-    printf("Starting Example\r\n");
+    printf("Starting Example\r\n"); // To enable low power mode disable all printf's
+
+    // Set Eddystone Frame Data (TLM,UID,URI...etc)
+    eddyBeacon.setTLMFrameData(tlmVersion,5.0);
+    eddyBeacon.setURLFrameData(advTxPower, Url, 2.0);
+    eddyBeacon.setUIDFrameData(advTxPower, UIDnamespace, UIDinstance, 3.0);
+    
+    // Attach functions to modify TLM data
     tlmTemperature.attach(tlmTemperatureCallback,2.0f);
     tlmBattery.attach(tlmBatteryCallback, 1.0f);
+
+    // Start Advertising the eddystone service. 
+    eddyBeacon.start(); 
+    
     printf("Running...\r\n");
     while (true) {
         ble.waitForEvent();