nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
hogp.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef BT_HOGP_H_
8#define BT_HOGP_H_
9
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21#include <zephyr/bluetooth/gatt.h>
22#include <zephyr/bluetooth/conn.h>
23#include <bluetooth/gatt_dm.h>
25
26struct bt_hogp;
27struct bt_hogp_rep_info;
28
46typedef uint8_t (*bt_hogp_read_cb)(struct bt_hogp *hogp,
47 struct bt_hogp_rep_info *rep,
48 uint8_t err,
49 const uint8_t *data);
50
58typedef void (*bt_hogp_write_cb)(struct bt_hogp *hogp,
59 struct bt_hogp_rep_info *rep,
60 uint8_t err);
61
73typedef void (*bt_hogp_ready_cb)(struct bt_hogp *hogp);
74
89typedef void (*bt_hogp_prep_fail_cb)(struct bt_hogp *hogp,
90 int err);
91
103typedef void (*bt_hogp_map_cb)(struct bt_hogp *hogp, uint8_t err,
104 const uint8_t *data, size_t size, size_t offset);
105
113typedef void (*bt_hogp_pm_update_cb)(struct bt_hogp *hogp);
114
134};
135
143struct bt_hogp_rep_info;
144
154struct bt_hogp {
156 struct bt_conn *conn;
162 uint16_t pm;
164 uint16_t rep_map;
166 uint16_t info;
168 uint16_t cp;
194 struct bt_gatt_read_params read_params;
201 struct k_sem read_params_sem;
202
203 struct {
209 uint8_t rep_idx;
211
212 struct {
218 struct bt_hogp_rep_info *kbd_inp;
223 struct bt_hogp_rep_info *kbd_out;
225 struct bt_hogp_rep_info *mouse_inp;
228 struct bt_hogp_rep_info **rep_info;
230 uint8_t rep_count;
232 bool ready;
235};
236
249void bt_hogp_init(struct bt_hogp *hogp,
250 const struct bt_hogp_init_params *params);
251
274int bt_hogp_handles_assign(struct bt_gatt_dm *dm, struct bt_hogp *hogp);
275
290void bt_hogp_release(struct bt_hogp *hogp);
291
306void bt_hogp_abort_all(struct bt_hogp *hogp);
307
316bool bt_hogp_assign_check(const struct bt_hogp *hogp);
317
331bool bt_hogp_ready_check(const struct bt_hogp *hogp);
332
345int bt_hogp_rep_read(struct bt_hogp *hogp,
346 struct bt_hogp_rep_info *rep,
347 bt_hogp_read_cb func);
348
365int bt_hogp_rep_write(struct bt_hogp *hogp,
366 struct bt_hogp_rep_info *rep,
367 bt_hogp_write_cb func,
368 const void *data, uint8_t length);
369
387 struct bt_hogp_rep_info *rep,
388 const void *data, uint8_t length,
389 bt_hogp_write_cb func);
390
404 struct bt_hogp_rep_info *rep,
405 bt_hogp_read_cb func);
406
417 struct bt_hogp_rep_info *rep);
418
442int bt_hogp_map_read(struct bt_hogp *hogp,
443 bt_hogp_map_cb func,
444 size_t offset,
445 k_timeout_t timeout);
446
469int bt_hogp_pm_update(struct bt_hogp *hogp, k_timeout_t timeout);
470
481enum bt_hids_pm bt_hogp_pm_get(const struct bt_hogp *hogp);
482
499int bt_hogp_pm_write(struct bt_hogp *hogp, enum bt_hids_pm pm);
500
512int bt_hogp_suspend(struct bt_hogp *hogp);
513
526
527
538struct bt_conn *bt_hogp_conn(const struct bt_hogp *hogp);
539
550const struct bt_hids_info *bt_hogp_conn_info_val(const struct bt_hogp *hogp);
551
560struct bt_hogp_rep_info *bt_hogp_rep_boot_kbd_in(struct bt_hogp *hogp);
561
570struct bt_hogp_rep_info *bt_hogp_rep_boot_kbd_out(struct bt_hogp *hogp);
571
580struct bt_hogp_rep_info *bt_hogp_rep_boot_mouse_in(struct bt_hogp *hogp);
581
593size_t bt_hogp_rep_count(const struct bt_hogp *hogp);
594
605struct bt_hogp_rep_info *bt_hogp_rep_next(struct bt_hogp *hogp,
606 const struct bt_hogp_rep_info *rep);
607
622struct bt_hogp_rep_info *bt_hogp_rep_find(struct bt_hogp *hogp,
623 enum bt_hids_report_type type,
624 uint8_t id);
625
632void bt_hogp_rep_user_data_set(struct bt_hogp_rep_info *rep, void *data);
633
641void *bt_hogp_rep_user_data(const struct bt_hogp_rep_info *rep);
642
650uint8_t bt_hogp_rep_id(const struct bt_hogp_rep_info *rep);
651
659enum bt_hids_report_type bt_hogp_rep_type(const struct bt_hogp_rep_info *rep);
660
675size_t bt_hogp_rep_size(const struct bt_hogp_rep_info *rep);
676
677#ifdef __cplusplus
678}
679#endif
680
685#endif /* BT_HOGP_H_ */
bt_hids_report_type
Report types as defined in the Report Reference Characteristic descriptor.
Definition: hids.h:84
bt_hids_pm
Possible values for the Protocol Mode Characteristic value.
Definition: hids.h:74
struct bt_hogp_rep_info * bt_hogp_rep_find(struct bt_hogp *hogp, enum bt_hids_report_type type, uint8_t id)
Find a report.
enum bt_hids_pm bt_hogp_pm_get(const struct bt_hogp *hogp)
Get the current protocol mode.
struct bt_hogp_rep_info * bt_hogp_rep_boot_mouse_in(struct bt_hogp *hogp)
Access boot mouse input report.
void(* bt_hogp_map_cb)(struct bt_hogp *hogp, uint8_t err, const uint8_t *data, size_t size, size_t offset)
Callback function that is called when a chunk of a report map data is received.
Definition: hogp.h:103
void(* bt_hogp_write_cb)(struct bt_hogp *hogp, struct bt_hogp_rep_info *rep, uint8_t err)
Callback function that is called when a write response is received.
Definition: hogp.h:58
int bt_hogp_suspend(struct bt_hogp *hogp)
Suspend the device.
const struct bt_hids_info * bt_hogp_conn_info_val(const struct bt_hogp *hogp)
Access the HID information value.
struct bt_hogp_rep_info * bt_hogp_rep_boot_kbd_in(struct bt_hogp *hogp)
Access boot keyboard input report.
void * bt_hogp_rep_user_data(const struct bt_hogp_rep_info *rep)
Get user data from report.
int bt_hogp_handles_assign(struct bt_gatt_dm *dm, struct bt_hogp *hogp)
Assign handlers to the HIDS client instance.
int bt_hogp_rep_read(struct bt_hogp *hogp, struct bt_hogp_rep_info *rep, bt_hogp_read_cb func)
Send a read request addressing the report value descriptor.
struct bt_hogp_rep_info * bt_hogp_rep_next(struct bt_hogp *hogp, const struct bt_hogp_rep_info *rep)
Get the next report in the HOGP object.
int bt_hogp_rep_write_wo_rsp(struct bt_hogp *hogp, struct bt_hogp_rep_info *rep, const void *data, uint8_t length, bt_hogp_write_cb func)
Send a write command addressing the report value descriptor.
int bt_hogp_rep_unsubscribe(struct bt_hogp *hogp, struct bt_hogp_rep_info *rep)
Remove the subscription for a selected report.
int bt_hogp_pm_update(struct bt_hogp *hogp, k_timeout_t timeout)
Read the current protocol mode from the server.
bool bt_hogp_ready_check(const struct bt_hogp *hogp)
Check if the HIDS client is ready to work.
bool bt_hogp_assign_check(const struct bt_hogp *hogp)
Check if the assignment function was called.
int bt_hogp_rep_write(struct bt_hogp *hogp, struct bt_hogp_rep_info *rep, bt_hogp_write_cb func, const void *data, uint8_t length)
Send a write request addressing the report value descriptor.
struct bt_conn * bt_hogp_conn(const struct bt_hogp *hogp)
Get the connection object from the HIDS client.
struct bt_hogp_rep_info * bt_hogp_rep_boot_kbd_out(struct bt_hogp *hogp)
Access boot keyboard output report.
uint8_t(* bt_hogp_read_cb)(struct bt_hogp *hogp, struct bt_hogp_rep_info *rep, uint8_t err, const uint8_t *data)
Callback function that is called when a notification or read response is received.
Definition: hogp.h:46
void(* bt_hogp_prep_fail_cb)(struct bt_hogp *hogp, int err)
Callback function that is called when an error is detected during HIDS client preparation.
Definition: hogp.h:89
void bt_hogp_abort_all(struct bt_hogp *hogp)
Abort all pending transfers.
uint8_t bt_hogp_rep_id(const struct bt_hogp_rep_info *rep)
Get report identifier.
int bt_hogp_map_read(struct bt_hogp *hogp, bt_hogp_map_cb func, size_t offset, k_timeout_t timeout)
Read part of the report map.
int bt_hogp_exit_suspend(struct bt_hogp *hogp)
Exit suspend and resume.
size_t bt_hogp_rep_size(const struct bt_hogp_rep_info *rep)
Get report size.
void bt_hogp_init(struct bt_hogp *hogp, const struct bt_hogp_init_params *params)
Initialize the HIDS client instance.
int bt_hogp_pm_write(struct bt_hogp *hogp, enum bt_hids_pm pm)
Set the current protocol mode.
void bt_hogp_rep_user_data_set(struct bt_hogp_rep_info *rep, void *data)
Set user data in report.
void(* bt_hogp_pm_update_cb)(struct bt_hogp *hogp)
Callback function that is called when the protocol mode is updated.
Definition: hogp.h:113
int bt_hogp_rep_subscribe(struct bt_hogp *hogp, struct bt_hogp_rep_info *rep, bt_hogp_read_cb func)
Subscribe to report notifications.
size_t bt_hogp_rep_count(const struct bt_hogp *hogp)
Get the number of HID reports in the device.
void bt_hogp_release(struct bt_hogp *hogp)
Release the HIDS client instance.
enum bt_hids_report_type bt_hogp_rep_type(const struct bt_hogp_rep_info *rep)
Get report type.
void(* bt_hogp_ready_cb)(struct bt_hogp *hogp)
Callback function that is called when the HIDS client is ready.
Definition: hogp.h:73
HID Service information.
Definition: hids.h:100
uint16_t info
Definition: hogp.h:166
uint16_t pm
Definition: hogp.h:162
uint16_t cp
Definition: hogp.h:168
uint16_t rep_map
Definition: hogp.h:164
Definition: hogp.h:160
bt_hogp_prep_fail_cb prep_error_cb
Function to call if HID preparation fails.
Definition: hogp.h:126
bt_hogp_pm_update_cb pm_update_cb
Function to call when the protocol mode is updated.
Definition: hogp.h:133
bt_hogp_ready_cb ready_cb
Function to call when the HID client is ready.
Definition: hogp.h:122
HIDS client parameters for the initialization function.
Definition: hogp.h:118
struct bt_hids_info info_val
Definition: hogp.h:158
enum bt_hids_pm pm
Definition: hogp.h:234
struct bt_conn * conn
Definition: hogp.h:156
struct bt_gatt_read_params read_params
Internal read parameters used when reading Protocol Mode or Report Map. This struct might also be use...
Definition: hogp.h:194
struct k_sem read_params_sem
The semaphore for common read parameters protection.
Definition: hogp.h:201
struct bt_hogp_rep_info ** rep_info
Definition: hogp.h:228
bool ready
Definition: hogp.h:232
struct bt_hogp_rep_info * kbd_inp
Definition: hogp.h:218
uint8_t rep_idx
Definition: hogp.h:209
struct bt_hogp_rep_info * kbd_out
Definition: hogp.h:223
struct bt_hogp_rep_info * mouse_inp
Definition: hogp.h:225
bt_hogp_prep_fail_cb prep_error_cb
Callback for HIDS client preparation failed.
Definition: hogp.h:178
bt_hogp_ready_cb ready_cb
Callback for HIDS client ready (see bt_hogp_ready_cb).
Definition: hogp.h:174
struct bt_hogp::@172 rep_boot
struct bt_hogp::bt_hogp_handlers handlers
bt_hogp_pm_update_cb pm_update_cb
Callback for protocol mode updated.
Definition: hogp.h:182
struct bt_hogp::@171 init_repref
bt_hogp_map_cb map_cb
Callback for report map data chunk received.
Definition: hogp.h:186
uint8_t rep_count
Definition: hogp.h:230
HOGP object.
Definition: hogp.h:154