Sending I2CWR command with Cellular lib

Hello,

AT#I2CWR=2,3,30,4,19\r
“> 00109000100A33000000494906062D00400060\032(ctrl-z)”
OK

When I send the command in line 1, it returns "> " as a reply. Then I need to send data as in line 2 with ctrl-z terminator. Then it returns the final response.

How can I do that with cellular lib.
Can u help?

Thank u and best regards

@doodle
Thank you for your interest in cellular interface. It looks like you are sending the binary data to modem.

Sending binary data to cellular modem is split into two steps:

  • Send the AT command.
AT#I2CWR=2,3,30,4,19\r
>                             // ">" is used to indicate that modem is ready to receive binary data
  • Send the binary data
00109000100A33000000494906062D00400060\032(ctrl-z)
OK                           // Modem replies "OK" to indicate binary stream is received successfully.

_Cellular_AtcmdDataSend API can be used to send the binary data to cellular modem.

* The structure to send the AT command. Mapping to the first step of send binary data. */
CellularAtReq_t atReqSocketSend =
{
    .pAtCmd = cmdBuf,                    /* In this example, "AT#I2CWR=2,3,30,4,19". */
    .atCmdType = CELLULAR_AT_NO_RESULT,  /* The command expects only result code to indicate status from modem. */
    .pAtRspPrefix = NULL,                /* No prefix for the result since the type is CELLULAR_AT_NO_RESULT. */
    .respCallback = NULL,                /* No response callback since the type is CELLULAR_AT_NO_RESULT. */
    .pData = NULL,                       /* No data since the type is CELLULAR_AT_NO_RESULT. */
    .dataLen = 0,                        /* Data length is 0. */
};
 
/* The structure to send the binary data. Mapping to the second step of send binary data. */
CellularAtDataReq_t atDataReqSocketSend =
{
    .pData = pData,                      /* Point to the data to send. */
    .dataLen = dataLength,               /* The length of the data to send. */
    .pSentDataLength = pSentDataLength,  /* The actual data sent to the modem. */
    .pEndPattern = NULL,                 /* The end pattern to send after the binary data. */
    .endPatternLen = 0                   /* The length of the end pattern. */
};
 
/* The send binary data send API in cellular common layer. */
pktStatus = _Cellular_AtcmdDataSend( pContext,                  /* The cellular context. */
                                     atReqSocketSend,           /* Send AT command request. */
                                     atDataReqSocketSend,       /* Send binary data. */
                                     socketSendDataPrefix,      /* Data prefix callback. BG96 port fix the input stream "> " in this function. */
                                     NULL,                      /* Data prefix callback context. Not used in this example. */
                                     PACKET_REQ_TIMEOUT_MS,     /* AT command send timeout. */
                                     sendTimeout,               /* Binary data send timeout. */
                                     0U );                      /* The delay between AT command and binary data. */

One thing to be noted is that cellular interface process the input stream in lines. If your modem replys only “>” instead of "> ( line changing symbol like \r or \n ), socketSendDataPrefix implementation in BG96 reference port can be referenced.

You can give this API a try and feedback further problem. We would like to discuss with you in this thread.

Thanks for the fast reply. I tried and its worked.