Skip to content

Commit 165cb04

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
1 parent 8f00263 commit 165cb04

File tree

1 file changed

+36
-30
lines changed

1 file changed

+36
-30
lines changed

src/utility/HCISharedMemTransport.cpp

+36-30
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ volatile bool sys_resp;
2626
volatile bool acl_data; /* true : data acknowledged by the BLE */
2727
volatile bool data_available;
2828

29-
/* this one is for printing
30-
#define DEBUG */
29+
/* this one is for printing */
30+
#define DEBUG
31+
#define PRINT_HCI_DATA
32+
3133
/* this must be defined */
3234
#define CONFIG_DEBUG
3335

@@ -141,19 +143,18 @@ __enable_irq();
141143
default:
142144
// should not happen - let's block to check
143145
#if defined(DEBUG)
144-
printf("BLE TL evt_received, wrong type:%d", hcievt->evtserial.type);
146+
printf("BLE TL evt_received, wrong type:%d\r\n", hcievt->evtserial.type);
145147
#endif /* DEBUG */
146148
break;
147149
}
148150

149151
if (_write_index > BLE_MODULE_SHARED_MEM_BUFFER_SIZE) {
150152
#if defined(DEBUG)
151-
printf("Error: data read overflow");
153+
printf("Error: data read overflow\r\n");
152154
#endif /* DEBUG */
153155
data_available = true;
154156
}
155157

