Smart Remote 3 nRF52 v1.2
m_coms_ble.h
1 /*$$$LICENCE_NORDIC_STANDARD<2016>$$$*/
2 
11 #ifndef __M_COMS_BLE_H__
12 #define __M_COMS_BLE_H__
13 
14 #include <stdbool.h>
15 #include <stdint.h>
16 
17 #include "app_scheduler.h"
18 #include "app_util.h"
19 #include "ble_types.h"
20 #include "ble_hids.h"
21 #include "ble_gap.h"
22 #include "ble_gatts.h"
23 #include "peer_manager.h"
24 
25 struct ble_hid_db_s;
26 
27 #define BOOT_KEYBOARD_LEN 8
30 typedef enum
31 {
49 
51 typedef struct
52 {
53  uint8_t interface_idx;
54  uint8_t report_type;
55  uint8_t report_idx;
56  uint8_t len;
57  uint8_t * data;
59 
61 typedef struct
62 {
63  uint8_t interface_idx;
64  uint8_t report_idx;
66 
68 typedef struct
69 {
70  uint16_t min_conn_interval;
71  uint16_t max_conn_interval;
72  uint16_t slave_latency;
75 
77 typedef struct
78 {
79  uint8_t level;
80  uint16_t conn_handle;
82 
84 typedef struct
85 {
86  uint8_t count;
88 
90 typedef struct
91 {
92  uint8_t effective_mtu;
94 
96 typedef struct
97 {
98  uint16_t conn_handle;
99  pm_peer_id_t peer_id;
101 
103 typedef struct
104 {
105  pm_peer_id_t peer_id;
107 
109 typedef struct
110 {
112  union
113  {
114  m_coms_ble_evt_data_recv_t data_received;
115  m_coms_ble_evt_read_req_t read_req;
116  m_coms_ble_evt_conn_update_t conn_update;
118  m_coms_ble_evt_tx_complete_t tx_complete;
119  m_coms_ble_evt_mtu_changed_t mtu_changed;
120  m_coms_ble_evt_conn_data_t conn_data;
121  m_coms_ble_evt_adv_data_t adv_data;
122  } data;
124 
129 typedef enum
130 {
135 
137 typedef enum
138 {
139  hid_report_type_input = BLE_HIDS_REP_TYPE_INPUT,
140  hid_report_type_output = BLE_HIDS_REP_TYPE_OUTPUT,
141  hid_report_type_feature = BLE_HIDS_REP_TYPE_FEATURE
143 
147 typedef union
148 {
149  struct
150  {
151  uint8_t keys[BOOT_KEYBOARD_LEN];
152  } keyboard_data;
153  struct
154  {
155  uint8_t buttons;
156  int8_t x_delta;
157  int8_t y_delta;
158  } mouse_data;
160 
174  m_coms_ble_hid_boot_type_t * p_pkt_type,
175  const uint8_t * p_data,
176  uint8_t p_len,
177  uint8_t p_hid_interface,
178  uint8_t p_report_idx);
179 
181 typedef struct
182 {
183  uint16_t interval;
184  uint16_t timeout;
186 
188 typedef struct
189 {
190  bool directed_adv;
198 
200 typedef struct
201 {
202  uint8_t io_capabilities;
204 
210 typedef struct
211 {
212  char * device_name;
214  char * hw_revision;
215  char * fw_revision;
216  char * serial_number;
217  uint16_t pnp_vendor_id;
219  uint16_t pnp_product_id;
222 
224 typedef struct
225 {
230  uint16_t appearance;
231  ble_gap_conn_params_t conn_params;
233  uint16_t base_hid_version;
235  uint8_t hids_flags;
240 
257 ret_code_t m_coms_ble_init(const m_coms_ble_params_t * p_ble_params,
258  const struct ble_hid_db_s * p_hid_db,
259  bool delete_bonds);
260 
271 ret_code_t m_coms_ble_oobkey_set(uint8_t * p_key);
272 
284 ret_code_t m_coms_ble_bonding_start(void);
285 
300 ret_code_t m_coms_ble_hid_report_send(uint8_t * p_data,
301  uint8_t p_len,
302  uint8_t p_hid_interface,
303  uint8_t p_report_idx);
304 
314 ret_code_t m_coms_ble_read_respond(uint8_t *p_data, uint8_t p_len);
315 
323 ret_code_t m_coms_ble_battery_level_update(uint8_t p_batt_level);
324 
333 ret_code_t m_coms_ble_disconnect(void);
334 
342 ret_code_t m_coms_ble_shutdown(void);
343 
350 bool m_coms_ble_bond_stored(void);
351 
357 ret_code_t m_coms_ble_bond_clear(void);
358 
365 ret_code_t m_coms_ble_advertise(bool bondable);
366 
370 ret_code_t m_coms_ble_sl_disable(void);
371 
375 ret_code_t m_coms_ble_sl_enable(void);
376 
377 #endif /* __M_COMS_BLE_H__ */
378 

Documentation feedback | Developer Zone | Subscribe | Updated