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: MQTT target_st_bluenrg
Fork of ble-star-mbed by
BleMasterService.h
00001 #ifndef __BLEMASTERSERVICE_H__ 00002 #define __BLEMASTERSERVICE_H__ 00003 00004 #include <events/mbed_events.h> 00005 #include <mbed.h> 00006 #include "ble/BLE.h" 00007 #include "ble/Gap.h" 00008 #include "ble/DiscoveredCharacteristic.h" 00009 #include "ble/DiscoveredService.h" 00010 #include <UUID.h> 00011 #include <BleSlaveService.h> 00012 00013 00014 00015 /* Max number of connectable nodes */ 00016 #define MAX_NUM_OF_NODES 7 00017 00018 /* brief Data type length */ 00019 #define ONE_BYTE_LEN 1 00020 #define TWO_BYTES_LEN 2 00021 00022 #define ENV_DATA_LEN_SHORT 8 00023 #define ENV_DATA_LEN_LONG 12 00024 #define PRESS_DATA_LEN 4 00025 #define HUM_DATA_LEN 2 00026 #define TEMP_DATA_LEN 2 00027 #define LED_DATA_LEN ONE_BYTE_LEN 00028 #define MIC_DATA_LEN ONE_BYTE_LEN 00029 #define LUX_DATA_LEN TWO_BYTES_LEN 00030 #define PRX_DATA_LEN TWO_BYTES_LEN 00031 #define ACC_DATA_LEN 6 00032 #define GYR_DATA_LEN 6 00033 #define MAG_DATA_LEN 6 00034 #define SFUSION_DATA_LEN 6 00035 #define X_DATA_LEN 2 00036 #define Y_DATA_LEN 2 00037 #define Z_DATA_LEN 2 00038 #define WUP_DATA_LEN 0 00039 #define STATUS_DATA_LEN 0 00040 00041 #define TSTAMP_LEN 2 00042 #define NODE_ID_LEN 2 00043 #define TYPE_ID_LEN 1 00044 00045 #define ATTR_HEAD_LEN TSTAMP_LEN+NODE_ID_LEN+TYPE_ID_LEN 00046 #define ENV_DATA_LEN PRESS_DATA_LEN+HUM_DATA_LEN+TEMP_DATA_LEN+TEMP_DATA_LEN 00047 #define MEMS_DATA_LEN ACC_DATA_LEN+GYR_DATA_LEN+MAG_DATA_LEN 00048 00049 #define INT_VALUE 1 00050 #define FLOAT_VALUE 2 00051 00052 00053 /* Supported peripheral nodes ID */ 00054 #define NODE_ME1 0x01 /* MOTENV1 */ 00055 #define NODE_FL1 0x02 /* FLIGHT1 */ 00056 #define NODE_AM1 0x03 /* ALLMEMS1 */ 00057 00058 #define BDADDR_SIZE 6 00059 #define NODE_ID_B1 0 /* byte of the node BLE address used as 1st byte of the node ID */ 00060 #define NODE_ID_B2 1 /* byte of the node BLE address used as 2nd byte of the node ID */ 00061 #define NODE_ID_OFFSET NODE_ID_B1 00062 00063 #define ME1_WUP_EVENT_ENABLED 1 /* To enable/disable Wake Up events from MOTENV1 nodes */ 00064 #define AM1_WUP_EVENT_ENABLED 0 /* To enable/disable Wake Up events from ALLMEMS1 nodes */ 00065 /* It is present, without the need of any additional board, on the X-NUCLEO-IKS01A2. */ 00066 #define MIC_PRESENT (0x20 | 0x04) /* MIC on the X-NUCLEO-CCA02M1 (in this case the fw running on the node is the ALLMEMS1). */ 00067 #define PLUX_PRESENT (0x03) /* Proximity and Lux sensor on X-NUCLEO-6180XA1 (in this case the fw running on the node */ 00068 /* is the FLIGHT1). */ 00069 00070 #define BDADDR_SIZE 6 00071 #define NODE_ID_B1 0 /* byte of the node BLE address used as 1st byte of the node ID */ 00072 #define NODE_ID_B2 1 /* byte of the node BLE address used as 2nd byte of the node ID */ 00073 #define NODE_ID_OFFSET NODE_ID_B1 00074 00075 #define BUF_LEN 27 00076 00077 #define ENABLE 1 00078 #define DISABLE 0 00079 00080 #define MANUF_SPECIFIC_TYPE 0xFF 00081 #define STM32_NUCLEO 0x80 00082 #define SENSOR_TILE 0x02 00083 #define BLUE_COIN 0x03 00084 #define WUP_POS 0x0A 00085 #define MIC_POS 0x1A 00086 #define PRX_POS 0x19 00087 #define ACC_POS 0x17 00088 #define SFUS_POS 0x07 00089 00090 /* Feature mask for Temperature1 */ 00091 #define FEATURE_MASK_TEMP1 0x00040000 00092 /* Feature mask for Temperature2 */ 00093 #define FEATURE_MASK_TEMP2 0x00010000 00094 /* Feature mask for Pressure */ 00095 #define FEATURE_MASK_PRESS 0x00100000 00096 /* Feature mask for Humidity */ 00097 #define FEATURE_MASK_HUM 0x00080000 00098 /* Feature mask for Accelerometer */ 00099 #define FEATURE_MASK_ACC 0x00800000 00100 /* Feature mask for Gyroscope */ 00101 #define FEATURE_MASK_GYR 0x00400000 00102 /* Feature mask for Magnetometer */ 00103 #define FEATURE_MASK_MAG 0x00200000 00104 /* Feature mask for Sensor fusion */ 00105 #define FEATURE_MASK_SENSORFUSION 0x00000100 00106 /* Feature mask for LED */ 00107 #define FEATURE_MASK_LED_EVENTS 0x20000000 00108 /* Feature mask for WakeUp EVENT (here used as Motion Detector) */ 00109 #define FEATURE_MASK_WAKEUP_EVENTS 0x00000400 00110 /* Feature mask for PROXIMITY EVENT */ 00111 #define FEATURE_MASK_PROX 0x02000000 00112 /* Feature mask for MICROPHONE */ 00113 #define FEATURE_MASK_MIC 0x04000000 00114 /* Command to set the WakeUp notification (here used as Motion Detector) */ 00115 #define WAKEUP_NOTIFICATION_CMD 'w' 00116 /* Command to set the notification frequency */ 00117 #define NOTIFICATION_FREQ_CMD 255 00118 /* Notification frequency @50mS (default) */ 00119 #define NOTIFICATION_FREQ_50 0 00120 /* Notification frequency @100mS */ 00121 #define NOTIFICATION_FREQ_100 1 00122 /* Notification frequency @1S */ 00123 #define NOTIFICATION_FREQ_1000 10 00124 /* Notification frequency @5S */ 00125 #define NOTIFICATION_FREQ_5000 50 00126 /* Set the notification frequency to 100ms multiple */ 00127 #define SENDING_INTERVAL_100MS_MULTIPLE 10 00128 /* Notification frequency when wifi is enabled */ 00129 #define NOTIFICATION_FREQ_WIFI_ON NOTIFICATION_FREQ_1000 /* reduced to 1000 from NOTIFICATION_FREQ_5000 */ 00130 /* Notification frequency when wifi is disabled */ 00131 #define NOTIFICATION_FREQ_WIFI_OFF NOTIFICATION_FREQ_1000 00132 /* 1 to enable mems noifications */ 00133 #define ENABLE_MEMS 0 00134 /* 1 to enable the scanning after disabling a notification */ 00135 #define SCAN_AFTER_NOTIFICATION 1 00136 00137 extern EventQueue eventQ; 00138 00139 00140 00141 /* This var defines the central role 00142 * 0 if master 00143 * 1 if slave */ 00144 extern uint8_t role; 00145 00146 /* Pointer to var (uint8_t role) */ 00147 //uint8_t * pRole; 00148 00149 00150 00151 /* Flag to indicate that the characteristic read is completed successful 00152 * 1 successful 00153 * 0 or anything else failed */ 00154 extern uint8_t readCompleted; 00155 00156 00157 00158 /* Flag to indicate if the device discovery is completed successful 00159 * 1 successful 00160 * 0 or anything else failed */ 00161 extern uint8_t discoveryCompleted; 00162 00163 00164 00165 /* Flag to indicate if the ch descriptor write is completed successful 00166 * 1 successful 00167 * 0 or anything else failed */ 00168 extern uint8_t writeDescriptorCompleted; 00169 00170 00171 00172 /* Flag to indicate if the advertising is completed 00173 * 1 completed 00174 * 0 or anything else not completed */ 00175 extern uint8_t advEnds; 00176 00177 00178 /* Flag to indicate if a change of notification is pending 00179 * 1 pending 00180 * 0 or anything else not pending */ 00181 extern uint8_t notificationPending; 00182 00183 00184 /* Flag to indicate if the ble stack is busy 00185 * 1 busy 00186 * 0 or anything else not busy */ 00187 extern uint8_t stackBusy; 00188 00189 00190 00191 /* Supported peripheral nodes name */ 00192 //const char NODE_MOTENV[] = "ME1V310"; 00193 const char NODE_MOTENV[] = "ME1V320"; 00194 const char NODE_FLIGHT[] = "FL1V310"; 00195 const char NODE_ALLMEMS[] = "AM1V320"; 00196 00197 00198 /* Properties mask */ 00199 static uint8_t props_mask[] = { 00200 0x01, 00201 0x02, 00202 0x04, 00203 0x08, 00204 0x10, 00205 0x20, 00206 0x40, 00207 0x80 00208 }; 00209 00210 00211 /* Enum of different states */ 00212 typedef enum { 00213 CONN_INIT, // 0 00214 START_DEVICE_DISCOVERY, // 1 00215 DEVICE_FOUND, // 2 00216 DEVICE_NOT_FOUND, // 3 00217 DEVICE_DISCOVERY_COMPLETE, // 4 00218 START_DEVICE_CONNECTION, // 5 00219 DEVICE_CONNECTED, // 6 00220 DEVICE_CONNECTION_COMPLETE, // 7 00221 START_DISCOVERABLE_MODE, // 8 00222 DISCOVERABLE_MODE_SET, // 9 00223 START_SERVICE_DISCOVERY, //10 00224 SERVICE_DISCOVERED, //11 00225 SERVICE_DISCOVERY_COMPLETE, //12 00226 START_HARDWARE_SERV_CHARS_DISCOVERY, //13 00227 HARDWARE_SERV_CHARS_DISCOVERED, //14 00228 HARDWARE_SERV_CHARS_DISCOVERY_COMPLETE, //15 00229 START_SOFTWARE_SERV_CHARS_DISCOVERY, //16 00230 SOFTWARE_SERV_CHARS_DISCOVERED, //17 00231 SOFTWARE_SERV_CHARS_DISCOVERY_COMPLETE, //18 00232 START_CONFIGURATION_SERV_CHARS_DISCOVERY, //19 00233 CONFIGURATION_SERV_CHARS_DISCOVERED, //20 00234 CONFIGURATION_SERV_CHARS_DISCOVERY_COMPLETE, //21 00235 ENABLE_ME1_LED_NOTIFICATIONS, //22 00236 ENABLE_ME1_WUP_NOTIFICATIONS, //23 00237 NOTIFICATIONS_ENABLED, //24 00238 READ_INIT, //25 00239 READING_PRX, //26 00240 NOTIFY_PRX_TO_CLIENT, //27 00241 READING_ENVIRONMENTAL, //28 00242 NOTIFY_ENV_TO_CLIENT, //29 00243 READING_LED, //30 00244 NOTIFY_LED_TO_CLIENT, //31 00245 READING_LUX, //32 00246 NOTIFY_LUX_TO_CLIENT, //33 00247 READING_MIC, //34 00248 NOTIFY_MIC_TO_CLIENT, //35 00249 READING_AGM, //36 00250 NOTIFY_AGM_TO_CLIENT, //37 00251 READING_SFUSION, //38 00252 NOTIFY_SFUSION_TO_CLIENT, //39 00253 READING_PRESSURE, //40 00254 READING_HUMIDITY, //41 00255 READING_TEMPERATURE, //42 00256 ALL_DATA_READ, //43 00257 NOTIFICATIONS_DATA_READ, //44 00258 DISABLE_NOTIFICATIONS, //45 00259 READING_DISCONNECTION, //46 00260 } Status_t; 00261 00262 00263 /* (Service) Handle struct */ 00264 typedef struct { 00265 uint16_t start_h; 00266 uint16_t end_h; 00267 } Handle_t; 00268 00269 typedef DiscoveredCharacteristic::Properties_t Properties_t; 00270 00271 typedef BLEProtocol::AddressBytes_t tBDAddr; 00272 00273 /* Peripheral device info struct */ 00274 typedef struct { 00275 uint8_t dev_v; // per device ID 00276 tBDAddr bdaddr; // per device addr 00277 } devInfo_t; 00278 00279 00280 /* Struct contains the peripheral devices informations */ 00281 typedef struct { 00282 devInfo_t devInfo[MAX_NUM_OF_NODES]; 00283 uint8_t discovery_enabled; 00284 bool device_found; 00285 uint8_t connDevices; 00286 uint8_t discDevices; 00287 uint8_t connDeviceIdx; 00288 uint8_t readDeviceIdx; 00289 uint16_t connection_handle[MAX_NUM_OF_NODES]; 00290 bool is_connected[MAX_NUM_OF_NODES]; 00291 bool is_disconnected[MAX_NUM_OF_NODES]; 00292 bool is_unconnectable[MAX_NUM_OF_NODES]; 00293 00294 Handle_t gen_access_profile_handle[MAX_NUM_OF_NODES]; 00295 Handle_t gen_attribute_profile_handle[MAX_NUM_OF_NODES]; 00296 Handle_t hardware_service_handle[MAX_NUM_OF_NODES]; 00297 Handle_t configuration_service_handle[MAX_NUM_OF_NODES]; 00298 Handle_t software_service_handle[MAX_NUM_OF_NODES]; 00299 00300 // Characteristic handles 00301 uint16_t environmental_char_handle[MAX_NUM_OF_NODES]; 00302 uint16_t pressure_char_handle[MAX_NUM_OF_NODES]; 00303 uint16_t humidity_char_handle[MAX_NUM_OF_NODES]; 00304 uint16_t temperature_char_handle[MAX_NUM_OF_NODES]; 00305 uint16_t led_char_handle[MAX_NUM_OF_NODES]; 00306 uint16_t cfg_char_handle[MAX_NUM_OF_NODES]; 00307 uint16_t wup_char_handle[MAX_NUM_OF_NODES]; 00308 uint16_t mic_char_handle[MAX_NUM_OF_NODES]; 00309 uint16_t prx_char_handle[MAX_NUM_OF_NODES]; 00310 uint16_t lux_char_handle[MAX_NUM_OF_NODES]; 00311 uint16_t agm_char_handle[MAX_NUM_OF_NODES]; 00312 uint16_t sfusion_char_handle[MAX_NUM_OF_NODES]; 00313 00314 uint8_t led_char_read[MAX_NUM_OF_NODES]; 00315 uint8_t wup_char_read[MAX_NUM_OF_NODES]; 00316 uint8_t mic_char_read[MAX_NUM_OF_NODES]; 00317 uint8_t prx_char_read[MAX_NUM_OF_NODES]; 00318 uint8_t agm_char_read[MAX_NUM_OF_NODES]; 00319 uint8_t sfusion_char_read[MAX_NUM_OF_NODES]; 00320 uint8_t wup_event[MAX_NUM_OF_NODES]; 00321 uint8_t mic_event[MAX_NUM_OF_NODES]; 00322 uint8_t prx_event[MAX_NUM_OF_NODES]; 00323 uint8_t agm_event[MAX_NUM_OF_NODES]; 00324 uint8_t sfusion_event[MAX_NUM_OF_NODES]; 00325 uint8_t prx_on[MAX_NUM_OF_NODES]; 00326 uint8_t agm_on[MAX_NUM_OF_NODES]; 00327 uint8_t sfusion_on[MAX_NUM_OF_NODES]; 00328 uint8_t mic_event_enabled; 00329 uint8_t prx_event_enabled; 00330 uint8_t agm_event_enabled; 00331 uint8_t sfusion_event_enabled; 00332 uint8_t wup_event_enabled; 00333 uint8_t acc_event_enabled; 00334 uint8_t gyr_event_enabled; 00335 uint8_t mag_event_enabled; 00336 Status_t status; 00337 00338 } PeripheralDevices_t; 00339 00340 00341 00342 00343 /* List of type id */ 00344 typedef enum { 00345 UNKNOWN_TYPE_ID, //0 00346 PRESS_TYPE_ID, //1 (its data value is 4 bytes long) 00347 HUM_TYPE_ID, //2 (its data value is 2 bytes long) 00348 TEMP_TYPE_ID, //3 (its data value is 2 bytes long) 00349 LED_TYPE_ID, //4 (its data value is 1 byte long) 00350 PRX_TYPE_ID, //5 (its data value is 2 bytes long) 00351 WUP_TYPE_ID, //6 (no data value) 00352 MICLEVEL_TYPE_ID, //7 (its data value is 1 byte long) 00353 LUX_TYPE_ID, //8 (its data value is 2 bytes long) 00354 ACC_TYPE_ID, //9 (its data value is 6 bytes long) 00355 GYR_TYPE_ID, //10 (its data value is 6 bytes long) 00356 MAG_TYPE_ID, //11 (its data value is 6 bytes long) 00357 STATUS_TYPE_ID, //12 (no data value) 00358 SFUSION_TYPE_ID //13 (its data value is 8 bytes long) 00359 // (increase the enum to add new data type IDs) 00360 } Data_Type_ID_t; 00361 00362 00363 00364 /* Struct of the generic DiscoveredCharacteristic node */ 00365 struct DiscoveredCharacteristicNode{ 00366 //data 00367 DiscoveredCharacteristic data; 00368 //pointer to next node 00369 DiscoveredCharacteristicNode * next; 00370 }; 00371 00372 00373 /* Header pointer of the DiscoveredCharacteristic list */ 00374 extern DiscoveredCharacteristicNode * headCharacteristic[MAX_NUM_OF_NODES]; 00375 extern DiscoveredCharacteristicNode * tmp[MAX_NUM_OF_NODES]; 00376 00377 00378 /* Primary Service UUID expected from Sensor demo peripherals */ 00379 extern UUID::ShortUUIDBytes_t GENERIC_ACCESS_PROFILE_UUID; 00380 extern UUID::ShortUUIDBytes_t GENERIC_ATTRIBUTE_PROFILE_UUID; 00381 00382 00383 00384 00385 /* Services UUID */ // 1b:c5:d5:a5:02:00:b4:9a:e1:11:XX:XX:XX:XX:XX:XX 00386 extern UUID::LongUUIDBytes_t HARDWARE_SERVICE_UUID; 00387 00388 extern UUID::LongUUIDBytes_t CONFIG_SERVICE_UUID; 00389 00390 extern UUID::LongUUIDBytes_t SOFTWARE_SERVICE_UUID; 00391 00392 00393 00394 00395 /* Characteristics UUID */ 00396 /* ENVIRONMENTAL */ 00397 extern UUID::LongUUIDBytes_t ENVIRONMENTAL_CHAR_UUID; 00398 00399 /* ENVIRONMENTAL for Sensor Tile */ 00400 extern UUID::LongUUIDBytes_t ENVIRONMENTAL_ST_CHAR_UUID; 00401 00402 /* ACC + GYRO + MAG */ 00403 extern UUID::LongUUIDBytes_t ACCGYROMAG_CHAR_UUID; 00404 00405 /* MEMS SENSOR FUSION */ 00406 extern UUID::LongUUIDBytes_t SFUSION_CHAR_UUID; 00407 00408 /* LED */ 00409 extern UUID::LongUUIDBytes_t LED_CHAR_UUID; 00410 00411 /* WAKEUP */ 00412 extern UUID::LongUUIDBytes_t WAKEUP_EVENT_CHAR_UUID; 00413 00414 /* MICROPHONE */ 00415 extern UUID::LongUUIDBytes_t MIC_EVENT_CHAR_UUID; 00416 00417 /* PROXIMITY */ 00418 extern UUID::LongUUIDBytes_t PROXIMITY_CHAR_UUID; 00419 00420 /* LUX */ 00421 extern UUID::LongUUIDBytes_t LUX_CHAR_UUID; 00422 00423 /* CONFIGURATION */ 00424 extern UUID::LongUUIDBytes_t CONFIG_CHAR_UUID; 00425 00426 00427 /*----- -----*/ 00428 extern uint8_t wifi_data[256]; 00429 extern uint8_t new_data; 00430 extern uint8_t *data; 00431 extern uint8_t wifi_present; 00432 00433 extern char print_msg_buff[512]; 00434 //extern UART_HandleTypeDef UartMsgHandle; 00435 00436 //extern uint16_t connection_handle = 0; 00437 00438 extern uint8_t attribute_value[20]; 00439 extern uint8_t star_attr_value[256]; 00440 //extern uint8_t bnrg_expansion_board_type = IDB04A1; /* at startup, suppose the X-NUCLEO-IDB04A1 is used */ 00441 extern uint8_t notification_freq; 00442 00443 00444 /*---- Main functions declaration ----*/ 00445 /* Complete the initialization of ble module */ 00446 void bleInitComplete (BLE::InitializationCompleteCallbackContext *params); 00447 00448 /* scheduleBleEventsProcessing */ 00449 void scheduleBleEventsProcessing (BLE::OnEventsToProcessCallbackContext* context); 00450 00451 /* Initialization error handling */ 00452 void onBleInitError (BLE &ble, ble_error_t error); 00453 00454 void checkStatus (void); 00455 00456 00457 /*---- Master service functions declarations ----*/ 00458 /* Scan for new peripheral nodes and establish new connections */ 00459 void connectionProcess (void); 00460 00461 /* Read data from peripheral nodes */ 00462 void readingProcess (void); 00463 00464 /* Create a null gatt read pointer */ 00465 GattReadCallbackParams * nullGattReadCallbackP (uint16_t connection_handle); 00466 00467 00468 /* Print the central mac addr */ 00469 void printMacAddress (void); 00470 00471 /* Complete the initialization of ble module */ 00472 void bleInitComplete (BLE::InitializationCompleteCallbackContext *params); 00473 00474 /* Callback functions */ 00475 void disconnectionCallback (const Gap::DisconnectionCallbackParams_t *); 00476 00477 void connectionCallback (const Gap::ConnectionCallbackParams_t *params); 00478 00479 void advertisementCallback (const Gap::AdvertisementCallbackParams_t *params); 00480 00481 void onStopScan (Gap::TimeoutSource_t t); 00482 00483 void serviceDiscoveryCallback (const DiscoveredService *service); 00484 00485 void characteristicDiscoveryCallback (const DiscoveredCharacteristic *characteristicP); 00486 00487 void discoveryTerminationCallback (Gap::Handle_t connectionHandle); 00488 00489 /* Method called after the reading of a characteristic */ 00490 void readCharacteristicCallback (const GattReadCallbackParams *response); 00491 00492 /* Method called after a periph descriptor is written */ 00493 void perDescriptorWrittenCallback (const GattWriteCallbackParams* event); 00494 00495 00496 00497 /* Save the found peripheral device in the struct containing all the 00498 found peripheral devices. */ 00499 void saveDeviceFound (uint8_t adv_type, BLEProtocol::AddressBytes_t addr, 00500 uint8_t data_length, const uint8_t* data_RSSI, uint8_t pos, uint8_t dev_v, 00501 uint8_t wup_event, uint8_t mic_event, uint8_t prx_event, 00502 uint8_t agm_event, uint8_t sfusion_event); 00503 00504 /* Connect the device as Master to a peripheral device */ 00505 void connectPeripheral (void); 00506 00507 /* Service discovery */ 00508 void discoverServices (void); 00509 00510 /* Initialize the struct where all peripheral devices are stored */ 00511 void initProcess (void); 00512 00513 /* Start the discovery of new peripheral nodes */ 00514 void startDiscovery (void); 00515 00516 /* This function retrieves the peripheral device index from the connection handle */ 00517 void getDeviceFromConnHandle (uint16_t handle, uint8_t *index, tBDAddr devAddr); 00518 00519 /* This method reads the characteristic in input */ 00520 void readSensorData (const DiscoveredCharacteristic &characteristic, 00521 uint16_t connection_handle, uint8_t index); 00522 00523 /* Set the new status */ 00524 void setNewStatus (void); 00525 00526 /* Method that enables characteristic notifications */ 00527 void enableNotifications (uint16_t conn_handle, uint8_t index, uint8_t dev_v, uint8_t set_mode); 00528 00529 /* Write a characteristic descriptor */ 00530 void writeCharacDescriptor (uint16_t conn_handle, uint16_t attr_handle, uint8_t attr_len, 00531 uint8_t* attr_value); 00532 00533 /* Get error */ 00534 ble_error_t writeCharacDescriptorWithError (uint16_t conn_handle, uint16_t attr_handle, uint8_t attr_len, 00535 uint8_t* attr_value); 00536 00537 /* Write a characteristic value without waiting for any response */ 00538 void writeCharacValueWithoutResp (uint16_t conn_handle, uint16_t attr_handle, uint8_t attr_len, 00539 uint8_t* attr_value); 00540 00541 /* Get error */ 00542 ble_error_t writeCharacValueWithoutRespWithError (uint16_t conn_handle, uint16_t attr_handle, uint8_t attr_len, 00543 uint8_t* attr_value); 00544 00545 /* Builds a Jason format string */ 00546 void Build_MEMS_Packet (uint8_t *attr_value, char *data_type, tBDAddr devAddr, uint8_t num_type); 00547 00548 00549 /* Create new attr value for the master */ 00550 void Create_New_Attr_Value (uint8_t *tstamp, tBDAddr devAddr, uint8_t data_type_id, uint8_t *data, uint8_t data_length); 00551 00552 /* Method called when there is a notification from the sever */ 00553 void onNotificationCallback (const GattHVXCallbackParams* event); 00554 00555 void scanTimeOut (void); 00556 /*----------------------------------------------------------------------------*/ 00557 00558 00559 00560 00561 /* DiscoveredCharacteristic List methods */ 00562 00563 /* Creating a new DiscoveredCharacteristicNode (struct r308)*/ 00564 DiscoveredCharacteristicNode * createDCNode (const DiscoveredCharacteristic &ch, DiscoveredCharacteristicNode *next); 00565 00566 /* Prepend a DiscoveredCharacteristicNode (struct r308)*/ 00567 DiscoveredCharacteristicNode * prependDCNode (DiscoveredCharacteristicNode *head, const DiscoveredCharacteristic *characteristic); 00568 00569 /* Append a DiscoveredCharacteristicNode (struct r308)*/ 00570 DiscoveredCharacteristicNode * appendDCNode (DiscoveredCharacteristicNode *head, const DiscoveredCharacteristic *characteristic); 00571 00572 /* Number of DiscoveredCharacteristic nodes */ 00573 int countElements (DiscoveredCharacteristicNode *head); 00574 00575 /* Search for a DiscoveredCharacteristic node by declaration handle */ 00576 DiscoveredCharacteristicNode * searchDCNode (DiscoveredCharacteristicNode *head, uint16_t declHandle); 00577 00578 /* Delete the DCN list */ 00579 void deleteDCNList (DiscoveredCharacteristicNode *head); 00580 00581 /*----------------------------------------------------------------------------*/ 00582 00583 00584 00585 00586 00587 00588 00589 #endif /*__BLEMASTERSERVICE_H__*/
Generated on Wed Jul 27 2022 08:13:19 by
1.7.2
