Error trying to set up a CoAP Client in BG96

Hi everyone,
I have some issues when I want to set up a CoAP client in my BG96 module. The aim of the project is simple, the BG96 module get some parameters of the Cat-NB1 network that the module is attached, after that the module should send these values to a CoAP server I deployed using the known python project CoAPthon. It is very easy to use. The trouble is in the client side, I don’t understand why no works.

This is the code I have written in the Arduino IDE, between the ATresponse functions’ parentheses we can see which AT Commands I used. The sequence is very similar to the CoAP Manual example of the BG96 module:

void openCoAPClient(String s, int c){
   //Openning and settlement of the CoAP client
   ATresponse("AT+QCOAPCFG=\"pdpcid\",0,1 ", 500); //Set the PDP context ID as 1 for CoAP client 0
   ATresponse("AT+QCOAPCFG=\"trans\",0,2,3", 500); //Configure retransmission settings for CoAP client 0.The ACK timeout is 2 seconds and the maximum retransmission count is 3
   ATresponse("AT+QCOAPOPEN=0,\"---.161.157.---\",5683", 500); //Create a CoAP session and connect to the CoAP server (IP Adress/Port)
   ATresponse("AT+QCOAPHEADER=0,"+String(c)+",1", 500); //Set to CoAP client 0 the CoAP message ID to 1234 and generate token automatically

   // CoAP options to be added (client ID, AddOptions?(yes=0), OptionIndex(0-7, max 8), OptionNumber, OptionValue)
   ATresponse("AT+QCOAPOPTION=0,0,0,12,0", 500); //Content-Format option: text/plain
   ATresponse("AT+QCOAPOPTION=0,0,1,15,\"coap://---.161.157.---/basic\"", 500); // Uri-Query option indicates all the URI (including the path where the resource will be posted)

   //Send CoAP message (clientID, NonConfirmable, POST, Add 0 to 1 Options, ByteLength (none means send all if msg<1024 bytes))
   ATresponse("AT+QCOAPSEND=0,1,2,3", 500);
   
   const char *cs = s.c_str();  
   
   if(Serial1.available()){
      if(String(Serial1.read()).equals(">")){
        Serial1.write(cs, sizeof(cs));
      }
   }
  
   ATresponse("AT+QCOAPCLOSE=0", 500); //Close the CoAP session after sending the payload
}

And now, these are the answer I received from every AT command:

AT+QCOAPCFG=“pdpcid”,0,1
ERROR
AT+QCOAPCFG=“trans”,0,2,3
ERROR
AT+QCOAPOPEN=0,“—.161.157.—”,5683
ERROR
AT+QCOAPHEADER=0,1,1
ERROR
AT+QCOAPOPTION=0,0,0,12,0
ERROR
AT+QCOAPOPTION=0,0,1,15,“coap://—.161.157.—:5683/basic”
ERROR
AT+QCOAPSEND=0,1,2,3
ERROR
AT+QCOAPCLOSE=0
ERROR

I wrote in this way (—.161.157.—) the IP purposely.

Is there any obvious and fatal error I cannot see ? Thanks everybody for your help!

I recommend that you try manual AT commands debugging via the UART port

@herbert.pan-Q I tried it, creating a simple AT command script and analysing in Qcom via UART0, but the issue lingers. I cannot see any CME Error code, so I don’t understand what is happening.
Are there any wrong command in my code ?
Thanks for your help!

Please monitor the TX output of MCU to determine whether there are Spaces or abnormal characters

@herbert.pan-Q no abnormal characters or spaces, only no works. It seems like the module doesn’t understand any CoAP command. I looked up if CoAP is bring-up in this module and I see that it is implemented. I don’t understand what is happening.