shubhamj84 / xbee-arduino

Automatically exported from code.google.com/p/xbee-arduino
GNU General Public License v2.0
0 stars 0 forks source link

Can't scan my xbee network #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I try to send an 'ND' at Command but only get packet error 3 :-(

Here's the code : 

uint8_t shCmd[] = {
  'N','D'    };
AtCommandRequest atRequest = AtCommandRequest(shCmd);
AtCommandResponse atResponse = AtCommandResponse();

void initScan()
{
  lcd.clear();
  lcd.printIn("Scan");
  lcd.cursorTo(2, 0);
  lcd.printIn("             RET");
  xbee.send(atRequest);
  if (xbee.readPacket(5000))
  {
    if (xbee.getResponse().getApiId() == AT_COMMAND_RESPONSE) 
    {
      xbee.getResponse().getAtCommandResponse(atResponse);
      if (atResponse.isOk()) {
        if(('N' == atResponse.getCommand()[0]) && ('D' == atResponse.getCommand()[0]))
        {
          if (0<atResponse.getValueLength()) 
          {
            lcd.cursorTo(2,1);
            word aShortAddr = atResponse.getValue()[0]<<8 | atResponse.getValue()[1];
            sprintf(aBuf,"Found : %4x",aShortAddr);
            lcd.printIn(aBuf);
          }
        }
      }
      else
      {
        lcd.cursorTo(2,1);
        sprintf(aBuf,"Cmd Err : %x",atResponse.getStatus());
        lcd.printIn(aBuf);
      }
    }
    else
    {
      lcd.cursorTo(2,1);
      sprintf(aBuf,"AT Err : %x",atResponse.getApiId());
      lcd.printIn(aBuf);
    }
  }
  else
  { 
    if (xbee.getResponse().isError()) {
      lcd.cursorTo(2,1);
      sprintf(aBuf,"Pkt Err : %x",xbee.getResponse().getErrorCode());
      lcd.printIn(aBuf);
    } 
    else {
      lcd.cursorTo(2,1);
      lcd.printIn(" No Answer");   
    }
  }
  changed = false;
}

Original issue reported on code.google.com by david.ol...@gmail.com on 7 Jun 2010 at 9:41

GoogleCodeExporter commented 9 years ago
Error 3  is UNEXPECTED_START_BYTE.  Are you sure you're in API mode 2?

Original comment by andrew.rapp@gmail.com on 3 Apr 2011 at 2:38

GoogleCodeExporter commented 9 years ago

Original comment by andrew.rapp@gmail.com on 12 Oct 2011 at 4:54