Kenji Arai / Mbed 2 deprecated BLE_EddystoneBeacon_w_ACC_TY51822

Dependencies:   BLE_API LIS3DH mbed nRF51822 BMC050 nRF51_LowPwr nRF51_Vdd

Fork of BLE_EddystoneBeacon_Service by Bluetooth Low Energy

Files at this revision

API Documentation at this revision

Comitter:
mbedAustin
Date:
Fri Jul 24 03:12:21 2015 +0000
Parent:
27:29c6d1bb462e
Child:
29:dfb7fb5a971b
Commit message:
[[FIX]] fixed build issue, now compiling, though not running correctly.

Changed in this revision

Eddystone.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Eddystone.h	Fri Jul 24 03:00:57 2015 +0000
+++ b/Eddystone.h	Fri Jul 24 03:12:21 2015 +0000
@@ -23,7 +23,7 @@
 static const uint8_t BEACON_EDDYSTONE[] = {0xAA, 0xFE};
 
 //Debug is disabled by default
-#if 0
+#if 1
 #define DBG(x, ...)  printf("[EddyStone: DBG]"x" \t[%s,%d]\r\n", ##__VA_ARGS__,__FILE__,__LINE__);
 #define WARN(x, ...) printf("[EddyStone: WARN]"x" \t[%s,%d]\r\n", ##__VA_ARGS__,__FILE__,__LINE__);
 #define ERR(x, ...)  printf("[EddyStone: ERR]"x" \t[%s,%d]\r\n", ##__VA_ARGS__,__FILE__,__LINE__);
@@ -39,24 +39,16 @@
 * See https://github.com/google/eddystone
 *
 */
