Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
card10
firmware
Commits
2a1591ea
Commit
2a1591ea
authored
4 years ago
by
schneider
Browse files
Options
Downloads
Patches
Plain Diff
change(hid): Clean up epicardium API
parent
a0b2edd0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!382
HID over BLE
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
epicardium/ble/hid_work.c
+44
-34
44 additions, 34 deletions
epicardium/ble/hid_work.c
epicardium/epicardium.h
+4
-10
4 additions, 10 deletions
epicardium/epicardium.h
with
48 additions
and
44 deletions
epicardium/ble/hid_work.c
+
44
−
34
View file @
2a1591ea
...
...
@@ -31,7 +31,7 @@ struct
/* clang-format on */
struct
report
{
uint8_t
report
I
d
;
uint8_t
report
_i
d
;
uint8_t
data
[
8
];
uint8_t
len
;
};
...
...
@@ -42,10 +42,20 @@ static QueueHandle_t queue;
static
uint8_t
buffer
[
sizeof
(
struct
report
)
*
QUEUE_SIZE
];
static
StaticQueue_t
queue_data
;
static
int
hid_queue_data
(
uint8_t
report
I
d
,
uint8_t
*
data
,
uint8_t
len
)
static
int
hid_queue_data
(
uint8_t
report
_i
d
,
uint8_t
*
data
,
uint8_t
len
)
{
struct
report
report
;
report
.
reportId
=
reportId
;
if
(
report_id
<
1
||
report_id
>
3
)
{
return
-
EINVAL
;
}
report
.
report_id
=
report_id
;
if
(
len
>
sizeof
(
report
.
data
))
{
return
-
EINVAL
;
}
memcpy
(
report
.
data
,
data
,
len
);
report
.
len
=
len
;
...
...
@@ -76,21 +86,21 @@ static bool hid_dequeue_data(dmConnId_t connId)
}
if
(
HidGetProtocolMode
()
==
HID_PROTOCOL_MODE_BOOT
)
{
if
(
report
.
report
I
d
==
HIDAPP_KEYBOARD_REPORT_ID
)
{
report
.
report
I
d
=
HID_KEYBOARD_BOOT_ID
;
cccHandle
=
HIDAPP_KBI_CCC_HDL
;
}
else
if
(
report
.
report
I
d
==
HIDAPP_MOUSE_REPORT_ID
)
{
report
.
report
I
d
=
HID_MOUSE_BOOT_ID
;
cccHandle
=
HIDAPP_MBI_CCC_HDL
;
if
(
report
.
report
_i
d
==
HIDAPP_KEYBOARD_REPORT_ID
)
{
report
.
report
_i
d
=
HID_KEYBOARD_BOOT_ID
;
cccHandle
=
HIDAPP_KBI_CCC_HDL
;
}
else
if
(
report
.
report
_i
d
==
HIDAPP_MOUSE_REPORT_ID
)
{
report
.
report
_i
d
=
HID_MOUSE_BOOT_ID
;
cccHandle
=
HIDAPP_MBI_CCC_HDL
;
}
else
{
break
;
}
}
else
{
if
(
report
.
report
I
d
==
HIDAPP_KEYBOARD_REPORT_ID
)
{
if
(
report
.
report
_i
d
==
HIDAPP_KEYBOARD_REPORT_ID
)
{
cccHandle
=
HIDAPP_IN_KEYBOARD_CCC_HDL
;
}
else
if
(
report
.
report
I
d
==
HIDAPP_MOUSE_REPORT_ID
)
{
}
else
if
(
report
.
report
_i
d
==
HIDAPP_MOUSE_REPORT_ID
)
{
cccHandle
=
HIDAPP_IN_MOUSE_CCC_HDL
;
}
else
if
(
report
.
report
I
d
==
HIDAPP_CONSUMER_REPORT_ID
)
{
}
else
if
(
report
.
report
_i
d
==
HIDAPP_CONSUMER_REPORT_ID
)
{
cccHandle
=
HIDAPP_IN_CONSUMER_CCC_HDL
;
}
else
{
break
;
...
...
@@ -102,7 +112,7 @@ static bool hid_dequeue_data(dmConnId_t connId)
/* Send the message */
HidSendInputReport
(
connId
,
report
.
report
I
d
,
report
.
report
_i
d
,
report
.
len
,
report
.
data
);
...
...
@@ -114,27 +124,6 @@ static bool hid_dequeue_data(dmConnId_t connId)
return
true
;
}
int
epic_ble_hid_send_report
(
uint8_t
reportId
,
uint8_t
*
data
,
uint8_t
len
)
{
dmConnId_t
connId
=
AppConnIsOpen
();
if
(
connId
==
DM_CONN_ID_NONE
)
{
return
-
EIO
;
}
int
ret
;
ret
=
hid_queue_data
(
reportId
,
data
,
len
);
if
(
ret
<
0
)
{
return
ret
;
}
if
(
hid_dequeue_data
(
connId
))
{
return
0
;
}
else
{
return
1
;
}
}
/*************************************************************************************************/
/*!
* \brief Callback to handle an output report from the host.
...
...
@@ -218,6 +207,27 @@ void HidProcMsg(wsfMsgHdr_t *pMsg)
}
}
int
epic_ble_hid_send_report
(
uint8_t
report_id
,
uint8_t
*
data
,
uint8_t
len
)
{
dmConnId_t
connId
=
AppConnIsOpen
();
if
(
connId
==
DM_CONN_ID_NONE
)
{
return
-
EIO
;
}
int
ret
;
ret
=
hid_queue_data
(
report_id
,
data
,
len
);
if
(
ret
<
0
)
{
return
ret
;
}
if
(
hid_dequeue_data
(
connId
))
{
return
0
;
}
else
{
return
1
;
}
}
void
hid_work_init
(
void
)
{
queue
=
xQueueCreateStatic
(
...
...
This diff is collapsed.
Click to expand it.
epicardium/epicardium.h
+
4
−
10
View file @
2a1591ea
...
...
@@ -2322,28 +2322,22 @@ API(API_BLE_SET_MODE, void epic_ble_set_mode(bool bondable, bool scanner));
*/
API
(
API_BLE_GET_SCAN_REPORT
,
int
epic_ble_get_scan_report
(
struct
epic_scan_report
*
rpt
));
/**
* Human Interface Device (HID)
* ==========================
*/
/**
* Send an input report to the host.
*
* :param uint8_t report
I
d: The id of the report to use.
0: remote,
1: keyboard, 2: mouse
* :param uint8_t report
_i
d: The id of the report to use. 1: keyboard, 2: mouse
, 3: consumer control
* :param uint8_t *data: Data to be reported.
* :param uint8_t len: Length in bytes of the data to be reported. Maximum length i
n
8 bytes.
* :param uint8_t len: Length in bytes of the data to be reported. Maximum length i
s
8 bytes.
*
* :return: `0` on success, `1` if the report is queued or a negative value if an error occured. Possible
* errors:
*
* - ``-EIO``: There is no host device connected
* - ``-EAGAIN``: There is no space in the queue available. Try again later.
* - ``-EINVAL``: Either the report_id is out of range or the data is too long.
*
*/
API
(
API_BLE_HID_SEND_REPORT
,
int
epic_ble_hid_send_report
(
uint8_t
report
I
d
,
uint8_t
*
data
,
uint8_t
len
));
API
(
API_BLE_HID_SEND_REPORT
,
int
epic_ble_hid_send_report
(
uint8_t
report
_i
d
,
uint8_t
*
data
,
uint8_t
len
));
#endif
/* _EPICARDIUM_H */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment