Skip to content

Commit a997c8e

Browse files
committed
add print message for debug
define DEBUG to output information define PRINT_HCI_DATA to trace the exact content of the TX packet Signed-off-by: Francois Ramu <[email protected]>
1 parent f857191 commit a997c8e

File tree

1 file changed

+52
-26
lines changed

1 file changed

+52
-26
lines changed

src/utility/HCISharedMemTransport.cpp

+52-26
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,19 @@ __disable_irq();
143143
_write_index += len;
144144
//TODO: control the _rxbuff cannot overflow
145145
__enable_irq();
146+
#if defined(DEBUG)
147+
printf("RX<< EVT ");
148+
#if defined(PRINT_HCI_DATA)
149+
printf(" Type %#x", hcievt->evtserial.type);
150+
printf(" evt %#x", hcievt->evtserial.evt.evtcode);
151+
printf(" Len %#d", hcievt->evtserial.evt.plen);
152+
printf(" :");
153+
for (uint8_t i = 0; i < hcievt->evtserial.evt.plen; i++) {
154+
printf(" %02X", hcievt->evtserial.evt.payload[i]);
155+
}
156+
#endif /* PRINT_HCI_DATA */
157+
printf("\r\n");
158+
#endif /* DEBUG */
146159
}
147160
break;
148161
case TL_ACL_DATA_PKT_TYPE: {
@@ -154,24 +167,37 @@ __disable_irq();
154167
_write_index += len;
155168
//TODO: control the _rxbuff cannot overflow
156169
__enable_irq();
170+
171+
#if defined(DEBUG)
172+
printf("RX<< ACL ");
173+
#if defined(PRINT_HCI_DATA)
174+
printf(" Type %#x", acl->type);
175+
printf(" evt %#x", acl->handle);
176+
printf(" Len %#d", acl->length);
177+
printf(" :");
178+
for (uint8_t i = 0; i < acl->length; i++) {
179+
printf(" %02X", acl->acl_data[i]);
180+
}
181+
#endif /* PRINT_HCI_DATA */
182+
printf("\r\n");
183+
#endif /* DEBUG */
157184
}
158185
break;
159186
default:
160187
// should not happen - let's block to check
161188
#if defined(DEBUG)
162-
printf("BLE TL evt_received, wrong type:%d", hcievt->evtserial.type);
189+
printf("BLE TL evt_received, wrong type:%d\r\n", hcievt->evtserial.type);
163190
#endif /* DEBUG */
164191
break;
165192
}
166193

167194
if (_write_index > BLE_MODULE_SHARED_MEM_BUFFER_SIZE) {
168195
#if defined(DEBUG)
169-
printf("Error: data read overflow");
196+
printf("Error: data read overflow\r\n");
170197
#endif /* DEBUG */
171198
data_available = true;
172199
}
173200

