ths_c.h
Go to the documentation of this file.
1
58 #ifndef __THS_C_H__
59 #define __THS_C_H__
60
61 #include "ble_prf_types.h"
62 #include "gr55xx_sys.h"
63 #include "custom_config.h"
64 #include <stdint.h>
65 #include <stdbool.h>
66
76 #define THS_C_CONNECTION_MAX (10 < CFG_MAX_CONNECTIONS ?\
77 10 : CFG_MAX_CONNECTIONS)
78 #define THS_SVC_UUID {0x1B, 0xD7, 0x90, 0xEC, 0xE8, 0xB9, 0x75, 0x80,\
79 0x0A, 0x46, 0x44, 0xD3, 0x01, 0x03, 0xED, 0xA6}
80 #define THS_TX_CHAR_UUID {0x1B, 0xD7, 0x90, 0xEC, 0xE8, 0xB9, 0x75, 0x80,\
81 0x0A, 0x46, 0x44, 0xD3, 0x02, 0x03, 0xED, 0xA6}
82 #define THS_RX_CHAR_UUID {0x1B, 0xD7, 0x90, 0xEC, 0xE8, 0xB9, 0x75, 0x80,\
83 0x0A, 0x46, 0x44, 0xD3, 0x03, 0x03, 0xED, 0xA6}
84 #define THS_SETTING_CHAR_UUID {0x1B, 0xD7, 0x90, 0xEC, 0xE8, 0xB9, 0x75, 0x80,\
85 0x0A, 0x46, 0x44, 0xD3, 0x04, 0x03, 0xED, 0xA6}
86 #define THS_TOGGLE_CHAR_UUID {0x1B, 0xD7, 0x90, 0xEC, 0xE8, 0xB9, 0x75, 0x80,\
87 0x0A, 0x46, 0x44, 0xD3, 0x05, 0x03, 0xED, 0xA6}
96 typedef enum
97 {
98 THS_C_SLAVE_NOTIFY_MODE,
99 THS_C_MASTER_WRITE_MODE,
100 THS_C_DOUBLE_MODE,
101 } ths_c_transport_mode_t;
102
104 typedef enum
105 {
106 THS_C_SETTINGS_TYPE_CI,
107 THS_C_SETTINGS_TYPE_MTU,
108 THS_C_SETTINGS_TYPE_PDU,
109 THS_C_SETTINGS_TYPE_PHY,
110 THS_C_SETTINGS_TYPE_TRANS_MODE,
111 THS_C_SETTINGS_TYPE_TX_POWER,
112 } ths_c_settings_type_t;
113
115 typedef enum
116 {
117 THS_C_EVT_INVALID,
118 THS_C_EVT_DISCOVERY_COMPLETE,
119 THS_C_EVT_DISCOVERY_FAIL,
120 THS_C_EVT_TX_NTF_SET_SUCCESS,
121 THS_C_EVT_SETTING_NTF_SET_SUCCESS,
122 THS_C_EVT_TOGGLE_SET_SUCCESS,
123 THS_C_EVT_SETTING_RSP_RECEIVE,
124 THS_C_EVT_THRP_DATA_RECEIVE,
125 THS_C_EVT_TX_SUCCESS,
126 THS_C_EVT_PARAM_SET_SUCCESS,
127 THS_C_EVT_WRITE_OP_ERR,
128 } ths_c_evt_type_t;
136 typedef struct
137 {
138 uint16_t ths_srvc_start_handle;
139 uint16_t ths_srvc_end_handle;
140 uint16_t ths_tx_handle;
141 uint16_t ths_tx_cccd_handle;
142 uint16_t ths_rx_handle;
143 uint16_t ths_setting_handle;
144 uint16_t ths_setting_cccd_handle;
145 uint16_t ths_toggle_handle;
146 } ths_c_handles_t;
147
149 typedef struct
150 {
151 uint8_t conn_idx;
152 ths_c_evt_type_t evt_type;
153 uint8_t *p_data;
154 uint16_t length;
155 } ths_c_evt_t;
163 typedef void (*ths_c_evt_handler_t)(ths_c_evt_t *p_evt);
179 sdk_err_t ths_client_init(ths_c_evt_handler_t evt_handler);
180
190 sdk_err_t ths_c_disc_srvc_start(uint8_t conn_idx);
191
202 sdk_err_t ths_c_tx_notify_set(uint8_t conn_idx, bool is_enable);
203
214 sdk_err_t ths_c_setting_notify_set(uint8_t conn_idx, bool is_enable);
215
227 sdk_err_t ths_c_comm_param_send(uint8_t conn_idx, uint8_t *p_data, uint16_t length);
228
239 sdk_err_t ths_c_toggle_set(uint8_t conn_idx, bool is_enable);
240
252 sdk_err_t ths_c_tx_data_send(uint8_t conn_idx, uint8_t *p_data, uint16_t length);
254 #endif
255
THS_C_EVT_SETTING_NTF_SET_SUCCESS
@ THS_C_EVT_SETTING_NTF_SET_SUCCESS
Definition: ths_c.h:121
THS_C_EVT_PARAM_SET_SUCCESS
@ THS_C_EVT_PARAM_SET_SUCCESS
Definition: ths_c.h:126
ths_c_evt_t::length
uint16_t length
Definition: ths_c.h:154
ths_c_evt_t::conn_idx
uint8_t conn_idx
Definition: ths_c.h:151
ths_c_handles_t::ths_srvc_start_handle
uint16_t ths_srvc_start_handle
Definition: ths_c.h:138
ths_c_handles_t
Handles on the connected peer device needed to interact with it.
Definition: ths_c.h:137
ths_c_evt_t::evt_type
ths_c_evt_type_t evt_type
Definition: ths_c.h:152
THS_C_EVT_TOGGLE_SET_SUCCESS
@ THS_C_EVT_TOGGLE_SET_SUCCESS
Definition: ths_c.h:122
THS_C_SETTINGS_TYPE_TX_POWER
@ THS_C_SETTINGS_TYPE_TX_POWER
Definition: ths_c.h:111
THS_C_SETTINGS_TYPE_MTU
@ THS_C_SETTINGS_TYPE_MTU
Definition: ths_c.h:107
THS_C_SETTINGS_TYPE_TRANS_MODE
@ THS_C_SETTINGS_TYPE_TRANS_MODE
Definition: ths_c.h:110
ths_c_setting_notify_set
sdk_err_t ths_c_setting_notify_set(uint8_t conn_idx, bool is_enable)
Enable or disable peer THS setting characteristic notify.
THS_C_EVT_INVALID
@ THS_C_EVT_INVALID
Definition: ths_c.h:117
THS_C_EVT_DISCOVERY_COMPLETE
@ THS_C_EVT_DISCOVERY_COMPLETE
Definition: ths_c.h:118
ths_c_evt_handler_t
void(* ths_c_evt_handler_t)(ths_c_evt_t *p_evt)
Throughput Service Client event handler type.
Definition: ths_c.h:163
gr55xx_sys.h
GR55XX System API.
THS_C_EVT_TX_SUCCESS
@ THS_C_EVT_TX_SUCCESS
Definition: ths_c.h:125
ths_c_handles_t::ths_rx_handle
uint16_t ths_rx_handle
Definition: ths_c.h:142
THS_C_EVT_SETTING_RSP_RECEIVE
@ THS_C_EVT_SETTING_RSP_RECEIVE
Definition: ths_c.h:123
ths_c_evt_t
Throughput Service Client event.
Definition: ths_c.h:150
ths_c_handles_t::ths_setting_handle
uint16_t ths_setting_handle
Definition: ths_c.h:143
ths_client_init
sdk_err_t ths_client_init(ths_c_evt_handler_t evt_handler)
Register THS Client event handler.
ths_c_handles_t::ths_srvc_end_handle
uint16_t ths_srvc_end_handle
Definition: ths_c.h:139
ths_c_handles_t::ths_tx_cccd_handle
uint16_t ths_tx_cccd_handle
Definition: ths_c.h:141
ths_c_evt_t::p_data
uint8_t * p_data
Definition: ths_c.h:153
ths_c_evt_type_t
ths_c_evt_type_t
Throughput Service Client event type.
Definition: ths_c.h:116
ths_c_handles_t::ths_setting_cccd_handle
uint16_t ths_setting_cccd_handle
Definition: ths_c.h:144
ths_c_handles_t::ths_toggle_handle
uint16_t ths_toggle_handle
Definition: ths_c.h:145
THS_C_EVT_THRP_DATA_RECEIVE
@ THS_C_EVT_THRP_DATA_RECEIVE
Definition: ths_c.h:124
ble_prf_types.h
Profile/Service Common Types.
ths_c_comm_param_send
sdk_err_t ths_c_comm_param_send(uint8_t conn_idx, uint8_t *p_data, uint16_t length)
Send communication parameter to peer.
THS_C_SETTINGS_TYPE_PHY
@ THS_C_SETTINGS_TYPE_PHY
Definition: ths_c.h:109
THS_C_EVT_DISCOVERY_FAIL
@ THS_C_EVT_DISCOVERY_FAIL
Definition: ths_c.h:119
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:243
THS_C_SETTINGS_TYPE_PDU
@ THS_C_SETTINGS_TYPE_PDU
Definition: ths_c.h:108
THS_C_DOUBLE_MODE
@ THS_C_DOUBLE_MODE
Definition: ths_c.h:100
THS_C_MASTER_WRITE_MODE
@ THS_C_MASTER_WRITE_MODE
Definition: ths_c.h:99
ths_c_disc_srvc_start
sdk_err_t ths_c_disc_srvc_start(uint8_t conn_idx)
Discovery THS on peer.
ths_c_transport_mode_t
ths_c_transport_mode_t
Throughput Service Client data transport mode.
Definition: ths_c.h:97
ths_c_toggle_set
sdk_err_t ths_c_toggle_set(uint8_t conn_idx, bool is_enable)
Set Throughput service toggle state of sending the data.
ths_c_handles_t::ths_tx_handle
uint16_t ths_tx_handle
Definition: ths_c.h:140
THS_C_EVT_WRITE_OP_ERR
@ THS_C_EVT_WRITE_OP_ERR
Definition: ths_c.h:127
THS_C_SETTINGS_TYPE_CI
@ THS_C_SETTINGS_TYPE_CI
Definition: ths_c.h:106
ths_c_tx_data_send
sdk_err_t ths_c_tx_data_send(uint8_t conn_idx, uint8_t *p_data, uint16_t length)
Send data to peer.
ths_c_tx_notify_set
sdk_err_t ths_c_tx_notify_set(uint8_t conn_idx, bool is_enable)
Enable or disable peer THS Tx characteristic notify.
ths_c_settings_type_t
ths_c_settings_type_t
Throughput service settings types.
Definition: ths_c.h:105
THS_C_EVT_TX_NTF_SET_SUCCESS
@ THS_C_EVT_TX_NTF_SET_SUCCESS
Definition: ths_c.h:120