Successful mqtt subscribe followed by rev failure

I am using the demo example to create a mqtt connection with aws. (https://github.com/FreeRTOS/Lab-Project-FreeRTOS-Cellular-Demo/blob/main/source/MutualAuthMQTTExample.c)

I can successfully connect and publish when subscribing I get the following output. This happens in the MQTT_ProcessLoop which returns a receive failure ?

2010 131813 [Cellular] mbedTLS: |4| 0x2000d2e8: dumping ‘input payload after decrypt’ (5 bytes)

2011 131814 [Cellular] mbedTLS: |4| 0x2000d2e8: 0000: 90 03 00 01 01 …

2012 131815 [Cellular] mbedTLS: |2| 0x2000d2e8: <= read record

2013 131816 [Cellular] mbedTLS: |2| 0x2000d2e8: <= read

2014 131817 [Cellular] mbedTLS: |2| 0x2000d2e8: => read

2015 131818 [Cellular] mbedTLS: |2| 0x2000d2e8: <= read

2016 131819 [Cellular] mbedTLS: |2| 0x2000d2e8: => read

2017 131820 [Cellular] mbedTLS: |2| 0x2000d2e8: <= read

2018 131822 [Cellular] [INFO] Subscribed to the topic demo-access-control-board/example/topic with maximum QoS 1.

2019 131823 [Cellular] mbedTLS: |2| 0x2000d2e8: => read

2020 131824 [Cellular] mbedTLS: |2| 0x2000d2e8: => read record

2021 131825 [Cellular] mbedTLS: |2| 0x2000d2e8: => fetch input

2022 131826 [Cellular] mbedTLS: |2| 0x2000d2e8: in_left: 0, nb_want: 5

2023 131828 [Cellular] [DEBUG] >>>>>Start sending [AT+USORD=0,5]<<<<<

2024 131840 [Cellular_Thread] [DEBUG] AT Read 24 bytes, data[0x2000dd26]

2025 131841 [Cellular_Thread] [DEBUG] Allocate at response 0x20011830

2026 131842 [Cellular_Thread] [DEBUG] AT solicited Resp[+USORD: 0,0,]

2027 131844 [Cellular_Thread] [DEBUG] Save [+USORD: 0,0,] 12 AT data to pResp

2028 131845 [Cellular_Thread] [DEBUG] _saveData : Save data 0x2000dd28 with length 13

2029 131846 [Cellular_Thread] [DEBUG] AT solicited Resp["]

2030 131847 [Cellular_Thread] [DEBUG] Save ["] 1 AT data to pResp

2031 131848 [Cellular_Thread] [DEBUG] _saveData : Save data 0x2000dd35 with length 2

2032 131849 [Cellular_Thread] [DEBUG] AT solicited Resp[OK]

2033 131851 [Cellular_Thread] [DEBUG] Final AT response is SUCCESS [OK]

2034 131852 [Cellular_Thread] [ERROR] Receive Data: paramerter error, data pointer 0x2000dd35, data to copy 0

2035 131853 [Cellular_Thread] [DEBUG] Garbage collection

2036 131860 [Cellular_Thread] [DEBUG] AT Read 17 bytes, data[0x2000dd26]

2037 131861 [Cellular_Thread] [DEBUG] Next URC token to parse [+UUSORD: 0,31]

Free Heap Size 11536
2038 132830 [Cellular] [WARN] Modem returns error in sending AT command AT+USORD=0,5, pktStatus 6.

2039 132831 [Cellular] [DEBUG] <<<<<Exit sending [AT+USORD=0,5] status[6]<<<<<

2040 132832 [Cellular] [ERROR] Cellular_SocketRecv: Data Receive fail, pktStatus: 6

2041 132833 [Cellular] [ERROR] _Cellular_TranslatePktStatus: Status 6

2042 132834 [Cellular] [ERROR] prvNetworkRecv failed 10

2043 132835 [Cellular] mbedTLS: |2| 0x2000d2e8: in_left: 0, nb_want: 5

2044 132836 [Cellular] mbedTLS: |2| 0x2000d2e8: ssl->f_recv(_timeout)() returned -27648 (-0x6c00)

2045 132839 [Cellular] mbedTLS: |1| 0x2000d2e8: mbedtls_ssl_fetch_input() returned -27648 (-0x6c00)

2046 132840 [Cellular] mbedTLS: |1| 0x2000d2e8: ssl_get_next_record() returned -27648 (-0x6c00)

2047 132841 [Cellular] mbedTLS: |1| 0x2000d2e8: mbedtls_ssl_read_record() returned -27648 (-0x6c00)

2048 132842 [Cellular] [ERROR] Failed to read data: mbedTLSError= SSL - Internal error (eg, unexpected failure in lower-level module) : .

Hi Adam,

Thank you for your interesting in cellular library.
It looks like you are using Lab-Project-FreeRTOS-Cellular-Demo repository to run SARA-R4 demo application.

The SARA-R4 demo is moved to FreeRTOS repository. It is suggested to use this SARA-R4 mqtt demo in FreeRTOS repository.

If you are not using windows simulator, please provide your platform information then we can better understand your problem.

I am using building the project on a stm32

I have tried just having MQTT_ProcessLoop(&xMQTTContext, mqttexamplePROCESS_LOOP_TIMEOUT_MS); without a subscribe (ie just ping the server) and i have the same issue

Hi Adam,

From your log, the following response looks different from the AT command document.

AT+USORD=0,5

+USORD: 0,0,""

From the AT command document, if there is no data to receive it will return the following.

SARA-R4 / SARA-N4
In case there are no bytes returned or available, the parameter is omitted in the information
text response to the set command.
Example: information text response does not have any length information.
AT+USORD=0,7
+USORD: 0,“”
OK

Can you help to try the following patch? If this is the problem, we can create PR to the repository.

diff --git a/modules/sara_r4/cellular_r4_api.c b/modules/sara_r4/cellular_r4_api.c
index c0b5949..e348de4 100644
--- a/modules/sara_r4/cellular_r4_api.c
+++ b/modules/sara_r4/cellular_r4_api.c
@@ -342,7 +342,7 @@ static CellularPktStatus_t _Cellular_RecvFuncData( CellularContext_t * pContext,
                 }

                 /* Process the data buffer. */
-                if( atCoreStatus == CELLULAR_AT_SUCCESS )
+                if( ( atCoreStatus == CELLULAR_AT_SUCCESS ) && ( *pDataRecv->pDataLen > 0U ) )
                 {
                     atCoreStatus = getDataFromResp( pAtResp, pDataRecv, *pDataRecv->pDataLen );
                 }
1 Like

Thank You, that solved the issue ! could you notify me when the pull request has been approved so I can include it in my code ?

No problem. Once it is merged, I will update in this thread.
Thank you for your feedback.

Hi Adam,

This patch is merged in this commit.
Thank you for your feedback.

1 Like