174-
175201
/* In case Event belongs to the Evt Pool we need to inform */
176202
if (((uint8_t *)hcievt >= EvtPool) && ((uint8_t *)hcievt < (EvtPool + POOL_SIZE))) {
177203
/* Free the message from shared memory */
@@ -312,18 +338,18 @@ int HCISharedMemTransportClass::begin()
312338
WirelessFwInfo_t wireless_info_instance;
313339
WirelessFwInfo_t *p_wireless_info = &wireless_info_instance;
314340
SHCI_GetWirelessFwInfo(p_wireless_info);
315-
/*
316-
* tr_info("WIRELESS COPROCESSOR FW VERSION ID = %d.%d.%d", p_wireless_info->VersionMajor, p_wireless_info->VersionMinor, p_wireless_info->VersionSub);
317-
* tr_info("WIRELESS COPROCESSOR FW STACK TYPE = %d", p_wireless_info->StackType);
318-
*/
319-
320-
341+
#if defined(DEBUG)
342+
printf("WB copro FW version = %d.%d.%d\r\n", p_wireless_info->VersionMajor, p_wireless_info->VersionMinor, p_wireless_info->VersionSub);
343+
#endif
321344
/* Now start BLE service on firmware side, using Vendor specific
322345
* command on the System Channel
323346
*/
324347
stm32wb_start_ble();
325348

326-
/* "IPM Channel Open Completed" */
349+
/* IPM Channel is now open */
350+
#if defined(DEBUG)
351+
printf("IPM Channel Open Completed\r\n");
352+
#endif
327353

328354
/* Once reset complete event is received we will need
329355
* to send a few more commands:
@@ -667,9 +693,7 @@ static int bt_ipm_set_power(void)
667693
// type 02 ACL DATA
668694
// type 03 SCO Voice (not supported)
669695
// type 04 event - uplink (not suported)
670-
#if defined(DEBUG)
671-
printf("mbox_write type:%d, len:%d", type, len);
672-
#endif /* DEBUG */
696+
673697
/* TO DO : MANAGE ACL DATA CASE in separate buffer */
674698
switch (type) {
675699
case 1://BLE command
@@ -679,23 +703,25 @@ static int bt_ipm_set_power(void)
679703
/* We're tracing here the command, after copy in shared mem but before
680704
* * M0 trigger. */
681705
#if defined(DEBUG)
682-
printf("TX>> BLE CMD");
683-
#if (PRINT_HCI_DATA)
706+
printf("TX>> CMD ");
707+
#if defined(PRINT_HCI_DATA)
684708
/* Trace the buffer including Type (+1 on lngth) */
685-
tr_debug(" Type %#x", bleCmdBuf->cmdserial.type);
686-
tr_debug(" Cmd %#x", bleCmdBuf->cmdserial.cmd.cmdcode);
687-
tr_debug(" Len %#x", bleCmdBuf->cmdserial.cmd.plen);
709+
printf(" Type %#x", bleCmdBuf->cmdserial.type);
710+
printf(" Cmd %#x", bleCmdBuf->cmdserial.cmd.cmdcode);
711+
printf(" Len %#d", bleCmdBuf->cmdserial.cmd.plen);
712+
printf(" :");
688713
for (uint8_t i = 0; i < bleCmdBuf->cmdserial.cmd.plen; i++) {
689-
tr_debug(" %02X", *(((uint8_t *)&bleCmdBuf->cmdserial.cmd.payload) + i));
714+
printf(" %02X", *(((uint8_t *)&bleCmdBuf->cmdserial.cmd.payload) + i));
690715
}
691716
#endif /* PRINT_HCI_DATA */
717+
printf("\r\n");
692718
#endif /* DEBUG */
693719
TL_BLE_SendCmd(NULL, 0); // unused parameters for now
694720
break;
695721
case 2://ACL DATA
696722
if (acl_data) {
697723
#if defined(DEBUG)
698-
printf("ERROR: previous ACL message not ACK'd");
724+
printf("ERROR: previous ACL message not ACK'd\r\n");
699725
#endif /* DEBUG */
700726
/* return number of bytes sent, 0 in this error case */
701727
return 0;
@@ -704,13 +730,13 @@ static int bt_ipm_set_power(void)
704730
aclDataSerial->type = type; // for now this param is overwritten in TL_BLE_SendCmd
705731
memcpy(HciAclDataBuffer + + sizeof(TL_PacketHeader_t) + sizeof(type), pData, len);
706732
#if defined(DEBUG)
707-
printf("TX>> BLE ACL");
708-
#if PRINT_HCI_DATA
733+
printf("TX>> ACL ");
734+
#if defined(PRINT_HCI_DATA)
709735
for (uint8_t i = 0; i < len + 1 + 8; i++) {
710-
tr_debug(" %02x", *(((uint8_t *) aclDataBuffer) + i));
736+
printf("%02x ", *(((uint8_t *) HciAclDataBuffer) + i));
711737
}
712-
printf("\r\n");
713738
#endif /* PRINT_HCI_DATA */
739+
printf("\r\n");
714740
#endif /* DEBUG */
715741
TL_BLE_SendAclData(NULL, 0); // unused parameters for now
716742
acl_data = true;
@@ -730,7 +756,7 @@ static void init_debug(void)
730756

731757
#if defined(CONFIG_DEBUG)
732758
#if defined(DEBUG)
733-
printf("init_debug ENABLED");
759+
printf("init_debug ENABLED\r\n");
734760
#endif /* DEBUG */
735761
/**
736762
* Keep debugger enabled while in any low power mode
@@ -745,7 +771,7 @@ static void init_debug(void)
745771

746772
#else
747773
#if defined(DEBUG)
748-
printf("init_debug DISABLED");
774+
printf("init_debug DISABLED\n\r");
749775
#endif /* DEBUG */
750776
GPIO_InitTypeDef gpio_config = {0};
751777

0 commit comments

Comments
 (0)