GAP based TOF Demo

Dependencies:   BLE_API X_NUCLEO_6180XA1 mbed

Fork of BLE_HeartRate_IDB0XA1 by ST

Revision:
24:0f08f68579bd
Parent:
23:677689000369
Child:
27:32267cee7cb8
--- a/bricks/characteristic.h	Fri Jan 06 15:28:18 2017 +0000
+++ b/bricks/characteristic.h	Fri Jan 06 20:49:58 2017 +0000
@@ -18,10 +18,10 @@
 //
 //    uuid:    A unique universal ID which identifies the characteristic
 //
-//    mode:    A string comprising zero or more access mode characters which 
-//             define the possible access modes of the characteristic.  
+//    mode:    A string comprising zero or more mode characters which 
+//             define possible properties of the characteristic.  
 //
-//                ""       no access
+//                ""       no properties
 //                "b"      broadcast
 //                "r"      read access
 //                "s"      send & pray (write without response)
@@ -93,35 +93,11 @@
 #include "ble/Gap.h"
 #include "bricks/types.h"
 #include "bricks/collection.h"
-
-//==============================================================================
-// UserDescriptor Class - Create a User Descriptor
-//==============================================================================
+#include "bricks/descriptor.h"
 
-   class UserDescriptor : public GattAttribute
-   {
-       private:
-          typedef GattAttribute *GattAttributePtr;
-       
-       public:
-          GattAttributePtr plist[1];
-          
-          UserDescriptor(const char *name) :
-             GattAttribute(0x2901,(uint8_t*)name,strlen(name),strlen(name))
-          {
-              plist[0] = this;
-          }
-   };
-
-//==============================================================================
-// Characteristic Class - derived GattCharacteristic, auto-adds to service list
-//==============================================================================
+// Parameter mode is used to define properties based on a string combination
+// of the following characters:
 //
-// Synopsis: 
-//             Characteristic(list,uuid,mode)
-//             Characteristic(list,uuid,mode,description)
-// 
-// Parameter mode is a string combination of the following characters:
 //    ""       BLE_GATT_CHAR_PROPERTIES_NONE (0x00)
 //    "b"      BLE_GATT_CHAR_PROPERTIES_BROADCAST (0x01)
 //    "r"      BLE_GATT_CHAR_PROPERTIES_READ (0x02)
@@ -151,6 +127,8 @@
          memset(inidata,0,sizeof(IniBuffer));
       }
    }
+   
+   class Service;
 
    template <typename Type>
    class Characteristic : public GattCharacteristic
@@ -195,7 +173,7 @@
          }
          
       public:
-         Characteristic<Type> (Collection &list, UUID uuid, const char *mode,
+         Characteristic<Type> (Service &service, UUID uuid, const char *mode,
                                Type *valuePtr = (Type*)&inidata) : 
             GattCharacteristic(uuid, 
                                reinterpret_cast<uint8_t*> (valuePtr),
@@ -204,7 +182,7 @@
                                getmask(mode),
                                NULL,             // descriptor list
                                0,                // number of descriptors
-                               false),
+                               false)
          {
             init();                              // assure initializing
             
@@ -214,12 +192,12 @@
             int feasible = (sizeof(Type) <= sizeof(inibuffer)); 
             if (feasible || valuePtr != (Type*)&inidata)
             {
-               list.add(this);                   // add to setup list
+               service.add(this);                // add to service
             }                                    // otherwise just ignore!
          }
 
       public:
-         Characteristic<Type> (Collection &list, UUID uuid, const char *mode,
+         Characteristic<Type> (Service &service, UUID uuid, const char *mode,
                                const char *name, Type *valuePtr = (Type*)&inidata) : 
             GattCharacteristic(uuid, 
                                reinterpret_cast<uint8_t*> (valuePtr),
@@ -239,7 +217,7 @@
             int feasible = (sizeof(Type) <= sizeof(IniBuffer)); 
             if (feasible || valuePtr != (Type*)&inidata)
             {
-               list.add(this);                   // add to setup list
+               service.add(this);                // add to service
             }                                    // otherwise just ignore!
          }
    };