thscps.h
Go to the documentation of this file.
1
57 #ifndef __THSCPS_H__
58 #define __THSCPS_H__
59
60 #include "ble_prf_types.h"
61 #include "gr55xx_sys.h"
62 #include "custom_config.h"
63
68 #define THSCPS_CONNECTION_MAX (10 < CFG_MAX_CONNECTIONS ?\
69 10 : CFG_MAX_CONNECTIONS)
70 #define THSCPS_CTRL_PT_VAL_LEN 20
71 #define THSCPS_TEST_SETTING_VAL_LEN 20
72 #define THSCPS_TEST_INFO_VAL_LEN 20
73 #define THSCPS_CONN_INFO_VAL_LEN 20
74 #define THSCPS_SERVICE_UUID 0x1B, 0xD7, 0x90, 0xEC, 0xE8, 0xB9, 0x75, 0x80,\
75 0x0A, 0x46, 0x44, 0xD3, 0x01, 0x07, 0xED, 0xA6
76 #define THSCPS_ACTION_ON 0x01
77 #define THSCPS_ACTION_OFF 0x00
78 #define THSCPS_CTRL_PT_RSP_CODE 0xff
86 typedef enum
87 {
88 THSCPS_TEST_ROLE_INVALID,
89 THSCPS_TEST_ROLE_SLAVE,
90 THSCPS_TEST_ROLE_MASTER,
91 } thscps_test_role_t;
92
95 typedef enum
96 {
97 THSCPS_LEGACY_ADV_PHY,
98 THSCPS_1MBPS_PHY,
99 THSCPS_CODED_PHY ,
100 } thscps_adv_phy_t;
101
103 typedef enum
104 {
105 THSCPS_TEST_STOP,
106 THSCPS_TEST_STARTED,
107 } thscps_test_state_t;
108
110 typedef enum
111 {
112 THSCPS_CTRL_PT_INVALID,
113 THSCPS_CTRL_PT_TEST_ROLE,
114 THSCPS_CTRL_PT_ADV_PARAM,
115 THSCPS_CTRL_PT_ADV_ACTION,
116 THSCPS_CTRL_PT_SCAN_ACTION,
117 THSCPS_CTRL_PT_TEST_READY,
118 THSCPS_CTRL_PT_SETTING,
119 } thscps_ctrl_pt_id_t;
120
122 typedef enum
123 {
124 THSCPS_SETTINGS_TYPE_CI,
125 THSCPS_SETTINGS_TYPE_MTU,
126 THSCPS_SETTINGS_TYPE_PDU,
127 THSCPS_SETTINGS_TYPE_PHY,
128 THSCPS_SETTINGS_TYPE_TRANS_MODE,
129 THSCPS_SETTINGS_TYPE_TX_POWER,
130 THSCPS_SETTINGS_TYPE_TOGGLE,
131 }thscps_settings_type_t;
132
134 typedef enum
135 {
136 THSCPS_RSP_ID_SUCCESS,
137 THSCPS_RSP_ID_UNSUPPORT,
138 THSCPS_RSP_ID_STATUS_ERR,
139 THSCPS_RSP_ID_PARAM_ERR,
140 THSCPS_RSP_ID_TEST_ROLE_ERR,
141 THSCPS_RSP_ID_SDK_ERR,
142 } thscps_status_rsp_t;
143
145 typedef enum
146 {
147 THSCPS_EVT_INVALID,
148 THSCPS_EVT_CTRL_PT_IND_ENABLE,
149 THSCPS_EVT_CTRL_PT_IND_DISABLE,
150 THSCPS_EVT_TSET_SET_NTF_ENABLE,
151 THSCPS_EVT_TSET_SET_NTF_DISABLE,
152 THSCPS_EVT_TSET_INFO_NTF_ENABLE,
153 THSCPS_EVT_TSET_INFO_NTF_DISABLE,
154 THSCPS_EVT_CONN_INFO_NTF_ENABLE,
155 THSCPS_EVT_CONN_INFO_NTF_DISABLE,
156 THSCPS_EVT_TEST_ROLE_SET,
157 THSCPS_EVT_ADV_PRAM_SET,
158 THSCPS_EVT_ADV_ACTION,
159 THSCPS_EVT_SCAN_ACTION,
160 THSCPS_EVT_SETTING_SET,
161 } thscps_evt_type_t;
169 typedef struct
170 {
171 uint16_t length;
172 const uint8_t *p_data;
173 } thscps_setting_t;
174
176 typedef struct
177 {
178 int8_t rssi;
179 uint8_t right_rate;
180 uint16_t instant_val;
181 uint16_t average_val;
182 uint16_t packets_val;
183 } thscps_test_info_t;
184
186 typedef struct
187 {
188 uint16_t ci;
189 uint16_t pdu;
190 uint16_t mtu;
191 uint8_t tx_phy;
192 uint8_t rx_phy;
193 int8_t tx_power;
194 uint8_t ths_mode;
195 } thscps_test_conn_info_t;
196
198 typedef struct
199 {
200 thscps_adv_phy_t phy;
201 uint16_t interval;
202 uint16_t duration;
203 int8_t tx_power;
204 } thscps_adv_param_t;
205
207 typedef struct
208 {
209 uint8_t cmd_id;
210 thscps_status_rsp_t status;
211 uint8_t conn_idx;
212 } thscps_rsp_val_t;
213
215 typedef struct
216 {
217 uint8_t conn_idx;
218 thscps_evt_type_t evt_type;
219 union
220 {
221 uint8_t action_set;
222 thscps_test_role_t test_role;
223 thscps_adv_param_t adv_param;
224 thscps_setting_t setting_info;
225 } param;
226 } thscps_evt_t;
234 typedef void (*thscps_evt_handler_t)(thscps_evt_t *p_evt);
250 sdk_err_t thscps_service_init(thscps_evt_handler_t evt_handler);
251
262 sdk_err_t thscps_ctrl_pt_rsp_send(uint8_t conn_idx, thscps_rsp_val_t *p_rsp_val);
263
274 sdk_err_t thscps_test_setting_rsp_send(uint8_t conn_idx, thscps_rsp_val_t *p_rsp_val);
275
286 sdk_err_t thscps_test_info_send(uint8_t conn_idx, thscps_test_info_t *p_test_info);
287
298 sdk_err_t thscps_conn_info_send(uint8_t conn_idx, thscps_test_conn_info_t *p_conn_info);
299
307 void thscps_test_state_set(thscps_test_state_t test_state);
309 #endif
310
THSCPS_EVT_CTRL_PT_IND_ENABLE
@ THSCPS_EVT_CTRL_PT_IND_ENABLE
Definition: thscps.h:148
thscps_evt_t::setting_info
thscps_setting_t setting_info
Definition: thscps.h:224
thscps_conn_info_send
sdk_err_t thscps_conn_info_send(uint8_t conn_idx, thscps_test_conn_info_t *p_conn_info)
Send Throughput Test Connect Information if its notification has been enabled.
thscps_adv_param_t::tx_power
int8_t tx_power
Definition: thscps.h:203
thscps_adv_param_t::duration
uint16_t duration
Definition: thscps.h:202
THSCPS_TEST_ROLE_MASTER
@ THSCPS_TEST_ROLE_MASTER
Definition: thscps.h:90
thscps_service_init
sdk_err_t thscps_service_init(thscps_evt_handler_t evt_handler)
Initialize a THS Control Point Service instance and add in the DB.
THSCPS_LEGACY_ADV_PHY
@ THSCPS_LEGACY_ADV_PHY
Definition: thscps.h:97
thscps_adv_phy_t
thscps_adv_phy_t
Specify PHY.
Definition: thscps.h:96
thscps_setting_t::p_data
const uint8_t * p_data
Definition: thscps.h:172
THSCPS_EVT_TSET_INFO_NTF_ENABLE
@ THSCPS_EVT_TSET_INFO_NTF_ENABLE
Definition: thscps.h:152
thscps_test_info_t::right_rate
uint8_t right_rate
Definition: thscps.h:179
thscps_adv_param_t::interval
uint16_t interval
Definition: thscps.h:201
thscps_evt_t
THS Control Point Service event.
Definition: thscps.h:216
THSCPS_SETTINGS_TYPE_PHY
@ THSCPS_SETTINGS_TYPE_PHY
Definition: thscps.h:127
THSCPS_CTRL_PT_SCAN_ACTION
@ THSCPS_CTRL_PT_SCAN_ACTION
Definition: thscps.h:116
thscps_test_state_t
thscps_test_state_t
Throughput Test State.
Definition: thscps.h:104
thscps_test_setting_rsp_send
sdk_err_t thscps_test_setting_rsp_send(uint8_t conn_idx, thscps_rsp_val_t *p_rsp_val)
Send Settings Response if its notification has been enabled.
thscps_test_conn_info_t::ci
uint16_t ci
Definition: thscps.h:188
THSCPS_EVT_TSET_SET_NTF_DISABLE
@ THSCPS_EVT_TSET_SET_NTF_DISABLE
Definition: thscps.h:151
thscps_evt_t::test_role
thscps_test_role_t test_role
Definition: thscps.h:222
thscps_test_conn_info_t
THS connect Information value.
Definition: thscps.h:187
thscps_evt_t::adv_param
thscps_adv_param_t adv_param
Definition: thscps.h:223
thscps_ctrl_pt_rsp_send
sdk_err_t thscps_ctrl_pt_rsp_send(uint8_t conn_idx, thscps_rsp_val_t *p_rsp_val)
Send Control Point Response if its indicaiton has been enabled.
THSCPS_1MBPS_PHY
@ THSCPS_1MBPS_PHY
Definition: thscps.h:98
thscps_test_state_set
void thscps_test_state_set(thscps_test_state_t test_state)
Set throughput state set.
thscps_test_info_t::rssi
int8_t rssi
Definition: thscps.h:178
THSCPS_EVT_TEST_ROLE_SET
@ THSCPS_EVT_TEST_ROLE_SET
Definition: thscps.h:156
gr55xx_sys.h
GR55XX System API.
thscps_rsp_val_t::status
thscps_status_rsp_t status
Definition: thscps.h:210
THSCPS_EVT_ADV_PRAM_SET
@ THSCPS_EVT_ADV_PRAM_SET
Definition: thscps.h:157
THSCPS_RSP_ID_SDK_ERR
@ THSCPS_RSP_ID_SDK_ERR
Definition: thscps.h:141
thscps_status_rsp_t
thscps_status_rsp_t
THS Control Point Response Types.
Definition: thscps.h:135
THSCPS_SETTINGS_TYPE_PDU
@ THSCPS_SETTINGS_TYPE_PDU
Definition: thscps.h:126
thscps_adv_param_t
THS Control Point Advertising Parameters.
Definition: thscps.h:199
THSCPS_SETTINGS_TYPE_TX_POWER
@ THSCPS_SETTINGS_TYPE_TX_POWER
Definition: thscps.h:129
thscps_test_info_send
sdk_err_t thscps_test_info_send(uint8_t conn_idx, thscps_test_info_t *p_test_info)
Send Throughput Test Information if its notification has been enabled.
thscps_test_info_t
THS Test Information value.
Definition: thscps.h:177
thscps_setting_t::length
uint16_t length
Definition: thscps.h:171
thscps_test_info_t::average_val
uint16_t average_val
Definition: thscps.h:181
THSCPS_RSP_ID_STATUS_ERR
@ THSCPS_RSP_ID_STATUS_ERR
Definition: thscps.h:138
THSCPS_RSP_ID_PARAM_ERR
@ THSCPS_RSP_ID_PARAM_ERR
Definition: thscps.h:139
thscps_evt_t::action_set
uint8_t action_set
Definition: thscps.h:221
THSCPS_SETTINGS_TYPE_CI
@ THSCPS_SETTINGS_TYPE_CI
Definition: thscps.h:124
thscps_test_info_t::instant_val
uint16_t instant_val
Definition: thscps.h:180
THSCPS_CTRL_PT_TEST_READY
@ THSCPS_CTRL_PT_TEST_READY
Definition: thscps.h:117
THSCPS_RSP_ID_SUCCESS
@ THSCPS_RSP_ID_SUCCESS
Definition: thscps.h:136
THSCPS_EVT_SCAN_ACTION
@ THSCPS_EVT_SCAN_ACTION
Definition: thscps.h:159
thscps_test_conn_info_t::mtu
uint16_t mtu
Definition: thscps.h:190
thscps_setting_t
THS Setting Information value.
Definition: thscps.h:170
ble_prf_types.h
Profile/Service Common Types.
THSCPS_CTRL_PT_TEST_ROLE
@ THSCPS_CTRL_PT_TEST_ROLE
Definition: thscps.h:113
THSCPS_EVT_TSET_INFO_NTF_DISABLE
@ THSCPS_EVT_TSET_INFO_NTF_DISABLE
Definition: thscps.h:153
thscps_settings_type_t
thscps_settings_type_t
Throughput service settings types.
Definition: thscps.h:123
THSCPS_EVT_CONN_INFO_NTF_ENABLE
@ THSCPS_EVT_CONN_INFO_NTF_ENABLE
Definition: thscps.h:154
THSCPS_CODED_PHY
@ THSCPS_CODED_PHY
Definition: thscps.h:99
thscps_evt_type_t
thscps_evt_type_t
THS Control Point Service Event Type.
Definition: thscps.h:146
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:243
thscps_test_role_t
thscps_test_role_t
Local device GAP Role Type.
Definition: thscps.h:87
THSCPS_EVT_SETTING_SET
@ THSCPS_EVT_SETTING_SET
Definition: thscps.h:160
THSCPS_RSP_ID_UNSUPPORT
@ THSCPS_RSP_ID_UNSUPPORT
Definition: thscps.h:137
thscps_test_conn_info_t::ths_mode
uint8_t ths_mode
Definition: thscps.h:194
thscps_adv_param_t::phy
thscps_adv_phy_t phy
Definition: thscps.h:200
thscps_test_conn_info_t::rx_phy
uint8_t rx_phy
Definition: thscps.h:192
THSCPS_EVT_CTRL_PT_IND_DISABLE
@ THSCPS_EVT_CTRL_PT_IND_DISABLE
Definition: thscps.h:149
THSCPS_RSP_ID_TEST_ROLE_ERR
@ THSCPS_RSP_ID_TEST_ROLE_ERR
Definition: thscps.h:140
THSCPS_CTRL_PT_ADV_PARAM
@ THSCPS_CTRL_PT_ADV_PARAM
Definition: thscps.h:114
THSCPS_SETTINGS_TYPE_TRANS_MODE
@ THSCPS_SETTINGS_TYPE_TRANS_MODE
Definition: thscps.h:128
thscps_test_conn_info_t::tx_phy
uint8_t tx_phy
Definition: thscps.h:191
thscps_test_conn_info_t::tx_power
int8_t tx_power
Definition: thscps.h:193
thscps_rsp_val_t::conn_idx
uint8_t conn_idx
Definition: thscps.h:211
thscps_ctrl_pt_id_t
thscps_ctrl_pt_id_t
THS Control Point Service Control Point IDs.
Definition: thscps.h:111
THSCPS_EVT_TSET_SET_NTF_ENABLE
@ THSCPS_EVT_TSET_SET_NTF_ENABLE
Definition: thscps.h:150
THSCPS_CTRL_PT_INVALID
@ THSCPS_CTRL_PT_INVALID
Definition: thscps.h:112
thscps_evt_t::evt_type
thscps_evt_type_t evt_type
Definition: thscps.h:218
THSCPS_TEST_STOP
@ THSCPS_TEST_STOP
Definition: thscps.h:105
thscps_evt_handler_t
void(* thscps_evt_handler_t)(thscps_evt_t *p_evt)
THS Control Point Service event handler type.
Definition: thscps.h:234
thscps_evt_t::conn_idx
uint8_t conn_idx
Definition: thscps.h:217
THSCPS_SETTINGS_TYPE_TOGGLE
@ THSCPS_SETTINGS_TYPE_TOGGLE
Definition: thscps.h:130
THSCPS_SETTINGS_TYPE_MTU
@ THSCPS_SETTINGS_TYPE_MTU
Definition: thscps.h:125
THSCPS_TEST_ROLE_SLAVE
@ THSCPS_TEST_ROLE_SLAVE
Definition: thscps.h:89
thscps_test_conn_info_t::pdu
uint16_t pdu
Definition: thscps.h:189
THSCPS_EVT_CONN_INFO_NTF_DISABLE
@ THSCPS_EVT_CONN_INFO_NTF_DISABLE
Definition: thscps.h:155
THSCPS_CTRL_PT_ADV_ACTION
@ THSCPS_CTRL_PT_ADV_ACTION
Definition: thscps.h:115
thscps_rsp_val_t
THS Control Point Response value.
Definition: thscps.h:208
thscps_test_info_t::packets_val
uint16_t packets_val
Definition: thscps.h:182
THSCPS_EVT_INVALID
@ THSCPS_EVT_INVALID
Definition: thscps.h:147
thscps_rsp_val_t::cmd_id
uint8_t cmd_id
Definition: thscps.h:209
THSCPS_EVT_ADV_ACTION
@ THSCPS_EVT_ADV_ACTION
Definition: thscps.h:158
THSCPS_TEST_ROLE_INVALID
@ THSCPS_TEST_ROLE_INVALID
Definition: thscps.h:88
THSCPS_TEST_STARTED
@ THSCPS_TEST_STARTED
Definition: thscps.h:106