예제 #1
0
파일: lights.cpp 프로젝트: 0x27/redalert
void checkSerialAPI(){
    xbee.readPacket();
    
    if (xbee.getResponse().isAvailable()) {
      
      if (xbee.getResponse().getApiId() == ZB_RX_RESPONSE) {
        xbee.getResponse().getZBRxResponse(rx);
            
        if (rx.getOption() == ZB_PACKET_ACKNOWLEDGED) {
        } else {}
        
        int len = rx.getDataLength();
        char m[len+1];
        for(int i=0;i<len;i++){
          m[i]=rx.getData(i);
        }
        m[len]='\0';

        splitString(m, CMD,DEL,BRI, R, G ,B, TOUT);
        t=millis() + TOUT * 1000;
        
      } else if (xbee.getResponse().getApiId() == MODEM_STATUS_RESPONSE) {
        xbee.getResponse().getModemStatusResponse(msr);
        if (msr.getStatus() == ASSOCIATED) {} 
        else if (msr.getStatus() == DISASSOCIATED) {} 
        else {}
      } else {}
    } else if (xbee.getResponse().isError()) {}
}
예제 #2
0
// Waits for the "Associated" modem status message 
uint8_t EndDevice::formingNetwork() {
	DEBUG_MSG("[FORMING NETWORK]");
	if (hasTimedOut()) {
		DEBUG_MSG("TIMEOUT");
		State = EndDeviceError;
		return TICK_ASSOC_FAIL;
		// TODO: Check association status and return appropriate error message.
	}
	if (xbee.getResponse().isAvailable()) {
		if (xbee.getResponse().getApiId() == MODEM_STATUS_RESPONSE) {
			ModemStatusResponse msr;
			xbee.getResponse().getModemStatusResponse(msr);
			if (msr.getStatus() == ASSOCIATED) {
				disableTimeout();
				State = EndDeviceJoiningSend;
			} else {
				// TODO: Not associated meddelande
			}
		} else {
			// TODO: Annan meddelande-typ
		}
	}
	return TICK_OK;
}
예제 #3
0
파일: Printers.cpp 프로젝트: Introsys/fresh
void printResponseCb(ModemStatusResponse& status, uintptr_t data) {
	Print *p = (Print*)data;
	p->println("ModemStatusResponse received:");
	printField(p, F("  Status: 0x"), status.getStatus());
}