hid_host.h (63bf37cdf290a24499821ad093bb095cca27d8e2) hid_host.h (fd7ba7a6d25e1504d0db40d88bc9982ee89b87bd)
1/*
2 * Copyright (C) 2020 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 34 unchanged lines hidden (view full) ---

43#include "bluetooth.h"
44#include "btstack_hid_parser.h"
45#include "classic/hid.h"
46
47#if defined __cplusplus
48extern "C" {
49#endif
50
1/*
2 * Copyright (C) 2020 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 34 unchanged lines hidden (view full) ---

43#include "bluetooth.h"
44#include "btstack_hid_parser.h"
45#include "classic/hid.h"
46
47#if defined __cplusplus
48extern "C" {
49#endif
50
51typedef enum {
52 HID_HOST_IDLE,
53 HID_HOST_W2_SEND_SDP_QUERY,
54 HID_HOST_W4_SDP_QUERY_RESULT,
55
56 HID_HOST_W4_CONTROL_CONNECTION_ESTABLISHED,
57 HID_HOST_CONTROL_CONNECTION_ESTABLISHED,
58
59 HID_HOST_W4_SET_BOOT_MODE,
60 HID_HOST_W4_INTERRUPT_CONNECTION_ESTABLISHED,
61 HID_HOST_CONNECTION_ESTABLISHED,
62
63 HID_HOST_W2_SEND_GET_REPORT,
64 HID_HOST_W4_GET_REPORT_RESPONSE,
65 HID_HOST_W2_SEND_SET_REPORT,
66 HID_HOST_W4_SET_REPORT_RESPONSE,
67 HID_HOST_W2_SEND_GET_PROTOCOL,
68 HID_HOST_W4_GET_PROTOCOL_RESPONSE,
69 HID_HOST_W2_SEND_SET_PROTOCOL,
70 HID_HOST_W4_SET_PROTOCOL_RESPONSE,
71 HID_HOST_W2_SEND_REPORT,
72 HID_HOST_W4_SEND_REPORT_RESPONSE
73} hid_host_state_t;
74
75typedef struct {
76 uint16_t hid_cid;
77 hci_con_handle_t con_handle;
78
79 bd_addr_t remote_addr;
80 bool incoming;
81 bool boot_mode;
82
83 uint16_t control_cid;
84 uint16_t control_psm;
85 uint16_t interrupt_cid;
86 uint16_t interrupt_psm;
87
88 hid_host_state_t state;
89 hid_protocol_mode_t protocol_mode;
90 bool unplugged;
91
92 uint16_t hid_descriptor_offset;
93 uint16_t hid_descriptor_len;
94 uint16_t hid_descriptor_max_len;
95
96 uint8_t user_request_can_send_now;
97
98 // get report
99 hid_report_type_t report_type;
100 uint8_t report_id;
101
102 // set report
103 uint8_t * report;
104 uint16_t report_len;
105} hid_host_connection_t;
106
51/* API_START */
52/**
53 * @brief Set up HID Host
54 * @param boot_protocol_mode_supported
55 * @param hid_descriptor_storage
56 * @param hid_descriptor_storage_len
57 */
107/* API_START */
108/**
109 * @brief Set up HID Host
110 * @param boot_protocol_mode_supported
111 * @param hid_descriptor_storage
112 * @param hid_descriptor_storage_len
113 */
58void hid_host_init(const uint8_t * hid_descriptor_storage, uint16_t hid_descriptor_storage_len);
114void hid_host_init(uint8_t * hid_descriptor_storage, uint16_t hid_descriptor_storage_len);
59
60/**
61 * @brief Register callback for the HID Device Host.
62 * @param callback
63 */
64void hid_host_register_packet_handler(btstack_packet_handler_t callback);
65
66/*
67 * @brief Create HID connection to HID Host
115
116/**
117 * @brief Register callback for the HID Device Host.
118 * @param callback
119 */
120void hid_host_register_packet_handler(btstack_packet_handler_t callback);
121
122/*
123 * @brief Create HID connection to HID Host
68 * @param addr
124 * @param remote_addr
69 * @param hid_cid to use for other commands
70 * @result status
71 */
125 * @param hid_cid to use for other commands
126 * @result status
127 */
72uint8_t hid_host_connect(bd_addr_t addr, hid_protocol_mode_t protocol_mode, uint16_t * hid_cid);
128uint8_t hid_host_connect(bd_addr_t remote_addr, hid_protocol_mode_t protocol_mode, uint16_t * hid_cid);
73
74/*
75 * @brief Disconnect from HID Host
76 * @param hid_cid
77 */
78void hid_host_disconnect(uint16_t hid_cid);
79
80/**

--- 28 unchanged lines hidden ---
129
130/*
131 * @brief Disconnect from HID Host
132 * @param hid_cid
133 */
134void hid_host_disconnect(uint16_t hid_cid);
135
136/**

--- 28 unchanged lines hidden ---