How to use cellular api simply

Hi,

Today I want to talk about how to use cellular api simply. OK, follow our guide of developer website:
https://doc.rakwireless.com/developer-tools/developer-tools/-

In cellular part, the most important api is:

  1. RUI_RETURN_STATUS rui_cellular_send(uint8_t *cmd)
  2. RUI_RETURN_STATUS rui_cellular_response(uint8_t *rsp, uint32_t len, uint32_t timeout)

The rui_cellular_send is for sending AT command to BG96 with Quectel format, not send data to any server.You could use like:
rui_cellular_send(“ATI”)

The rui_cellular_response is for recieving AT response from BG96 with Quectel format. You can use like:

uint8_t tmp[256] = {0};
rui_cellular_send(“AT+CPIN?”);
rui_cellular_response(tmp, 256, 1000);

The timeout depends on different AT response time of BG96. All log about this part will send via uart, usb, RTT log. So do not use rui_uart_send send response to uart anymore.

OK, end here today!!

Notes:
If AT of bg96 is like this:
AT+QIOPEN=1,0,“TCP”,"","",0,1
This command will response soon:
OK

And then responese severals seconds if connected ok!!:
+QIOPEN:0,0

So you should do as below:
rui_cellular_send(“AT+QIOPEN=1,0,“TCP”,“ip”,“port”,0,1”)
rui_cellular_response(tmp, 256, 1000);// wait ok
memset(tmp,0,256);
rui_cellular_response(tmp, 256, 10000);//wait for next!!!

It is the same with all AT of BG96 responses more than once!!!

  1. the rui_cellular_response is the type of block, so if it return more than once .If the OK is not last words, tihe api must be called more times. like:
    else if (strstr(gsm_cmd,“AT+QMTCONN=”)!= NULL && strstr(gsm_cmd,",")!= NULL)
    {
    rui_cellular_send(gsm_cmd);
    rui_cellular_response(gsm_rsp, 256, 500 * 2);
    memset(gsm_rsp,0,256);
    rui_cellular_response(gsm_rsp, 256, 500 * 15);
    }
    Response
    OK //call rui_cellular_response first time to get
    +QMTCONN: ,[,<ret_code>] // call rui_cellular_response second time to get

  2. if the OK or ERROR is the last words of at response, just call once, like:
    rui_cellular_send(“AT+QMTCLOSE=?”)
    rui_cellular_response(gsm_rsp, 256, 500 * 2);
    Here just need call once for below:
    Response
    +QMTCLOSE: (list of supported s)
    OK