马上注册,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册 
×
在BLE client中有一个赋值,有些看不明白。
- SERVICE_FUNC_POINTERS_T BatteryServiceFuncStore = {
- .serviceUuid = &BatteryServiceUuid,
- .isMandatory = NULL,
- .serviceInit = &BatteryServiceDataInit,
- .checkHandle = &BatteryServiceCheckHandle,
- .getHandles = &BatteryServiceGetHandles,
- .charDiscovered = &BatteryServiceCharDiscovered,
- .descDiscovered = &BatteryServiceCharDescDisc,
- .discoveryComplete = &BatteryServiceDiscoveryComplete,
- .serviceIndNotifHandler = &BatteryServiceHandlerNotifInd,
- .configureServiceNotif = &BatteryServiceConfigNotif,
- .writeRequest = NULL,
- .writeConfirm = &BatteryServiceWriteConfirm,
- .readRequest = &BatteryServiceReadRequest,
- .readConfirm = &BatteryServiceReadConfirm,
- .configureService = &BatteryServiceConfigure,
- .isServiceFound = &BatteryServiceFound,
- .resetServiceData = &BatteryServiceResetData
- };
复制代码 该数据类型定义如下,是一个结构体,成员都是函数指针:
- /* Service callbacks */
- typedef struct _SERVICE_FUNC_POINTERS_T
- {
- /* Returns the service UUID and its type (16-bit or 128-bit) */
- void (*serviceUuid)(GATT_UUID_T *type, uint16 *uuid);
- /* Returns TRUE if the service is mandatory */
- bool (*isMandatory)(void);
- /* Initialise service data */
- void (*serviceInit)(uint16 dev_num,
- GATT_DISC_PRIM_SERV_BY_UUID_IND_T *p_event_data);
- /* Returns TRUE if the handle is supported by the service */
- bool (*checkHandle)(uint16 dev_num, uint16 handle);
-
- /* Get the start and end handle for the service or characteristic */
- bool (*getHandles)(uint16 dev_num,
- uint16 *StartHandle,
- uint16 *EndHandle,
- gatt_profile_hierarchy_t type);
- /* Called for each discovered characteristic */
- bool (*charDiscovered)(uint16 dev_num,
- GATT_CHAR_DECL_INFO_IND_T *p_event_data);
- /* Called for each discovered characteristic descriptor. This function must
- * only be called after first calling charDiscovered.
- */
- void (*descDiscovered)(uint16 dev_num,
- GATT_CHAR_DESC_INFO_IND_T *p_event_data);
- /* Called when the Discovery Procedure is complete for the current server.
- * Returns TRUE if the callback starts a read or write, otherwise FALSE
- */
- bool (*discoveryComplete)(uint16 dev_num,
- uint16 connect_handle);
- /* Configure notifications for a given characteristic by writing to the
- * Client Characteristic Configuration Descriptor. Returns TRUE, if
- * successful, otherwise FALSE
- */
- bool (*configureServiceNotif)(uint16 dev_num,
- uint16 type,
- uint8 sub_type,
- bool enable);
- /* Callback for handling indications and notifications */
- bool (*serviceIndNotifHandler)(uint16 dev_num,
- uint16 handle,
- uint16 size,
- uint8 *value);
- /* Callback to modify the value of a characteristic on the peer device */
- bool (*writeRequest)(uint16 dev_num,
- uint16 type,
- uint8 *data,
- uint16 size);
- /* Function called after a characteristic value has been successfully
- * written
- */
- void (*writeConfirm)(uint16 dev_num,
- uint16 connect_handle);
- /* Callback to read the value of a characteristic on the peer device */
- bool (*readRequest)(uint16 dev_num, uint16 type);
- /* Function called when a characteristic value has been successfully read */
- void (*readConfirm)(uint16 dev_num,
- uint16 size,
- uint8 *value);
- /* Configure the service to request notifications or indications */
- bool (*configureService)(uint16 dev_num);
- /* Check if the service is present on the specified device */
- bool (*isServiceFound)(uint16 dev_num);
-
- /* Reset the service data */
- void (*resetServiceData)(uint16 dev_num);
- } SERVICE_FUNC_POINTERS_T;
复制代码 结构体赋初值不应该是如下这样吗?
- SERVICE_FUNC_POINTERS_T BatteryServiceFuncStore = {
- &BatteryServiceUuid,
- NULL,
- &BatteryServiceDataInit,
- &BatteryServiceCheckHandle,
- &BatteryServiceGetHandles,
- &BatteryServiceCharDiscovered,
- &BatteryServiceCharDescDisc,
- &BatteryServiceDiscoveryComplete,
- &BatteryServiceHandlerNotifInd,
- &BatteryServiceConfigNotif,
- NULL,
- &BatteryServiceWriteConfirm,
- &BatteryServiceReadRequest,
- &BatteryServiceReadConfirm,
- &BatteryServiceConfigure,
- &BatteryServiceFound,
- &BatteryServiceResetData
- };
复制代码 例程中,成员前加一个.然后再=,这种赋值法在C里边没有见过啊,而且放到标准的C编译器里也编译不过。是SDK支持的特殊语法吗?
|