@@ -974,6 +974,51 @@ static void prvInputBufferCommIntfRecvCallback( void )
974974 pCommIntfRecvCustomString = URC_DATA_CALLBACK_MATCH_STR_PART2 ;
975975}
976976
977+ static CellularPktStatus_t prvPacketCallbackError ( CellularContext_t * pContext ,
978+ _atRespType_t atRespType ,
979+ const void * pBuffer )
980+ {
981+ const CellularATCommandResponse_t * pAtResp = ( const CellularATCommandResponse_t * ) pBuffer ;
982+
983+ ( void ) pContext ;
984+
985+ /* Verify the response type is AT_SOLICITED. */
986+ TEST_ASSERT_EQUAL ( AT_SOLICITED , atRespType );
987+
988+ /* Verify that no item is added to the response. */
989+ TEST_ASSERT_NOT_EQUAL ( NULL , pAtResp );
990+ TEST_ASSERT_EQUAL ( NULL , pAtResp -> pItm );
991+
992+ /* Verify that the response indicate error. */
993+ TEST_ASSERT_EQUAL ( false, pAtResp -> status );
994+
995+ return CELLULAR_PKT_STATUS_OK ;
996+ }
997+
998+ static CellularPktStatus_t prvPacketCallbackSuccess ( CellularContext_t * pContext ,
999+ _atRespType_t atRespType ,
1000+ const void * pBuffer )
1001+ {
1002+ const CellularATCommandResponse_t * pAtResp = ( const CellularATCommandResponse_t * ) pBuffer ;
1003+ int cmpResult ;
1004+
1005+ ( void ) pContext ;
1006+
1007+ /* Verify the response type is AT_SOLICITED. */
1008+ TEST_ASSERT_EQUAL ( AT_SOLICITED , atRespType );
1009+
1010+ /* Verify the string is the same as expected. */
1011+ TEST_ASSERT_NOT_EQUAL ( NULL , pAtResp );
1012+ TEST_ASSERT_NOT_EQUAL ( NULL , pAtResp -> pItm );
1013+ TEST_ASSERT_NOT_EQUAL ( NULL , pAtResp -> pItm -> pLine );
1014+ cmpResult = strncmp ( pAtResp -> pItm -> pLine , pCommIntfRecvCustomString , strlen ( pAtResp -> pItm -> pLine ) );
1015+ TEST_ASSERT_EQUAL ( 0 , cmpResult );
1016+
1017+ /* Verify that the response indicate error. */
1018+ TEST_ASSERT_EQUAL ( true, pAtResp -> status );
1019+
1020+ return CELLULAR_PKT_STATUS_OK ;
1021+ }
9771022
9781023/* ========================================================================== */
9791024
@@ -2141,6 +2186,180 @@ void test__Cellular_PktioInit_Thread_Rx_Data_Event_CELLULAR_AT_WO_PREFIX_STRING_
21412186 TEST_ASSERT_EQUAL ( CELLULAR_PKT_STATUS_OK , pktStatus );
21422187}
21432188
2189+ /**
2190+ * @brief _processIntermediateResponse - Successfully handle AT command type CELLULAR_AT_WO_PREFIX_NO_RESULT_CODE.
2191+ *
2192+ * Successfully handle at command type CELLULAR_AT_WO_PREFIX_NO_RESULT_CODE. Verify
2193+ * the response string in the callback function.
2194+ *
2195+ * <b>Coverage</b>
2196+ * @code{c}
2197+ * case CELLULAR_AT_WO_PREFIX_NO_RESULT_CODE:
2198+ * ...
2199+ * _saveATData( pLine, pResp );
2200+ *
2201+ * pktStatus = CELLULAR_PKT_STATUS_OK;
2202+ * break;
2203+ * @endcode
2204+ * The CELLULAR_AT_WO_PREFIX_NO_RESULT_CODE case.
2205+ */
2206+ void test__Cellular_PktioInit_Thread_Rx_Data_Event_CELLULAR_AT_WO_PREFIX_NO_RESULT_CODE_success ( void )
2207+ {
2208+ CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK ;
2209+ CellularContext_t context ;
2210+ CellularCommInterface_t * pCommIntf = & CellularCommInterface ;
2211+
2212+ threadReturn = true;
2213+ memset ( & context , 0 , sizeof ( CellularContext_t ) );
2214+
2215+ /* copy the token table. */
2216+ ( void ) memcpy ( & context .tokenTable , & tokenTable , sizeof ( CellularTokenTable_t ) );
2217+
2218+ /* Assign the comm interface to pContext. */
2219+ context .pCommIntf = pCommIntf ;
2220+ context .pPktioShutdownCB = _shutdownCallback ;
2221+
2222+ /* Test the rx_data event with CELLULAR_AT_WO_PREFIX resp. */
2223+ pktioEvtMask = PKTIO_EVT_MASK_RX_DATA ;
2224+ recvCount = 1 ;
2225+ atCmdType = CELLULAR_AT_WO_PREFIX_NO_RESULT_CODE ;
2226+ testCommIfRecvType = COMM_IF_RECV_CUSTOM_STRING ;
2227+ pCommIntfRecvCustomString = "12345\r\n" ; /* Dummy string to be verified in the callback. */
2228+
2229+ /* Check that CELLULAR_PKT_STATUS_OK is returned. */
2230+ pktStatus = _Cellular_PktioInit ( & context , prvPacketCallbackSuccess );
2231+
2232+ /* Verification. */
2233+ TEST_ASSERT_EQUAL ( CELLULAR_PKT_STATUS_OK , pktStatus );
2234+
2235+ /* The result is verified in prvPacketCallbackSuccess. */
2236+ }
2237+
2238+ /**
2239+ * @brief _processIntermediateResponse - Modem returns error when sending AT command type CELLULAR_AT_WO_PREFIX_NO_RESULT_CODE.
2240+ *
2241+ * Modem returns error when sending AT command type CELLULAR_AT_WO_PREFIX_NO_RESULT_CODE.
2242+ */
2243+ void test__Cellular_PktioInit_Thread_Rx_Data_Event_CELLULAR_AT_WO_PREFIX_NO_RESULT_CODE_error ( void )
2244+ {
2245+ CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK ;
2246+ CellularContext_t context ;
2247+ CellularCommInterface_t * pCommIntf = & CellularCommInterface ;
2248+
2249+ threadReturn = true;
2250+ memset ( & context , 0 , sizeof ( CellularContext_t ) );
2251+
2252+ /* copy the token table. */
2253+ ( void ) memcpy ( & context .tokenTable , & tokenTable , sizeof ( CellularTokenTable_t ) );
2254+
2255+ /* Assign the comm interface to pContext. */
2256+ context .pCommIntf = pCommIntf ;
2257+ context .pPktioShutdownCB = _shutdownCallback ;
2258+
2259+ /* Test the rx_data event with CELLULAR_AT_WO_PREFIX resp. */
2260+ pktioEvtMask = PKTIO_EVT_MASK_RX_DATA ;
2261+ recvCount = 1 ;
2262+ atCmdType = CELLULAR_AT_WO_PREFIX_NO_RESULT_CODE ;
2263+ testCommIfRecvType = COMM_IF_RECV_CUSTOM_STRING ;
2264+ pCommIntfRecvCustomString = "ERROR\r\n" ; /* Return one of the error token. */
2265+
2266+ /* Check that CELLULAR_PKT_STATUS_OK is returned. */
2267+ pktStatus = _Cellular_PktioInit ( & context , prvPacketCallbackError );
2268+
2269+ /* Verification. */
2270+ TEST_ASSERT_EQUAL ( CELLULAR_PKT_STATUS_OK , pktStatus );
2271+
2272+ /* The result is verified in prvPacketCallbackError. */
2273+ }
2274+
2275+
2276+ /**
2277+ * @brief _processIntermediateResponse - Successfully handle AT command type CELLULAR_AT_WITH_PREFIX_NO_RESULT_CODE.
2278+ *
2279+ * Successfully handle at command type CELLULAR_AT_WITH_PREFIX_NO_RESULT_CODE. Verify
2280+ * the response string in the callback function.
2281+ *
2282+ * <b>Coverage</b>
2283+ * @code{c}
2284+ * case CELLULAR_AT_WITH_PREFIX_NO_RESULT_CODE:
2285+ * _saveATData( pLine, pResp );
2286+ *
2287+ * pkStatus = CELLULAR_PKT_STATUS_OK;
2288+ * break;
2289+ * @endcode
2290+ * The CELLULAR_AT_WITH_PREFIX_NO_RESULT_CODE case.
2291+ */
2292+ void test__Cellular_PktioInit_Thread_Rx_Data_Event_CELLULAR_AT_WITH_PREFIX_NO_RESULT_CODE_success ( void )
2293+ {
2294+ CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK ;
2295+ CellularContext_t context ;
2296+ CellularCommInterface_t * pCommIntf = & CellularCommInterface ;
2297+
2298+ threadReturn = true;
2299+ memset ( & context , 0 , sizeof ( CellularContext_t ) );
2300+
2301+ /* copy the token table. */
2302+ ( void ) memcpy ( & context .tokenTable , & tokenTable , sizeof ( CellularTokenTable_t ) );
2303+
2304+ /* Assign the comm interface to pContext. */
2305+ context .pCommIntf = pCommIntf ;
2306+ context .pPktioShutdownCB = _shutdownCallback ;
2307+
2308+ /* Test the rx_data event with CELLULAR_AT_WO_PREFIX resp. */
2309+ pktioEvtMask = PKTIO_EVT_MASK_RX_DATA ;
2310+ recvCount = 1 ;
2311+ atCmdType = CELLULAR_AT_WITH_PREFIX_NO_RESULT_CODE ;
2312+ testCommIfRecvType = COMM_IF_RECV_CUSTOM_STRING ;
2313+ context .pRespPrefix = "+CMD_PREFIX" ;
2314+ pCommIntfRecvCustomString = "+CMD_PREFIX:12345\r\n" ; /* Dummy string to be verified in the callback. */
2315+
2316+ /* Check that CELLULAR_PKT_STATUS_OK is returned. */
2317+ pktStatus = _Cellular_PktioInit ( & context , prvPacketCallbackSuccess );
2318+
2319+ /* Verification. */
2320+ TEST_ASSERT_EQUAL ( CELLULAR_PKT_STATUS_OK , pktStatus );
2321+
2322+ /* The result is verified in prvPacketCallbackSuccess. */
2323+ }
2324+
2325+ /**
2326+ * @brief _processIntermediateResponse - Modem returns error when sending AT command type CELLULAR_AT_WITH_PREFIX_NO_RESULT_CODE.
2327+ *
2328+ * Modem returns error when sending AT command type CELLULAR_AT_WITH_PREFIX_NO_RESULT_CODE.
2329+ */
2330+ void test__Cellular_PktioInit_Thread_Rx_Data_Event_CELLULAR_AT_WITH_PREFIX_NO_RESULT_CODE_error ( void )
2331+ {
2332+ CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK ;
2333+ CellularContext_t context ;
2334+ CellularCommInterface_t * pCommIntf = & CellularCommInterface ;
2335+
2336+ threadReturn = true;
2337+ memset ( & context , 0 , sizeof ( CellularContext_t ) );
2338+
2339+ /* copy the token table. */
2340+ ( void ) memcpy ( & context .tokenTable , & tokenTable , sizeof ( CellularTokenTable_t ) );
2341+
2342+ /* Assign the comm interface to pContext. */
2343+ context .pCommIntf = pCommIntf ;
2344+ context .pPktioShutdownCB = _shutdownCallback ;
2345+
2346+ /* Test the rx_data event with CELLULAR_AT_WO_PREFIX resp. */
2347+ pktioEvtMask = PKTIO_EVT_MASK_RX_DATA ;
2348+ recvCount = 1 ;
2349+ atCmdType = CELLULAR_AT_WITH_PREFIX_NO_RESULT_CODE ;
2350+ testCommIfRecvType = COMM_IF_RECV_CUSTOM_STRING ;
2351+ context .pRespPrefix = "+CMD_PREFIX" ;
2352+ pCommIntfRecvCustomString = "ERROR\r\n" ; /* Return one of the error token. */
2353+
2354+ /* Check that CELLULAR_PKT_STATUS_OK is returned. */
2355+ pktStatus = _Cellular_PktioInit ( & context , prvPacketCallbackError );
2356+
2357+ /* Verification. */
2358+ TEST_ASSERT_EQUAL ( CELLULAR_PKT_STATUS_OK , pktStatus );
2359+
2360+ /* The result is verified in prvPacketCallbackError. */
2361+ }
2362+
21442363/**
21452364 * @brief Test thread receiving rx data event with success token for _Cellular_PktioInit to return CELLULAR_PKT_STATUS_OK.
21462365 */
0 commit comments