at command

Salve a tutti.
Premessa la mia scarsa conoscenza in materia di programmazione,chiedo aiuto su un problema.
Ho due arduino uno con shield Xbee S2 ( un end device e un coordinator).
Sto cercando di farli comunicare tra loro e ottenere il valore di RSSI utilizzando la funzione DB richiamata tramite comandi AT. Il problema è che il valore ottenuto è 0 anche quando i dispositivi si associano.
Ambedue i dispositivi sono in API mode.
Allego lo sketch che ho scritto
Vi ringrazio in anticipo per l'eventuale aiuto.

#include<XBee.h>
#include<string.h>

AtCommandRequest Request = AtCommandRequest();
AtCommandResponse Response = AtCommandResponse();
XBee xbee = XBee();
uint8_t DB[] = {'D','B'};

int timeout = 1000;



void setup() {
 xbee.begin(9600);
 delay(500);
}

void loop() {
int nodeCount = 0;
 Request.setCommand(DB);
 Serial.print("Sending command to the XBee ");
 xbee.send(Request);
 Serial.println("");
 
 while(xbee.readPacket(timeout)) {
   if (xbee.getResponse().getApiId() == AT_COMMAND_RESPONSE) {
     xbee.getResponse().getAtCommandResponse(Response);
     }
 }
 
 
 Serial.print("Results: ");
 int i=0;
   while ( i < Response.getValueLength()) {
     i++;
           }
            Serial.print(Response.getValue()[i], HEX);
           Serial.print(" ");
         
 Serial.println("");
}

Il codice devi racchiuderlo nei tag code, vedi sezione 7 del regolamento, spiega bene come fare ( pulsante </> ).
Altrimenti parte del codice può essere visualizzata male o mancare perchè interpretato come attributo del testo stesso.
Infatti il tuo codice ad un certo punto diventa con font italico

#include<XBee.h>
#include<string.h>

AtCommandRequest Request = AtCommandRequest();
AtCommandResponse Response = AtCommandResponse();
XBee xbee = XBee();
uint8_t DB[] = {'D','B'};

int timeout = 1000;



void setup() {
  xbee.begin(9600);
  delay(500);
}

void loop() {
 int nodeCount = 0;
  Request.setCommand(DB);
  Serial.print("Sending command to the XBee ");
  xbee.send(Request);
  Serial.println("");
  
  while(xbee.readPacket(timeout)) {
    if (xbee.getResponse().getApiId() == AT_COMMAND_RESPONSE) {
      xbee.getResponse().getAtCommandResponse(Response);
      }
  }
  
  
  Serial.print("Results: ");
  int i=0;
    while ( i < Response.getValueLength()) {
      i++;
            }
             Serial.print(Response.getValue(), HEX);
            Serial.print(" ");
          
  Serial.println("");
}

Mi scuso per la mancanza e ti ringrazio per averlo fatto notare :slight_smile: