Quantcast
Channel: panStamp forum - All Forums
Viewing all articles
Browse latest Browse all 473

Understanding Modem code

$
0
0
Hello,
i have revised the code the post to be more specific.i want to know the flow of handleSerialCMD function, how does it work and how the strSerial variable get's filled.
because there are the lines calling it:
Code:
if (ch == 0x0D)  
    {
  
      STOP_TIMER();
      strSerial[len] = 0;
      handleSerialCmd(strSerial);
but as you see we are putting 0 in it and i don't understand how this function triggers and how strSerial gets filled.[/code]
Code:
* handleSerialCmd

void handleSerialCmd(char* command)        
{
  byte i, len;
  byte arrV[2];
  CCPACKET packet;
  ATQUERY atQuery = ATQUERY_REQUEST;  

  // Data mode?
  if (serMode == SERMODE_DATA)
  {
    packet.length = strlen(command)/2;
    
    if (packet.length > 0)
    {
      // Convert ASCII string into array of bytes
      for(i=0 ; i<packet.length ; i++)
      {    
        packet.data[i] = charToHex(command[i*2]) << 4;  
        packet.data[i] |= charToHex(command[i*2 + 1]);
      }
      // Send packet via RF
      panstamp.radio.sendData(packet);
    }
  }
  // Command mode?
  else  // serMode = SERMODE_COMMAND
  {
    len = strlen(command);
    Serial.print("AT Mode");
    if (len < 5)
    {
      // Basic attention command
      if (!strcmp(strSerial, AT_ATTENTION))
        Serial.print("AT Mode down");
}

i have tried to send the commands as :
+++ it works;
but any other command e.g
AT or \rAT does not work.

lastly i want to ask can we send these commands from a remote node via wireless to modem because right now i am using IDE serial monitor to send the commands.

Viewing all articles
Browse latest Browse all 473

Trending Articles