Пример #1
0
void printErrorCb(RemoteAtCommandResponse& r, uintptr_t data) {
	Print *p = (Print*)data;
	if (!r.isOk()) {
		p->print(F("Error sending remote "));
		p->write(r.getCommand(), 2);
		p->print(F(" command. Status: "));
		p->println(r.getStatus());
	}
}
Пример #2
0
void XBeeActive::sendRemoteAtCommand()
{
	DEBAG.println("\nSending command sendRemoteAtCommand to the XBee");
	xbee.send(remoteAtRequest);

	// wait up to 5 seconds for the status response
	if (xbee.readPacket(5000))
	{
		// got a response!

		// should be an AT command response
		if (xbee.getResponse().getApiId() == REMOTE_AT_COMMAND_RESPONSE)
		{
			xbee.getResponse().getRemoteAtCommandResponse(remoteAtResponse);

			if (remoteAtResponse.isOk()) {
				DEBAG.print("Command [");
				DEBAG.print(remoteAtResponse.getCommand()[0]);
				DEBAG.print(remoteAtResponse.getCommand()[1]);
				DEBAG.println("] was successful!");

				if (remoteAtResponse.getValueLength() > 0) {
					DEBAG.print("Command value length is ");
					DEBAG.println(remoteAtResponse.getValueLength(), DEC);

					DEBAG.print("Command value: ");

					for (int i = 0; i < remoteAtResponse.getValueLength(); i++) {
						DEBAG.print(remoteAtResponse.getValue()[i], HEX);
						DEBAG.print(" ");
					}

					DEBAG.println("");
				}
			}
			else {
				DEBAG.print("Command returned error code: ");
				DEBAG.println(remoteAtResponse.getStatus(), HEX);
			}
		}
		else
		{
			DEBAG.print("Expected Remote AT response but got ");
			DEBAG.print(xbee.getResponse().getApiId(), HEX);
		}
	}
	else if (xbee.getResponse().isError())
	{
		DEBAG.print("Error reading packet.  Error code: ");
		DEBAG.println(xbee.getResponse().getErrorCode());
	}
	else
	{
		DEBAG.print("No response from radio3");
	}
}
Пример #3
0
void printResponseCb(RemoteAtCommandResponse& at, uintptr_t data) {
	Print *p = (Print*)data;
	p->println("AtRemoteCommandResponse received:");
	printField(p, F("  To: 0x"), at.getRemoteAddress64());
	printField(p, F("  To: 0x"), at.getRemoteAddress16());
	p->print(F("  Command: "));
	p->write(at.getCommand(), 2);
	p->println();
	printField(p, F("  Status: 0x"), at.getStatus());
	if (at.getValueLength()) {
		p->print(F("  Value: "));
		printHex(*p, at.getValue(), at.getValueLength(), F(" "), NULL);
		p->println();
	}
}