GCC Code Coverage Report


Directory: main/
File: bluetooth/hidp/generic.c
Date: 2025-10-04 14:03:00
Exec Total Coverage
Lines: 17 18 94.4%
Functions: 3 3 100.0%
Branches: 5 8 62.5%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2019-2024, Jacques Gagnon
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6 #include "bluetooth/host.h"
7 #include "bluetooth/att_hid.h"
8 #include "generic.h"
9
10 6 void bt_hid_cmd_generic_rumble(struct bt_dev *device, void *report) {
11 6 struct bt_hidp_generic_rumble *rumble_report = (struct bt_hidp_generic_rumble *)report;
12
13
3/4
✓ Branch 0 (2→3) taken 1 times.
✓ Branch 1 (2→9) taken 5 times.
✓ Branch 2 (3→4) taken 1 times.
✗ Branch 3 (3→9) not taken.
6 if (rumble_report->report_id && rumble_report->report_size) {
14
1/2
✗ Branch 0 (5→6) not taken.
✓ Branch 1 (5→7) taken 1 times.
1 if (atomic_test_bit(&device->flags, BT_DEV_IS_BLE)) {
15 bt_att_write_hid_report(device, rumble_report->report_id, rumble_report->state, rumble_report->report_size);
16 }
17 else {
18 1 memcpy(bt_hci_pkt_tmp.hidp_data, rumble_report->state, rumble_report->report_size);
19 1 bt_hid_cmd(device->acl_handle, device->intr_chan.dcid, BT_HIDP_DATA_OUT, rumble_report->report_id, rumble_report->report_size);
20 }
21 }
22 6 }
23
24 23 void bt_hid_generic_init(struct bt_dev *device) {
25 23 atomic_set_bit(&device->flags, BT_DEV_HID_INIT_DONE);
26 23 }
27
28 178 void bt_hid_generic_hdlr(struct bt_dev *device, struct bt_hci_pkt *bt_hci_acl_pkt, uint32_t len) {
29 178 uint32_t hidp_data_len = len - (BT_HCI_H4_HDR_SIZE + BT_HCI_ACL_HDR_SIZE
30 + sizeof(struct bt_l2cap_hdr) + sizeof(struct bt_hidp_hdr));
31
32
1/2
✓ Branch 0 (2→3) taken 178 times.
✗ Branch 1 (2→5) not taken.
178 switch (bt_hci_acl_pkt->sig_hdr.code) {
33 178 case BT_HIDP_DATA_IN:
34 178 bt_host_bridge(device, bt_hci_acl_pkt->hidp_hdr.protocol, bt_hci_acl_pkt->hidp_data, hidp_data_len);
35 178 break;
36 }
37 178 }
38