-class Eddystone
+class EddystoneService
 {
 public:
     /**
      * @brief Transmission Power Modes for UriBeacon
      */
-    static const uint8_t TX_POWER_MODE_LOWEST = 0; /*!< Lowest TX power mode */
-    static const uint8_t TX_POWER_MODE_LOW    = 1; /*!< Low TX power mode */
-    static const uint8_t TX_POWER_MODE_MEDIUM = 2; /*!< Medium TX power mode */
-    static const uint8_t TX_POWER_MODE_HIGH   = 3; /*!< High TX power mode */
-    static const unsigned int NUM_POWER_MODES = 4; /*!< Number of Power Modes defined */
 
     static const int ADVERTISING_INTERVAL_MSEC = 1000;  // Advertising interval for config service.
     static const int SERVICE_DATA_MAX = 31;             // Maximum size of service data in ADV packets
 
-    typedef uint8_t Lock_t[16];               /* 128 bits */
-    typedef int8_t PowerLevels_t[NUM_POWER_MODES];
-
     // There are currently 3 subframes defined, URI, UID, and TLM
 #define EDDYSTONE_MAX_FRAMETYPE 3
     void (*frames[EDDYSTONE_MAX_FRAMETYPE])(uint8_t *, uint32_t);
@@ -78,22 +70,6 @@
     static const uint8_t FRAME_SIZE_TLM = 14; // TLM frame is a constant 14Bytes
     static const uint8_t FRAME_SIZE_UID = 20; // includes RFU bytes
 
-    struct Params_t {
-        Lock_t        lock;
-        uint8_t       uriDataLength;
-        UriData_t     uriData;
-        uint8_t       flags;
-        PowerLevels_t advPowerLevels; // Current value of AdvertisedPowerLevels
-        uint8_t       txPowerMode;    // Firmware power levels used with setTxPower()
-        uint16_t      beaconPeriod;
-        uint8_t       tlmVersion;     // version of TLM packet
-        UIDNamespaceID_t uidNamespaceID; // UUID type, Namespace ID, 10B
-        UIDInstanceID_t  uidInstanceID;  // UUID type, Instance ID,  6B
-        int(*tlmGetBatt(void)); // Function Pointers for user provided functions that return the Temp and Battery Voltage data for the TLM field.
-        int(*tlmGetTemp(void)); // ^^
-    };
-
-
     /*
     *  Set Eddystone UID Frame information.
     *  @param[in] power   TX Power in dB measured at 0 meters from the device. Range of -100 to +20 dB.
@@ -352,13 +328,13 @@
             // state machine to control which packet is being sent
             switch(frameIndex) {
                 case 0: // TLM Frame
-                    switchFrame.attach_us(this, &Eddystone::swapOutFrames, EDDYSTONE_SWAPFRAME_DELAYMS);
+                    switchFrame.attach_us(this, &EddystoneService::swapOutFrames, EDDYSTONE_SWAPFRAME_DELAYMS);
                     switchFlag = true;
                     break;
                 case 1: // URL Frame
                     // switch out packets
                     if(switchFlag) {
-                        switchFrame.attach_us(this, &Eddystone::swapOutFrames, EDDYSTONE_SWAPFRAME_DELAYMS);
+                        switchFrame.attach_us(this, &EddystoneService::swapOutFrames, EDDYSTONE_SWAPFRAME_DELAYMS);
                         switchFlag = false;
                     } else {
                         if((TlmPduCount % 10) == 0) { // every 10 adv packets switch the frame
@@ -369,7 +345,7 @@
                 case 2: // UIDFrame
                     // switch out packets
                     if(switchFlag ) {
-                        switchFrame.attach_us(this, &Eddystone::swapOutFrames, EDDYSTONE_SWAPFRAME_DELAYMS);
+                        switchFrame.attach_us(this, &EddystoneService::swapOutFrames, EDDYSTONE_SWAPFRAME_DELAYMS);
                         switchFlag = false;
                     } else {
                         if((TlmPduCount % 10) == 0) { // every 10 adv packets switch the frame
@@ -397,7 +373,7 @@
     *   @param tlmVersion version of telemetry data field to use (default to 0x00)
     *
     */
-    Eddystone(BLEDevice       &bleIn,
+    EddystoneService(BLEDevice       &bleIn,
               uint16_t        beaconPeriodus = 100,
               uint8_t         txPowerLevel = 0,
               uint8_t *       uidNamespaceID = NULL,
@@ -449,8 +425,8 @@
 
         updateAdvPacket(serviceData, serviceDataLen);
         ble.gap().startAdvertising();
-        ble.gap().onRadioNotification(this,&Eddystone::radioNotificationCallback);
-        timeSinceBootTick.attach(this,&Eddystone::tsbCallback,0.1); // incriment the TimeSinceBoot ticker every 0.1s
+        ble.gap().onRadioNotification(this,&EddystoneService::radioNotificationCallback);
+        timeSinceBootTick.attach(this,&EddystoneService::tsbCallback,0.1); // incriment the TimeSinceBoot ticker every 0.1s
 
     }
 
@@ -458,7 +434,6 @@
 
 
     BLEDevice           &ble;
-    Params_t            &params;
     Ticker              timeSinceBootTick;
     Timeout             switchFrame;
 // Default value that is restored on reset
@@ -471,11 +446,6 @@
     uint16_t            uidRFU;
     bool                uidIsSet;
     bool                urlIsSet;
-// Default value that is restored on reset
-    PowerLevels_t       &defaultAdvPowerLevels;
-    uint8_t             lockedState;
-    bool                initSucceeded;
-    uint8_t             resetFlag;
     bool switchFlag;
 
 // Private Variables for Telemetry Data
--- a/main.cpp	Fri Jul 24 03:00:57 2015 +0000
+++ b/main.cpp	Fri Jul 24 03:12:21 2015 +0000
@@ -26,7 +26,7 @@
 int main(void)
 {
     printf("Starting Example\r\n");
-    Eddystone eddyBeacon(ble, 100, 10,UIDnamespace, UIDinstance, Url, sizeof(Url));
+    EddystoneService eddyBeacon(ble, 100, 10,UIDnamespace, UIDinstance, Url, sizeof(Url));
     printf("Running...\r\n");
     while (true) {
         ble.waitForEvent();