Software can read HMC5883L

Dependents:   DOOR_BLE_PROGRAM

Fork of BLE_API by Bluetooth Low Energy

Files at this revision

API Documentation at this revision

Comitter:
rgrover1
Date:
Mon Nov 02 09:09:05 2015 +0000
Parent:
849:0f5972e454b2
Child:
851:802f445cc195
Commit message:
Synchronized with git rev 8aaa385e
Author: Johnny Robeson
use the github url public url in module.json

Changed in this revision

ble/BLE.h Show annotated file Show diff for this revision Revisions of this file
ble/BLEInstanceBase.h Show annotated file Show diff for this revision Revisions of this file
ble/FunctionPointerWithContext.h Show annotated file Show diff for this revision Revisions of this file
ble/UUID.h Show annotated file Show diff for this revision Revisions of this file
ble/services/EddystoneConfigService.h Show annotated file Show diff for this revision Revisions of this file
ble/services/EddystoneService.h Show annotated file Show diff for this revision Revisions of this file
ble/services/LinkLossService.h Show annotated file Show diff for this revision Revisions of this file
ble/services/UARTService.h Show annotated file Show diff for this revision Revisions of this file
ble/services/URIBeaconConfigService.h Show annotated file Show diff for this revision Revisions of this file
module.json Show annotated file Show diff for this revision Revisions of this file
--- a/ble/BLE.h	Mon Nov 02 09:09:05 2015 +0000
+++ b/ble/BLE.h	Mon Nov 02 09:09:05 2015 +0000
@@ -23,11 +23,7 @@
 #include "GattClient.h"
 #include "BLEInstanceBase.h"
 
-#ifdef YOTTA_CFG_MBED_OS
-#include "mbed-drivers/mbed_error.h"
-#else
 #include "mbed_error.h"
-#endif
 
 /**
  * The base class used to abstract away BLE capable radio transceivers or SOCs,
--- a/ble/BLEInstanceBase.h	Mon Nov 02 09:09:05 2015 +0000
+++ b/ble/BLEInstanceBase.h	Mon Nov 02 09:09:05 2015 +0000
@@ -18,7 +18,6 @@
 #define __BLE_DEVICE_INSTANCE_BASE__
 
 #include "Gap.h"
-#include "ble/SecurityManager.h"
 
 /* forward declarations */
 class GattServer;
--- a/ble/FunctionPointerWithContext.h	Mon Nov 02 09:09:05 2015 +0000
+++ b/ble/FunctionPointerWithContext.h	Mon Nov 02 09:09:05 2015 +0000
@@ -20,7 +20,6 @@
 #include <string.h>
 
 
-
 /** A class for storing and calling a pointer to a static or member void function
  *  which takes a context.
  */
@@ -35,7 +34,7 @@
      *  @param function The void static function to attach (default is none)
      */
     FunctionPointerWithContext(void (*function)(ContextType context) = NULL) :
