samples: hci_spi: Fix cmd_hdr and acl_hdr usage
Fixes #27266. cmd_hdr and acl_hdr local structs were read but never written. Causing unpredictable errors in bt_tx_thread such as : "Invalid HCI CMD packet length" in hci.c:2280 or Imprecise data bus errors on nrf52810. cmd_hdr and acl_hdr are now filled with the received data from SPI Master. Signed-off-by: Corentin Dorothée <corentin.dorothee@gmail.com>
This commit is contained in:
parent
6b50f643da
commit
37aca482e9
1 changed files with 15 additions and 9 deletions
|
@ -148,8 +148,12 @@ static void bt_tx_thread(void *p1, void *p2, void *p3)
|
||||||
uint8_t header_slave[5] = { READY_NOW, SANITY_CHECK,
|
uint8_t header_slave[5] = { READY_NOW, SANITY_CHECK,
|
||||||
0x00, 0x00, 0x00 };
|
0x00, 0x00, 0x00 };
|
||||||
struct net_buf *buf = NULL;
|
struct net_buf *buf = NULL;
|
||||||
struct bt_hci_cmd_hdr cmd_hdr;
|
|
||||||
struct bt_hci_acl_hdr acl_hdr;
|
union {
|
||||||
|
struct bt_hci_cmd_hdr *cmd_hdr;
|
||||||
|
struct bt_hci_acl_hdr *acl_hdr;
|
||||||
|
} hci_hdr;
|
||||||
|
hci_hdr.cmd_hdr = (struct bt_hci_cmd_hdr *)&rxmsg[1];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ARG_UNUSED(p1);
|
ARG_UNUSED(p1);
|
||||||
|
@ -195,11 +199,12 @@ static void bt_tx_thread(void *p1, void *p2, void *p3)
|
||||||
|
|
||||||
switch (rxmsg[PACKET_TYPE]) {
|
switch (rxmsg[PACKET_TYPE]) {
|
||||||
case HCI_CMD:
|
case HCI_CMD:
|
||||||
buf = bt_buf_get_tx(BT_BUF_CMD, K_NO_WAIT, &rxmsg[1],
|
buf = bt_buf_get_tx(BT_BUF_CMD, K_NO_WAIT,
|
||||||
sizeof(cmd_hdr));
|
hci_hdr.cmd_hdr,
|
||||||
|
sizeof(*hci_hdr.cmd_hdr));
|
||||||
if (buf) {
|
if (buf) {
|
||||||
net_buf_add_mem(buf, &rxmsg[4],
|
net_buf_add_mem(buf, &rxmsg[4],
|
||||||
cmd_hdr.param_len);
|
hci_hdr.cmd_hdr->param_len);
|
||||||
} else {
|
} else {
|
||||||
LOG_ERR("No available command buffers!");
|
LOG_ERR("No available command buffers!");
|
||||||
continue;
|
continue;
|
||||||
|
@ -207,10 +212,11 @@ static void bt_tx_thread(void *p1, void *p2, void *p3)
|
||||||
break;
|
break;
|
||||||
case HCI_ACL:
|
case HCI_ACL:
|
||||||
buf = bt_buf_get_tx(BT_BUF_ACL_OUT, K_NO_WAIT,
|
buf = bt_buf_get_tx(BT_BUF_ACL_OUT, K_NO_WAIT,
|
||||||
&rxmsg[1], sizeof(acl_hdr));
|
hci_hdr.acl_hdr,
|
||||||
|
sizeof(*hci_hdr.acl_hdr));
|
||||||
if (buf) {
|
if (buf) {
|
||||||
net_buf_add_mem(buf, &rxmsg[5],
|
net_buf_add_mem(buf, &rxmsg[5],
|
||||||
sys_le16_to_cpu(acl_hdr.len));
|
sys_le16_to_cpu(hci_hdr.acl_hdr->len));
|
||||||
} else {
|
} else {
|
||||||
LOG_ERR("No available ACL buffers!");
|
LOG_ERR("No available ACL buffers!");
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue