ths.h
Go to the documentation of this file.
1
61 #ifndef _THS_H_
62 #define _THS_H_
63
64 #include "gr55xx_sys.h"
65 #include "custom_config.h"
66 #include <stdint.h>
67
72 #define THS_CONNECTION_MAX (10 < CFG_MAX_CONNECTIONS ?\
73 10 : CFG_MAX_CONNECTIONS)
74 #define THS_MAX_DATA_LEN 512
75 #define THS_SERVICE_UUID 0x1B, 0xD7, 0x90, 0xEC, 0xE8, 0xB9, 0x75, 0x80,\
76 0x0A, 0x46, 0x44, 0xD3, 0x01, 0x03, 0xED, 0xA6
84 typedef enum
85 {
86 THS_SLAVE_NOTIFY_MODE,
87 THS_MASTER_WRITE_MODE,
88 THS_DOUBLE_MODE,
89 } ths_transport_mode_t;
90
92 typedef enum
93 {
94 THS_EVT_INVALID,
95 THS_EVT_DATA_RECEIVED,
96 THS_EVT_DATA_SENT,
97 THS_EVT_SETTINGS_CHANGED,
98 THS_EVT_TOGGLE_SET,
99 } ths_evt_type_t;
100
102 enum ths_toggle_state_t
103 {
104 THS_TOGGLE_STATE_OFF,
105 THS_TOGGLE_STATE_ON,
106 };
107
109 typedef enum
110 {
111 THS_SETTINGS_TYPE_CI,
112 THS_SETTINGS_TYPE_MTU,
113 THS_SETTINGS_TYPE_PDU,
114 THS_SETTINGS_TYPE_PHY,
115 THS_SETTINGS_TYPE_TRANS_MODE,
116 THS_SETTINGS_TYPE_TX_POWER,
117 }ths_settings_type_t;
125 typedef struct
126 {
127 ths_evt_type_t evt_type;
128 ths_settings_type_t setting_type;
129 uint8_t conn_idx;
130 uint8_t *p_data;
131 uint16_t length;
132 } ths_evt_t;
140 typedef void (*ths_evt_handler_t)(ths_evt_t *p_evt);
148 typedef struct
149 {
150 ths_evt_handler_t evt_handler;
151 ths_transport_mode_t transport_mode;
152 } ths_init_t;
168 sdk_err_t ths_service_init(ths_init_t *p_ths_init);
169
181 sdk_err_t ths_data_send(uint8_t conn_idx, uint8_t *p_data, uint16_t length);
182
194 sdk_err_t ths_settings_notify(uint8_t conn_idx, uint8_t *p_settings, uint16_t length);
195
203 ths_transport_mode_t ths_transport_mode_get(void);
206 #endif
207
ths_data_send
sdk_err_t ths_data_send(uint8_t conn_idx, uint8_t *p_data, uint16_t length)
Send data to peer device.
THS_EVT_DATA_RECEIVED
@ THS_EVT_DATA_RECEIVED
Definition: ths.h:95
ths_evt_t::length
uint16_t length
Definition: ths.h:131
ths_service_init
sdk_err_t ths_service_init(ths_init_t *p_ths_init)
Initialize a Throughput Service instance and add in the DB.
THS_SETTINGS_TYPE_CI
@ THS_SETTINGS_TYPE_CI
Definition: ths.h:111
THS_TOGGLE_STATE_ON
@ THS_TOGGLE_STATE_ON
Definition: ths.h:105
ths_init_t::evt_handler
ths_evt_handler_t evt_handler
Definition: ths.h:150
ths_evt_type_t
ths_evt_type_t
Throughput Service event type.
Definition: ths.h:93
THS_TOGGLE_STATE_OFF
@ THS_TOGGLE_STATE_OFF
Definition: ths.h:104
THS_SETTINGS_TYPE_MTU
@ THS_SETTINGS_TYPE_MTU
Definition: ths.h:112
ths_evt_t::evt_type
ths_evt_type_t evt_type
Definition: ths.h:127
THS_EVT_TOGGLE_SET
@ THS_EVT_TOGGLE_SET
Definition: ths.h:98
ths_transport_mode_t
ths_transport_mode_t
Throughput data transport mode.
Definition: ths.h:85
gr55xx_sys.h
GR55XX System API.
THS_SLAVE_NOTIFY_MODE
@ THS_SLAVE_NOTIFY_MODE
Definition: ths.h:86
ths_init_t::transport_mode
ths_transport_mode_t transport_mode
Definition: ths.h:151
THS_EVT_INVALID
@ THS_EVT_INVALID
Definition: ths.h:94
ths_settings_type_t
ths_settings_type_t
Throughput service settings types.
Definition: ths.h:110
ths_evt_t::setting_type
ths_settings_type_t setting_type
Definition: ths.h:128
THS_MASTER_WRITE_MODE
@ THS_MASTER_WRITE_MODE
Definition: ths.h:87
THS_EVT_SETTINGS_CHANGED
@ THS_EVT_SETTINGS_CHANGED
Definition: ths.h:97
ths_evt_t::conn_idx
uint8_t conn_idx
Definition: ths.h:129
THS_SETTINGS_TYPE_PHY
@ THS_SETTINGS_TYPE_PHY
Definition: ths.h:114
THS_DOUBLE_MODE
@ THS_DOUBLE_MODE
Definition: ths.h:88
ths_evt_t
Throughput Service event.
Definition: ths.h:126
ths_evt_t::p_data
uint8_t * p_data
Definition: ths.h:130
ths_transport_mode_get
ths_transport_mode_t ths_transport_mode_get(void)
Get current transport mode of device.
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:243
ths_toggle_state_t
ths_toggle_state_t
Throughput toggle state of sending the data.
Definition: ths.h:103
ths_init_t
Throughput Service init stucture. This contains all option and data needed for initialization of the ...
Definition: ths.h:149
ths_settings_notify
sdk_err_t ths_settings_notify(uint8_t conn_idx, uint8_t *p_settings, uint16_t length)
Notify the peer device of the change of settings.
THS_SETTINGS_TYPE_TX_POWER
@ THS_SETTINGS_TYPE_TX_POWER
Definition: ths.h:116
THS_SETTINGS_TYPE_TRANS_MODE
@ THS_SETTINGS_TYPE_TRANS_MODE
Definition: ths.h:115
THS_EVT_DATA_SENT
@ THS_EVT_DATA_SENT
Definition: ths.h:96
ths_evt_handler_t
void(* ths_evt_handler_t)(ths_evt_t *p_evt)
Throughput Service event handler type.
Definition: ths.h:140
THS_SETTINGS_TYPE_PDU
@ THS_SETTINGS_TYPE_PDU
Definition: ths.h:113