156-
157158
/* In case Event belongs to the Evt Pool we need to inform */
158159
if (((uint8_t *)hcievt >= EvtPool) && ((uint8_t *)hcievt < (EvtPool + POOL_SIZE))) {
159160
/* Free the message from shared memory */
@@ -663,10 +664,11 @@ static int bt_ipm_set_power(void)
663664
/* if event is a command complete event */
664665
if (*pMsg == HCI_CMD_CMPL_EVT) {
665666
/* "Command Complete Event Command" */
666-
#if (PRINT_HCI_DATA)
667+
#if defined(PRINT_HCI_DATA)
667668
for (uint8_t i = 0; i < 20; i++) {
668-
tr_debug(" %02X", *((uint8_t *)pMsg + i));
669+
printf(" %02X", *((uint8_t *)pMsg + i));
669670
}
671+
printf("\r\n");
670672
#endif
671673
/* parse parameters */
672674
pMsg += HCI_EVT_HDR_LEN;
@@ -841,7 +843,7 @@ static int bt_ipm_set_power(void)
841843
842844
default:
843845
#if defined(DEBUG)
844-
printf("Complete Event in reset seq with unknown opcode =0x%4X", opcode);
846+
printf("Complete Event in reset seq with unknown opcode =0x%4X\r\n", opcode);
845847
#endif /* DEBUG */
846848
break;
847849
}
@@ -855,7 +857,7 @@ static int bt_ipm_set_power(void)
855857
pMsg++; /* skip num packets */
856858
BSTREAM_TO_UINT16(opcode, pMsg);
857859
#if defined(DEBUG)
858-
printf("Command Status event, status:%d, opcode=0x%4X", status, opcode);
860+
printf("Command Status event, status:%d, opcode=0x%4X\r\n", status, opcode);
859861
#endif /* DEBUG */
860862
} else {
861863
/**
@@ -866,11 +868,11 @@ static int bt_ipm_set_power(void)
866868
pMsg += HCI_EVT_HDR_LEN;
867869
BSTREAM_TO_UINT16(opcode, pMsg);
868870
#if defined(DEBUG)
869-
printf("Vendor specific event, opcode=0x%4X", opcode);
871+
printf("Vendor specific event, opcode=0x%4X\r\n", opcode);
870872
#endif /* DEBUG */
871873
} else {
872874
#if defined(DEBUG)
873-
printf("Unknown event %d!", pMsg[0]);
875+
printf("Unknown event %d!\r\n", pMsg[0]);
874876
#endif /* DEBUG */
875877
}
876878
}
@@ -888,9 +890,7 @@ static int bt_ipm_set_power(void)
888890
// type 02 ACL DATA
889891
// type 03 SCO Voice (not supported)
890892
// type 04 event - uplink (not suported)
891-
#if defined(DEBUG)
892-
printf("mbox_write type:%d, len:%d", type, len);
893-
#endif /* DEBUG */
893+
894894
/* TO DO : MANAGE ACL DATA CASE in separate buffer */
895895
switch (type) {
896896
case 1://BLE command
@@ -900,23 +900,26 @@ static int bt_ipm_set_power(void)
900900
/* We're tracing here the command, after copy in shared mem but before
901901
* * M0 trigger. */
902902
#if defined(DEBUG)
903-
printf("TX>> BLE CMD");
904-
#endif /* DEBUG */
905-
#if (PRINT_HCI_DATA)
906-
/* Trace the buffer including Type (+1 on lngth) */
907-
tr_debug(" Type %#x", bleCmdBuf->cmdserial.type);
908-
tr_debug(" Cmd %#x", bleCmdBuf->cmdserial.cmd.cmdcode);
909-
tr_debug(" Len %#x", bleCmdBuf->cmdserial.cmd.plen);
903+
#if !defined(PRINT_HCI_DATA)
904+
printf("mbox_write type:%d, len:%d\r\n", type, len);
905+
#else /* Trace the buffer including Type (+1 on lngth) */
906+
printf("TX>> BLE CMD : ");
907+
printf(" Type %#x", bleCmdBuf->cmdserial.type);
908+
printf(" Cmd %#x", bleCmdBuf->cmdserial.cmd.cmdcode);
909+
printf(" Len %#d", bleCmdBuf->cmdserial.cmd.plen);
910+
printf(" :");
910911
for (uint8_t i = 0; i < bleCmdBuf->cmdserial.cmd.plen; i++) {
911-
tr_debug(" %02X", *(((uint8_t *)&bleCmdBuf->cmdserial.cmd.payload) + i));
912+
printf(" %02X", *(((uint8_t *)&bleCmdBuf->cmdserial.cmd.payload) + i));
912913
}
914+
printf("\r\n");
913915
#endif /* PRINT_HCI_DATA */
916+
#endif /* DEBUG */
914917
TL_BLE_SendCmd(NULL, 0); // unused parameters for now
915918
break;
916919
case 2://ACL DATA
917920
if (!acl_data) {
918921
#if defined(DEBUG)
919-
printf("ERROR: previous ACL message not ACK'd");
922+
printf("ERROR: previous ACL message not ACK'd\r\n");
920923
#endif /* DEBUG */
921924
/* return number of bytes sent, 0 in this error case */
922925
return 0;
@@ -925,13 +928,16 @@ static int bt_ipm_set_power(void)
925928
&((TL_AclDataPacket_t *)HciAclDataBuffer)->AclDataSerial, pData, len);
926929
TL_BLE_SendAclData(NULL, 0); // unused parameters for now
927930
#if defined(DEBUG)
928-
printf("TX>> BLE ACL");
929-
#endif /* DEBUG */
930-
#if PRINT_HCI_DATA
931+
#if !defined(PRINT_HCI_DATA)
932+
printf("mbox_write type:%d, len:%d \r\n", type, len);
933+
#else
934+
printf("TX>> BLE ACL : ");
931935
for (uint8_t i = 0; i < len + 1 + 8; i++) {
932-
tr_debug(" %02x", *(((uint8_t *) aclDataBuffer) + i));
936+
printf("%02x ", *(((uint8_t *) HciAclDataBuffer) + i));
933937
}
934-
#endif
938+
printf("\r\n");
939+
#endif /* PRINT_HCI_DATA */
940+
#endif /* DEBUG */
935941
break;
936942
}
937943
return len;
@@ -948,7 +954,7 @@ static void init_debug(void)
948954

949955
#if defined(CONFIG_DEBUG)
950956
#if defined(DEBUG)
951-
printf("init_debug ENABLED");
957+
printf("init_debug ENABLED\r\n");
952958
#endif /* DEBUG */
953959
/**
954960
* Keep debugger enabled while in any low power mode
@@ -963,7 +969,7 @@ static void init_debug(void)
963969

964970
#else
965971
#if defined(DEBUG)
966-
printf("init_debug DISABLED");
972+
printf("init_debug DISABLED\n\r");
967973
#endif /* DEBUG */
968974
GPIO_InitTypeDef gpio_config = {0};
969975

0 commit comments

Comments
 (0)