Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API X_NUCLEO_6180XA1 X_NUCLEO_IDB0XA1 mbed
Fork of BLE_HeartRate_IDB0XA1 by
tedious.cpp
00001 // tedious.cpp - tedious setup and handling of DETECTION services 00002 00003 #include "detection.h" 00004 00005 // declare a CharacteristicDataInitializer which can be used to initialize 00006 // all our characteristics 00007 00008 static CharacteristicInitializer ini; 00009 00010 // Detection Service 00011 // 00012 // Service detection(0xA010,"Detection"); // Detection Service 00013 // Characteristic<Bool> chrPresence(detection,0xA011, "n", "Presence"); 00014 00015 UserDescriptor(namePresense,attPresence,dscPresence,"Presence") 00016 static ReadOnlyGattCharacteristic<Bool> chrPresence(0xA011,ini.pBool(),0,dscPresence,1); 00017 00018 static GattCharacteristic *detectionList[] = {&chrPresence}; 00019 static GattService detection(0xA010, detectionList, GattListLength(detectionList)); 00020 00021 // Address Service 00022 // 00023 // Service address(0xA020,"Address"); 00024 // Characteristic<ObjectId> chrId (address, 0xA021, "na", "ID"); 00025 // Characteristic<ObjectName> chrName (address, 0xA022, "na", "Name"); 00026 // Characteristic<Bool> chrLayout (address, 0xA023, "na", "Layout"); 00027 00028 UserDescriptor(nameId,attId,dscId,"ID") 00029 static WriteOnlyGattCharacteristic<ObjectId> chrId(0xA021,ini.pObjectId(),0,dscId,1); 00030 00031 UserDescriptor(nameName,attName,dscName,"Name") 00032 static ReadOnlyGattCharacteristic<ObjectName> chrName(0xA022,ini.pObjectName(),0,dscName,1); 00033 00034 UserDescriptor(nameLayout,attLayout,dscLayout,"Layout") 00035 static ReadOnlyGattCharacteristic<ObjectName> chrLayout(0xA023,ini.pObjectName(),0,dscLayout,1); 00036 00037 static GattCharacteristic *addressList[] = {&chrId,&chrName,&chrLayout}; 00038 static GattService address(0xA020, addressList, GattListLength(addressList)); 00039 00040 // Debug Service 00041 // 00042 // Service debug(0xA030,"Debug"); 00043 // Characteristic<Bool> chrTest (debug, 0xA031, "w", "Test"); 00044 // Characteristic<DateTime> chrTimestamp (debug, 0xA032, "r", "Timestamp"); 00045 00046 UserDescriptor(nameTest,attTest,dscTest,"Test") 00047 static WriteOnlyGattCharacteristic<Bool> chrTest(0xA031,ini.pBool(),0,dscTest,1); 00048 00049 UserDescriptor(nameTimeStamp,attTimeStamp,dscTimeStamp,"TimeStamp") 00050 static ReadOnlyGattCharacteristic<DateTime> chrTimeStamp(0xA032,ini.pDateTime(),0,dscTimeStamp,1); 00051 00052 static GattCharacteristic *debugList[] = {&chrTest,&chrTimeStamp}; 00053 static GattService debug(0xA030, debugList, GattListLength(debugList)); 00054 00055 00056 //============================================================================== 00057 // Update Callback 00058 //============================================================================== 00059 00060 static void cbWritten(Blob &o) // handle updates 00061 { 00062 Bool value; 00063 00064 if (updated(o,chrTest)) // has chrTest been updated? 00065 { 00066 get(o,chrTest,value); // get value of chrTest 00067 set(o,chrPresence,value); // and store this value to chrPresence 00068 00069 print(o,value,"test"); 00070 if (value == 0) 00071 blinkConnected(o,"x x "); 00072 else if (value == 1) 00073 blinkConnected(o,"xxx xxx "); 00074 else 00075 blinkConnected(o,"x xxx x xxx "); 00076 } 00077 else if (updated(o,chrPresence)) // has chrPresence been updated? 00078 { 00079 get(o,chrPresence,value); 00080 print(o,value,"test"); 00081 } 00082 } 00083 00084 //============================================================================== 00085 // Register Services and Callbacks 00086 //============================================================================== 00087 00088 void tediousServices(Blob &o) // enroll all services & characteristics 00089 { 00090 enroll(o,detection,0xA010); 00091 enroll(o,address,0xA020); 00092 enroll(o,debug,0xA030); 00093 00094 onWritten(o,cbWritten); // setup 'data written' callback 00095 } 00096 00097 //eof
Generated on Tue Jul 12 2022 21:31:05 by
1.7.2
