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
BleSlaveService.h
00001 #ifndef __BLESLAVESERVICE_H__ 00002 #define __BLESLAVESERVICE_H__ 00003 00004 #include "ble/GattService.h" 00005 #include "ble/GattCharacteristic.h" 00006 #include <BleMasterService.h> 00007 00008 /* Attribute value format of the STAR_CHAR */ 00009 /* Timestamp | Node ID | Type ID | value | Type ID | value | Type ID | value | */ 00010 /* 2 bytes | 2 bytes | 1 byte | x bytes | 1 byte | x bytes | 1 byte | x bytes | */ 00011 #define STAR_CHAR_MAX_VALUE_LEN 20 00012 00013 #define uint8_tNAME_BLESTAR1 'B','l','e','S','t','a','r','1' 00014 00015 00016 /* Store Value into a buffer in Little Endian Format */ 00017 #define STORE_LE_16(buf, val) ( ((buf)[0] = (uint8_t) (val) ) , \ 00018 ((buf)[1] = (uint8_t) (val>>8) ) ) 00019 00020 #define STORE_LE_32(buf, val) ( ((buf)[0] = (uint8_t) (val) ) , \ 00021 ((buf)[1] = (uint8_t) (val>>8) ) , \ 00022 ((buf)[2] = (uint8_t) (val>>16) ) , \ 00023 ((buf)[3] = (uint8_t) (val>>24) ) ) 00024 00025 #define STORE_BE_32(buf, val) ( ((buf)[3] = (uint8_t) (val) ) , \ 00026 ((buf)[2] = (uint8_t) (val>>8) ) , \ 00027 ((buf)[1] = (uint8_t) (val>>16) ) , \ 00028 ((buf)[0] = (uint8_t) (val>>24) ) ) 00029 00030 00031 00032 00033 00034 typedef BLEProtocol::AddressBytes_t tBDAddr; 00035 00036 /* MANUFACTURER_SPECIFIC_DATA */ 00037 extern uint8_t manuf_data[6]; 00038 00039 00040 00041 00042 /* BLE Slave Service exported types */ 00043 typedef struct { 00044 uint8_t data_length; 00045 uint8_t *attribute_value; 00046 tBDAddr devAddr; 00047 uint16_t attribute_handle; 00048 } NotificationData_t; 00049 00050 typedef struct { 00051 uint8_t is_discoverable; 00052 uint8_t is_connected; 00053 uint16_t conn_handle; 00054 uint16_t star_hw_serv_handle; 00055 uint16_t star_data_char_handle; 00056 uint16_t star_config_char_handle; 00057 uint8_t star_data_char_notify; 00058 uint8_t star_config_value[3]; 00059 uint8_t star_config_value_len; 00060 NotificationData_t notification_data; 00061 } SlaveDevice_t; 00062 00063 00064 /* This struct owns the Change_Notification_Status() parameters */ 00065 typedef struct { 00066 uint8_t *att_data; 00067 uint8_t *attr_value; 00068 uint16_t conn_handle; 00069 uint8_t i; 00070 uint32_t feature_mask; 00071 uint8_t frequency; 00072 }ChangeNotificationQueue; 00073 00074 00075 00076 00077 /* ---- BLE Slave Service exported functions ---- */ 00078 /* Set the device as a slave in discoverable mode */ 00079 void setSlaveDiscoverable (void); 00080 00081 /* Stop advertising */ 00082 void stopAdv (void); 00083 00084 /* Sets some notification properties */ 00085 void setNotificationProperty (uint16_t conn_handle, uint8_t i, uint32_t feature_mask, 00086 uint8_t command, uint8_t data); 00087 /* Disable all notifications */ 00088 void disableAllNotifications (void); 00089 00090 /* This function enables or disables the new peripheral scanning */ 00091 void setNewNodesScanning (uint8_t enabled); 00092 00093 /* This function forwards to the peripheral device the command coming from the Cloud */ 00094 void Forward_Command_To_BlueNRG (uint8_t* data_ptr, uint8_t data_length); 00095 00096 /* This function is called when an attribute gets modified */ 00097 void AttributeModified_CB (const GattWriteCallbackParams* param); 00098 00099 /* Notification callbacks */ 00100 void onUpdatesDisabledCallback (Gap::Handle_t handle); 00101 void onUpdatesEnabledCallback (GattAttribute::Handle_t handle); 00102 00103 /* Retrieve the device index from the peripheral device address */ 00104 uint8_t Get_Device_Index_From_Addr (uint8_t *addr); 00105 00106 /* This function is called to Enable/Disable MIC/PRX/AGM/SFusion notifications */ 00107 void Change_Notification_Status (uint8_t *att_data, uint8_t *attr_value, uint16_t conn_handle, uint8_t i, 00108 uint32_t feature_mask, uint8_t frequency); 00109 00110 /* Add all services using a vendor specific UUIDs */ 00111 void addAllServices (void); 00112 00113 /* Forwards to master all notifications from peripherals */ 00114 //void notifyMaster (uint8_t data_length, uint8_t* attribute_value, GattCharacteristic *pCharac); 00115 void notifyMaster (uint8_t data_length, uint8_t* attribute_value, uint16_t attribute_handle); 00116 00117 /* Function used to call Attribute_Modified_CB outside the callback call */ 00118 void createAttribute_Modified_CB_Prototype (uint16_t handle, uint8_t data_length, uint8_t *att_data); 00119 00120 00121 00122 00123 00124 00125 00126 00127 00128 00129 #endif /*__BLESLAVESERVICE_H__*/
Generated on Wed Jul 27 2022 08:13:19 by
1.7.2
