示例#1
0
文件: XBee.cpp 项目: Annath/secon2013
void XBeeResponse::getZBRxResponse(XBeeResponse &rxResponse) {

	ZBRxResponse* zb = static_cast<ZBRxResponse*>(&rxResponse);

	//TODO verify response api id matches this api for this response

	// pass pointer array to subclass
	zb->setFrameData(getFrameData());
	setCommon(rxResponse);

	zb->getRemoteAddress64().setMsb((uint32_t(getFrameData()[0]) << 24) + (uint32_t(getFrameData()[1]) << 16) + (uint16_t(getFrameData()[2]) << 8) + getFrameData()[3]);
	zb->getRemoteAddress64().setLsb((uint32_t(getFrameData()[4]) << 24) + (uint32_t(getFrameData()[5]) << 16) + (uint16_t(getFrameData()[6]) << 8) + (getFrameData()[7]));
}
示例#2
0
void processRxPacket(ZBRxResponse & rx, uintptr_t) {
    DebugSerial.println(F("Message received"));
    Buffer b(rx.getData(), rx.getDataLength());
    XBeeAddress64 addr = rx.getRemoteAddress64();
//    DebugSerial.println(addr,HEX);
    if (b.len() == 4 ) {
      if (addr == 0x0013A20041629B6C) {
//        DebugSerial.println(F("0013A20041629B6C"));
        publish(F("0013A20041629B6C"), b.remove < float > ());
        return;        
      } else if (addr == 0x0013A20041629B76) {
//        DebugSerial.println(F("0013A20041629B76"));
        publish(F("0013A20041629B76"), b.remove < float > ());
        return;
      }else if (addr == 0x0013A20040D7B896) {
//        DebugSerial.println(F("0013A20040D7B896"));
        publish(F("0013A20040D7B896"), b.remove < float > ());
        return;
      }else if (addr == 0x0013A20041629B72) {
//        DebugSerial.println(F("0013A20041629B72"));
        publish(F("0013A20041629B72"), b.remove < float > ());
        return;
      }else if (addr == 0x0013A20041629B77) {
//        DebugSerial.println(F("0013A20041629B77"));
        publish(F("0013A20041629B77"), b.remove < float > ());
        return;
      } else if (addr == 0x0013A20041629B6A) {
//        DebugSerial.println(F("0013A20041629B6A"));
        publish(F("0013A20041629B6A"), b.remove < float > ());
        return;
      } else if (addr == 0x0013A20040D7B872) {
//        DebugSerial.println(F("0013A20040D7B872"));
        publish(F("0013A20040D7B872"), b.remove < float > ());
        return;
      } else if (addr == 0x0013A20040B09A44) {
//        DebugSerial.println(F("0013A20040B09A44"));
        publish(F("0013A20040B09A44"), b.remove < float > ());
        return;        
      }    
      
//      
//      else if (addr == 0x0013A20040D7B885) {
//        DebugSerial.println(F("0013A20040D7B885"));
//        publish(F("0013A20040D7B885"), b.remove < float > ());
//        return;
//      }
      
        //      DebugSerial.println(b.remove<float>());
        
    }

    
    //  this should get extended for all the xbee's

    DebugSerial.println(F("Unknown or invalid packet"));
    printResponse(rx, DebugSerial);
}
示例#3
0
void printResponseCb(ZBRxResponse& rx, uintptr_t data) {
	Print *p = (Print*)data;
	p->println(F("ZBRxResponse received:"));
	printField(p, F("  From: 0x"), rx.getRemoteAddress64());
	printField(p, F("  From: 0x"), rx.getRemoteAddress16());
	printField(p, F("  Receive options: 0x"), rx.getOption());
	if (rx.getDataLength() > 8)
		p->print("  Payload:\r\n    ");
	else
		p->print("  Payload: ");
	printHex(*p, rx.getFrameData() + rx.getDataOffset(), rx.getDataLength(), F(" "), F("\r\n    "), 8);
	p->println();
}
void ConnectOneAdapter::handleRxResponse(XBeeResponse &aResponse)
{
  ZBRxResponse rx;
  aResponse.getZBRxResponse(rx);
          
  string data((const char*) rx.getData(), rx.getDataLength());
  XBeeAddress64& addr = rx.getRemoteAddress64();
          
  // Prefix data items...
  ConnectOneDevice *dev = getOrCreateDevice(addr);

  if (data[0] == '*')
    handleMTConnectCommand(dev, data);
  else
    handleMTConnectSamples(dev, data);
}