-        _function(NULL), _caller(NULL), _next(NULL) {
+        _function(NULL), _object(NULL), _member(), _membercaller(NULL), _next(NULL) {
         attach(function);
     }
 
@@ -46,7 +45,7 @@
      */
     template<typename T>
     FunctionPointerWithContext(T *object, void (T::*member)(ContextType context)) :
-        _memberFunctionAndPointer(), _caller(NULL), _next(NULL) {
+        _function(NULL), _object(NULL), _member(), _membercaller(NULL), _next(NULL) {
         attach(object, member);
     }
 
@@ -56,7 +55,6 @@
      */
     void attach(void (*function)(ContextType context) = NULL) {
         _function = function;
-        _caller = functioncaller;
     }
 
     /** Attach a member function
@@ -66,9 +64,9 @@
      */
     template<typename T>
     void attach(T *object, void (T::*member)(ContextType context)) {
-        _memberFunctionAndPointer._object = static_cast<void *>(object);
-        memcpy(_memberFunctionAndPointer._memberFunction, (char*) &member, sizeof(member));
-        _caller = &FunctionPointerWithContext::membercaller<T>;
+        _object = static_cast<void *>(object);
+        memcpy(_member, (char *)&member, sizeof(member));
+        _membercaller = &FunctionPointerWithContext::membercaller<T>;
     }
 
     /** Call the attached static or member function; and if there are chained
@@ -76,7 +74,11 @@
      *  @Note: all chained callbacks stack up; so hopefully there won't be too
      *  many FunctionPointers in a chain. */
     void call(ContextType context) {
-        _caller(this, context);
+        if (_function) {
+            _function(context);
+        } else if (_object && _membercaller) {
+            _membercaller(_object, _member, context);
+        }
 
         /* Propagate the call to next in the chain. */
         if (_next) {
@@ -105,49 +107,19 @@
 
 private:
     template<typename T>
-    static void membercaller(FunctionPointerWithContext* self, ContextType context) {
-        if(self->_memberFunctionAndPointer._object) {
-            T *o = static_cast<T *>(self->_memberFunctionAndPointer._object);        
-            void (T::*m)(ContextType);
-            memcpy((char*) &m, self->_memberFunctionAndPointer._memberFunction, sizeof(m));
-            (o->*m)(context);            
-        }
-    }
-
-    static void functioncaller(FunctionPointerWithContext* self, ContextType context) {
-        if(self->_function) {
-            self->_function(context);
-        }
+    static void membercaller(void *object, char *member, ContextType context) {
+        T *o = static_cast<T *>(object);
+        void (T::*m)(ContextType);
+        memcpy((char *)&m, member, sizeof(m));
+        (o->*m)(context);
     }
 
-    struct MemberFunctionAndPtr {
-        /*
-         * forward declaration of a class and a member function to this class. 
-         * Because the compiler doesnt know anything about the member function, it 
-         * will always take the biggest size that a member function can take.
-         * This also guarantee that the proper alignement will be chosen 
-         */
-        class UndefinedClass;
-        typedef void (UndefinedClass::*UndefinedMemberFunction)(ContextType);
-
-        void* _object;
-        union {
-            char _memberFunction[sizeof(UndefinedMemberFunction)];
-            UndefinedMemberFunction _allignement;            
-        };
-    };
-
-    union {
-        void (*_function)(ContextType context);             /**< static function pointer - NULL if none attached */        
-        /** 
-         * object this pointer and pointer to member - 
-         * _memberFunctionAndPointer._object will be NULL if none attached 
-         */        
-        MemberFunctionAndPtr _memberFunctionAndPointer;      
-    };
-
-    void (*_caller)(FunctionPointerWithContext*, ContextType);
-
+    void (*_function)(ContextType context);             /**< static function pointer - NULL if none attached */
+    void *_object;                                      /**< object this pointer - NULL if none attached */
+    char _member[16];                                   /**< raw member function pointer storage - converted back by
+                                                         *   registered _membercaller */
+    void (*_membercaller)(void *, char *, ContextType); /**< registered membercaller function to convert back and call
+                                                         *   _member on _object passing the context. */
     pFunctionPointerWithContext_t _next;                /**< Optional link to make a chain out of functionPointers; this
                                                          *   allows chaining function pointers without requiring
                                                          *   external memory to manage the chain. Also refer to
--- a/ble/UUID.h	Mon Nov 02 09:09:05 2015 +0000
+++ b/ble/UUID.h	Mon Nov 02 09:09:05 2015 +0000
@@ -74,7 +74,7 @@
      *
      * @note we don't yet support 32-bit shortened UUIDs.
      */
-    UUID(ShortUUIDBytes_t _shortUUID) : type(UUID_TYPE_SHORT), baseUUID(), shortUUID(_shortUUID) {
+    UUID(ShortUUIDBytes_t shortUUID) : type(UUID_TYPE_SHORT), baseUUID(), shortUUID(shortUUID) {
         /* empty */
     }
 
--- a/ble/services/EddystoneConfigService.h	Mon Nov 02 09:09:05 2015 +0000
+++ b/ble/services/EddystoneConfigService.h	Mon Nov 02 09:09:05 2015 +0000
@@ -306,7 +306,7 @@
             eddyServ.setTLMFrameData(params.tlmVersion, params.tlmBeaconPeriod);
         }
         if (params.uriEnabled) {
-            eddyServ.setURLFrameEncodedData(params.advPowerLevels[params.txPowerMode], (const char *) params.uriData, params.uriDataLength, params.uriBeaconPeriod);
+            eddyServ.setURLFrameData(params.advPowerLevels[params.txPowerMode], (const char *) params.uriData, params.uriBeaconPeriod);
         }
         if (params.uidEnabled) {
             eddyServ.setUIDFrameData(params.advPowerLevels[params.txPowerMode],
--- a/ble/services/EddystoneService.h	Mon Nov 02 09:09:05 2015 +0000
+++ b/ble/services/EddystoneService.h	Mon Nov 02 09:09:05 2015 +0000
@@ -175,40 +175,16 @@
             urlIsSet = false;
             return false;
         }
+        defaultUrlPower = power;
         encodeURL(urlIn, defaultUriData, defaultUriDataLength); // encode URL to URL Formatting
         if (defaultUriDataLength > URI_DATA_MAX) {
             return true;                                        // error, URL is too big
         }
-        defaultUrlPower = power;
         urlAdvPeriod = urlAdvPeriodIn;
         urlIsSet     = true;
         return false;
     }
 
-    /**
-     *  Set Eddystone URL Frame information.
-     *  @param[in] power              TX Power in dB measured at 0 meters from the device.
-     *  @param[in] encodedUrlIn       Encoded URL
-     *  @param[in] encodedUrlInLength Length of the encoded URL
-     *  @param[in] urlAdvPeriodIn     How long to advertise the URL frame (measured in # of adv periods)
-     *  @return false on success, true on failure.
-     */
-    bool setURLFrameEncodedData(int8_t power, const char *encodedUrlIn, uint8_t encodedUrlInLength, uint32_t urlAdvPeriodIn) {
-        if (0 == urlAdvPeriodIn) {
-            urlIsSet = false;
-            return false;
-        }
-        memcpy(defaultUriData, encodedUrlIn, encodedUrlInLength);
-        if (defaultUriDataLength > URI_DATA_MAX) {
-            return true;                                        // error, URL is too big
-        }
-        defaultUrlPower      = power;
-        defaultUriDataLength = encodedUrlInLength;
-        urlAdvPeriod         = urlAdvPeriodIn;
-        urlIsSet             = true;
-        return false;
-    }
-
     /*
     *  Construct URL frame from private variables
     *  @param[in/out] Data pointer to array to store constructed frame in
--- a/ble/services/LinkLossService.h	Mon Nov 02 09:09:05 2015 +0000
+++ b/ble/services/LinkLossService.h	Mon Nov 02 09:09:05 2015 +0000
@@ -55,7 +55,7 @@
         ble.addService(linkLossService);
         serviceAdded = true;
 
-        ble.onDisconnection(this, &LinkLossService::onDisconnectionFilter);
+        ble.addToDisconnectionCallChain(this, &LinkLossService::onDisconnectionFilter);
         ble.onDataWritten(this, &LinkLossService::onDataWritten);
     }
 
@@ -86,7 +86,7 @@
         }
     }
 
-    void onDisconnectionFilter(const Gap::DisconnectionCallbackParams_t *params) {
+    void onDisconnectionFilter(void) {
         if (alertLevel != NO_ALERT) {
             callback(alertLevel);
         }
--- a/ble/services/UARTService.h	Mon Nov 02 09:09:05 2015 +0000
+++ b/ble/services/UARTService.h	Mon Nov 02 09:09:05 2015 +0000
@@ -17,13 +17,8 @@
 #ifndef __BLE_UART_SERVICE_H__
 #define __BLE_UART_SERVICE_H__
 
-#ifdef YOTTA_CFG_MBED_OS
-#include "mbed-drivers/mbed.h"
-#include "mbed-drivers/Stream.h"
-#else
 #include "mbed.h"
 #include "Stream.h"
-#endif
 
 #include "ble/UUID.h"
 #include "ble/BLE.h"
--- a/ble/services/URIBeaconConfigService.h	Mon Nov 02 09:09:05 2015 +0000
+++ b/ble/services/URIBeaconConfigService.h	Mon Nov 02 09:09:05 2015 +0000
@@ -18,12 +18,7 @@
 #define SERVICES_URIBEACONCONFIGSERVICE_H_
 
 #include "ble/BLE.h"
-
-#ifdef YOTTA_CFG_MBED_OS
-#include "mbed-drivers/mbed.h"
-#else
 #include "mbed.h"
-#endif
 
 extern const uint8_t UUID_URI_BEACON_SERVICE[UUID::LENGTH_OF_LONG_UUID];
 extern const uint8_t UUID_LOCK_STATE_CHAR[UUID::LENGTH_OF_LONG_UUID];
--- a/module.json	Mon Nov 02 09:09:05 2015 +0000
+++ b/module.json	Mon Nov 02 09:09:05 2015 +0000
@@ -10,7 +10,7 @@
   ],
   "author": "Rohit Grover",
   "repository": {
-    "url": "git@github.com:ARMmbed/ble.git",
+    "url": "https://github.com/ARMmbed/ble.git",
     "type": "git"
   },
   "homepage": "http://mbed.org/ble",
@@ -28,9 +28,6 @@
     "nrf51822": {
       "ble-nrf51822": "^1.0.0"
     },
-    "cordio": {
-      "ble-wicentric": "~0.0.0"
-    },
     "mbed-classic": {
       "mbed-classic": "~0.0.1"
     },