SrSryrsHub::SrSryrsHub() :hubSerial(Serial) ,lcd(LCD_RS, LCD_RW, LCD_Enable, LCD_D4, LCD_D5, LCD_D6, LCD_D7) ,xbee(XBee()) ,remoteAtRequest(RemoteAtCommandRequest(xba64, NULL, NULL, sizeof(NULL))) ,remoteAtResponse(RemoteAtCommandResponse()) ,ioSample(ZBRxIoSampleResponse()) ,ip(IP0, IP1, IP2, IP3) #ifdef USING_COSM ,cosmAPIKey(COSM_API_KEY) ,cosmUserAgent(COSM_USER_AGENT) ,cosmServer(COSM_IP0, COSM_IP1, COSM_IP2, COSM_IP3)//(216,52,233,122) ,cosmClient(client) ,cosmShareFeed(COSM_SHARE_FEED_ID, cosmShareDataStreams, 1) ,cosmControlFeed(COSM_CONTROL_FEED_ID, cosmControlDataStreams, 1) #endif //USING_COSM // ,server(SERVER_NUM) { /////////////////////////////////// ///// Microcontroller ///// /////////////////////////////////// internalLed = INTERNAL_LED; //////////////////////// ////// LCD ///// //////////////////////// //////////////////////// ///// XBee ///// //////////////////////// // //////////////////////////// ///// Ethernet ///// //////////////////////////// mac[0] = MAC_0; mac[1] = MAC_1; mac[2] = MAC_2; mac[3] = MAC_3; mac[4] = MAC_4; mac[5] = MAC_5; //////////////////////// ///// COSM ///// //////////////////////// #ifdef USING_COSM cosmControlVal = 0; cosmShareFeedID = COSM_SHARE_FEED_ID; cosmControlFeedID = COSM_CONTROL_FEED_ID; #endif USING_COSM }
/* Send a DB request to a specific node. This is the new function all the other request forward their code to. **/ void LithneClass::sendDBRequest( XBeeAddress64 _addr64, uint16_t _addr16 ) { /* Serial.print("Opening DB req. on node "); Serial.print(getNodeBy64( _addr64 )->getID()); Serial.print(" from 16 bit add "); Serial.print( _addr16 ); Serial.print(" and 64 bit add "); Serial.print( _addr64.getMsb() , HEX ); Serial.print( ", "); Serial.println( _addr64.getLsb() , HEX );*/ RemoteAtCommandRequest db; /* If we know the 16 bit address, we transmit to that */ if( _addr16 != UNKNOWN_16B ) { db = RemoteAtCommandRequest( _addr16, atDB ); // If the 64 bit add is not a broadcast, we set that add as well. if ( _addr64.getMsb() != 0x0 || _addr64.getLsb() != 0xFFFF ) { db.setRemoteAddress64( _addr64 ); } /* Open the request on the node we transmit the DB request to */ if (nodeKnown16( _addr16 ) ) { getNodeBy16( _addr16 )->openDBRequest(); } } /* If we don't know the 16 bit address, we use the 64 bit, at least if we know it */ else // if ( _addr64 != NULL ) // unfortunately, we can't put NULL as a 64 bit address { db = RemoteAtCommandRequest( _addr64, atDB ); /* If we broadcast the DB request, open the node request on all nodes */ if ( _addr64.getMsb() == 0x0 && _addr64.getLsb() == 0xFFFF ) { for(uint16_t i=0; i< numNodes; i++) { nodes[i]->openDBRequest(); } } /* Otherwise, we open the request on the node we transmit the DB request to */ else { Node * receiverNode = getNodeBy64( _addr64 ); if (receiverNode != NULL) { receiverNode->openDBRequest(); /* Serial.print("Found node by 64bit add to send DB request to; node ID: "); Serial.println( receiverNode->getID() ); */ } } /*Serial.print("Opened DB req. on node "); Serial.print(getNodeBy64( _addr64 )->getID()); Serial.print(" from 64 bit add "); Serial.println( _addr64.getLsb() ); */ } /* Transmit the request */ /*Serial.print("Transmitting DB Request:"); for (int i = 0; i < db.getFrameDataLength (); i++) { Serial.print(db.getFrameData(i),HEX); Serial.print(" "); } Serial.println();*/ xbee.send( db ); }
char* simbol_ascii[2]; char cmd; XBeeResponse response = XBeeResponse(); //Это создает экземпляр объекта "response" "ответ" обрабатывать пакеты Xbee ZBRxResponse rx = ZBRxResponse(); //Это создает экземпляр объекта "rx" на процесс Xbee Series 2 API пакеты ModemStatusResponse msr = ModemStatusResponse(); //Это создает экземпляр объекта "msr" процесс associate/disassociate packets (PAN membership) ZBRxIoSampleResponse ioSample = ZBRxIoSampleResponse(); XBeeAddress64 addr64 = XBeeAddress64(XBee_Addr64_MS, XBee_Addr64_LS); // SH + SL Address of receiving XBee ZBTxRequest zbTx = ZBTxRequest(addr64, payload, sizeof(payload)); // Формирует пакет zbTx с адресом отправителя и данными ZBTxStatusResponse txStatus = ZBTxStatusResponse(); // Это создает экземпляр объекта "txStatus" процесс благодарности прислал Xbee Series 2 API пакеты AtCommandRequest atRequest = AtCommandRequest(shCmd); // XBeeAddress64 remoteAddress = XBeeAddress64(XBee_Addr64_MS, XBee_Addr64_LS); AtCommandRequest arRequestMod = AtCommandRequest(command, commandValue, commandValueLength); AtCommandResponse atResponse = AtCommandResponse(); RemoteAtCommandRequest remoteAtRequest = RemoteAtCommandRequest(addr64, irCmd, irValue, sizeof(irValue)); // Create a remote AT request with the IR command RemoteAtCommandResponse remoteAtResponse = RemoteAtCommandResponse(); // Create a Remote AT response object XBeeActive RealXBeeMenu; void XBeeActive::setup() { xbee.begin(Serial1); DEBAG.println("\nXBee setup"); } void XBeeActive::sendAtCommand() { int i10; xbee.send(atRequest); if (xbee.readPacket(5000)) // подождите до 5 секунд для ответа состояния {