@@ -71,6 +71,7 @@ LoraRadio::LoraRadio()
7171bool LoraRadio::begin (HardwareSerial *serialx)
7272{
7373 uint8_t nbTry = 0 ;
74+ uint8_t enable = 0 ;
7475
7576 if (serialx == NULL ) {
7677 return false ;
@@ -83,8 +84,14 @@ bool LoraRadio::begin(HardwareSerial *serialx)
8384
8485 LoRa_DumyRequest ();
8586
86- // Echo mode must be disabled
87- Modem_AT_Cmd (AT_EXCEPT, AT_ATE, 0 );
87+ // Local echo mode must be disabled
88+ Modem_AT_Cmd (AT_EXCEPT, AT_ATE, &enable);
89+
90+ // Verbose response must be enabled for the AT parser
91+ enable = 1 ;
92+ if (Modem_AT_Cmd (AT_EXCEPT, AT_VERB, &enable) != AT_OK) {
93+ AT_VERB_cmd = false ;
94+ }
8895
8996 // Enable Lora module
9097 /*
@@ -410,55 +417,55 @@ uint8_t LoraRadio::parseRcvData(void *pdata)
410417 return AT_END_ERROR;
411418 }
412419
413- /* cleanup the response buffer*/
420+ // Cleanup the response buffer
414421 memset (response, 0x00 , DATA_RX_MAX_BUFF_SIZE);
415422
416- while (!ResponseComplete)
417- {
423+ while (!ResponseComplete) {
418424 msStart = millis ();
419- while (HW_UART_Modem_IsNewCharReceived () == RESET ) {
425+ while (! HW_UART_Modem_IsNewCharReceived ()) {
420426 if ((millis () - msStart) > RESPONSE_TIMEOUT) {
421427 return AT_UART_LINK_ERROR;
422428 }
423429 }
424430
425- /* process the response*/
431+ // Process the response
426432 response[i] = HW_UART_Modem_GetNewChar ();
427433
428- /* wait up to carriage return OR the line feed marker*/
429- if (/* (response[i] =='\r') || */ (response[i] == ' \n ' ))
430- {
434+ // Wait up to carriage return OR the line feed marker
435+ if (/* (response[i] =='\r') || */ (response[i] == ' \n ' )) {
431436 DBG_PRINTF (" LoRa radio rcv: %s\r\n " , response);
432437
433- if (i!= 0 ) /* trap the asynchronous event*/
434- {
435- /* first statement to get back the return value*/
438+ if (i!= 0 ) { // Trap the asynchronous event
439+ // First statement to get back the return value
436440 response[i] = ' \0 ' ;
437- ptrChr = strchr (&response[0 ],' +' ); /* to skip the '\0''\r'*/
438- if (strncmp (ptrChr, " +RCV: " , sizeof (" +RCV: " )-1 ) == 0 ) {
441+ ptrChr = strchr (&response[0 ],' +' ); // Skip the '\0''\r'
442+ if (strncmp (ptrChr, " +RCV" , sizeof (" +RCV" )-1 ) == 0 ) {
439443 RetCode = AT_OK;
440- ptrChr = strchr (&response[1 ],' :' ); /* to skip the '\0''\r'*/
441- strcpy ((char *)pdata,ptrChr+2 );
444+ if (AT_VERB_cmd) {
445+ ptrChr = strrchr (&response[1 ], ' ,' );
446+ strcpy ((char *)pdata, ptrChr+1 );
447+ } else {
448+ ptrChr = strchr (&response[1 ],' :' );
449+ strcpy ((char *)pdata, ptrChr+2 );
450+ }
442451 ResponseComplete = 1 ;
443452 } else {
444453 RetCode = AT_END_ERROR;
445454 }
446455 memset (response, 0x00 , 16 );
447- i= -1 ; /* to compensate the next index iteration and restart in [0]*/
456+ i= -1 ; // Compensate the next index iteration and restart in [0]
448457 }
449- }
450- else
451- {
452- if (i == (DATA_RX_MAX_BUFF_SIZE-1 )) /* frame overflow */
453- {
458+ } else {
459+ if (i == (DATA_RX_MAX_BUFF_SIZE-1 )) {
460+ // Frame overflow
454461 i = 0 ;
455462 return (AT_TEST_PARAM_OVERFLOW);
456463 }
457464 }
458465 i++;
459466 }
460467
461- return ( RetCode); /* version of HAL .. there was not Rx field state */
468+ return RetCode;
462469}
463470
464471LoraRadio loraRadio;
0 commit comments