/****************************************************************************** * @fn StubAPS_SetIntraPanChannel * * @brief This function sets the device's channel back to the NIB channel. * * @param none * * @return ZStatus_t */ ZStatus_t StubAPS_SetIntraPanChannel( void ) { uint8 currChannel; uint8 rxOnIdle; if ( channelChangeInProgress ) return ( ZFailure ); ZMacGetReq( ZMacChannel, &currChannel ); if ( currChannel == _NIB.nwkLogicalChannel ) return ( ZSuccess ); channelChangeInProgress = TRUE; // turn MAC receiver off rxOnIdle = false; ZMacSetReq( ZMacRxOnIdle, &rxOnIdle ); // set the NIB channel ZMacSetReq( ZMacChannel, &(_NIB.nwkLogicalChannel) ); // turn MAC receiver back on rxOnIdle = true; ZMacSetReq( ZMacRxOnIdle, &rxOnIdle ); // set NWK task to run nwk_setStateIdle( FALSE ); channelChangeInProgress = FALSE; return ( ZSuccess ); } /* StubAPS_SetIntraPanChannel */
/************************************************************************************************** * @fn MT_SysStackTune * * @brief ZAccel RPC interface for tuning the stack parameters to adjust performance * * @param uint8 pData - Pointer to the data. * * @return None *************************************************************************************************/ void MT_SysStackTune(uint8 *pBuf) { uint8 cmd, rtrn; cmd = pBuf[MT_RPC_POS_CMD1]; pBuf += MT_RPC_FRAME_HDR_SZ; switch (*pBuf++) { case STK_TX_PWR: rtrn = ZMacSetReq(ZMacPhyTransmitPowerSigned, pBuf); break; case STK_RX_ON_IDLE: if ((*pBuf != TRUE) && (*pBuf != FALSE)) { (void)ZMacGetReq(ZMacRxOnIdle, &rtrn); } else { rtrn = ZMacSetReq(ZMacRxOnIdle, pBuf); } break; default: rtrn = ZInvalidParameter; break; } MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_SRSP | (uint8)MT_RPC_SYS_SYS), cmd, 1, &rtrn); }
/**************************************************************************** * @fn ZDiagsRestoreStatsFromNV * * @brief Restores the statistics table from NV into the RAM table. * * @param none. * * @return ZSuccess - if NV data was restored from NV. * ZFailure - Otherwise, NV_OPER_FAILED for failure. */ uint8 ZDiagsRestoreStatsFromNV( void ) { uint8 retValue = ZFailure; #if defined ( FEATURE_SYSTEM_STATS ) // restore diagnostics table from NV into RAM table if ( osal_nv_read( ZCD_NV_DIAGNOSTIC_STATS, 0, (uint16)sizeof( DiagStatistics_t ), &DiagsStatsTable ) == SUCCESS ) { // restore MAC values into the PIB ZMacSetReq( ZMacDiagsRxCrcPass, (uint8 *)&(DiagsStatsTable.MacRxCrcPass) ); ZMacSetReq( ZMacDiagsRxCrcFail, (uint8 *)&(DiagsStatsTable.MacRxCrcFail) ); ZMacSetReq( ZMacDiagsRxBcast, (uint8 *)&(DiagsStatsTable.MacRxBcast) ); ZMacSetReq( ZMacDiagsTxBcast, (uint8 *)&(DiagsStatsTable.MacTxBcast) ); ZMacSetReq( ZMacDiagsRxUcast, (uint8 *)&(DiagsStatsTable.MacRxUcast) ); ZMacSetReq( ZMacDiagsTxUcast, (uint8 *)&(DiagsStatsTable.MacTxUcast) ); ZMacSetReq( ZMacDiagsTxUcastRetry, (uint8 *)&(DiagsStatsTable.MacTxUcastRetry) ); ZMacSetReq( ZMacDiagsTxUcastFail, (uint8 *)&(DiagsStatsTable.MacTxUcastFail) ); retValue = ZSuccess; } #endif // FEATURE_SYSTEM_STATS return ( retValue ); }
/********************************************************************* * @fn OTA_Dongle_Init * * @brief Initialization function for the zclGeneral layer. * * @param none * * @return none */ void OTA_Dongle_Init( byte task_id ) { OTA_Dongle_TaskID = task_id; uint8 RxOnIdle = TRUE; OTA_Dongle_SeqNo = 0; ZMacSetReq( ZMacRxOnIdle, &RxOnIdle ); // Register the ZCL General Cluster Library callback functions zclGeneral_RegisterCmdCallbacks( OTA_DONGLE_ENDPOINT, &OTA_Dongle_CmdCallbacks ); // Register the application's attribute list zcl_registerAttrList( OTA_DONGLE_ENDPOINT, OTA_DONGLE_MAX_ATTRIBUTES, OTA_Dongle_Attrs ); // Register the application's cluster option list zcl_registerClusterOptionList( OTA_DONGLE_ENDPOINT, OTA_DONGLE_MAX_OPTIONS, OTA_Dongle_Options ); // Register the Application to receive the unprocessed Foundation command/response messages zcl_registerForMsg( OTA_Dongle_TaskID ); // Register for all key events - This app will handle all key events RegisterForKeys( OTA_Dongle_TaskID ); // Register endpoints afRegister( &ota_DongleEp ); afRegister( &ota_SysAppEp ); // Register with the ZDO to receive Match Descriptor Responses ZDO_RegisterForZDOMsg(task_id, Match_Desc_rsp); ZDO_RegisterForZDOMsg(task_id, Device_annce); // Start a timer to notify the console about the dongle osal_start_timerEx( OTA_Dongle_TaskID, OTA_DONGLE_DONGLE_NOTIFY_EVT, 4000 ); }
/********************************************************************* * @fn StubAPS_ProcessEvent() * * @brief Main event loop for Stub APS task. This function should be called * at periodic intervals when event occur. * * @param task_id - Task ID * @param events - Bitmap of events * * @return none */ UINT16 StubAPS_ProcessEvent( uint8 task_id, uint16 events ) { (void)task_id; // Intentionally unreferenced parameter if ( events & SYS_EVENT_MSG ) { osal_event_hdr_t *msg_ptr; while ( (msg_ptr = (osal_event_hdr_t *)osal_msg_receive( StubAPS_TaskID )) != NULL ) { if ( msg_ptr->event == MAC_MCPS_DATA_CNF ) { INTERP_DataConfirm( (ZMacDataCnf_t *)msg_ptr ); } else if ( msg_ptr->event == MAC_MCPS_DATA_IND ) { INTERP_DataIndication( (macMcpsDataInd_t *)msg_ptr ); } osal_msg_deallocate( (uint8 *)msg_ptr ); } // Return unproccessed events return ( events ^ SYS_EVENT_MSG ); } if ( events & CHANNEL_CHANGE_EVT ) { // try to change to the new channel ZStatus_t status = StubAPS_SetNewChannel( newChannel ); if ( status != ZSuccess ) { // turn MAC receiver back on uint8 rxOnIdle = true; ZMacSetReq( ZMacRxOnIdle, &rxOnIdle ); // set NWK task to run nwk_setStateIdle( FALSE ); channelChangeInProgress = FALSE; } // notify the application StubAPS_NotifyApp( status ); return ( events ^ CHANNEL_CHANGE_EVT ); } // If reach here, the events are unknown // Discard or make more handlers return 0; } /* StubAPS_ProcessEvent() */
/****************************************************************************** * @fn StubAPS_setNewChannel * * @brief This function changes the device's channel. * * @param none * * @return ZStatus_t */ static ZStatus_t StubAPS_SetNewChannel( uint8 channel ) { uint8 rxOnIdle; // make sure MAC has nothing to transmit if ( ( nwkDB_CountTypes( NWK_DATABUF_SENT ) == 0 ) && ZMacStateIdle() ) { // set the new channel ZMacSetReq( ZMacChannel, &channel ); // turn MAC receiver back on rxOnIdle = true; ZMacSetReq( ZMacRxOnIdle, &rxOnIdle ); channelChangeInProgress = FALSE; return ( ZSuccess ); } return ( ZFailure ); } /* StubAPS_setNewChannel */
/********************************************************************* * @fn zclSampleSw_ProcessOTAMsgs * * @brief Called to process callbacks from the ZCL OTA. * * @param none * * @return none */ static void zclSampleSw_ProcessOTAMsgs( zclOTA_CallbackMsg_t* pMsg ) { uint8 RxOnIdle; switch(pMsg->ota_event) { case ZCL_OTA_START_CALLBACK: if (pMsg->hdr.status == ZSuccess) { // Speed up the poll rate RxOnIdle = TRUE; ZMacSetReq( ZMacRxOnIdle, &RxOnIdle ); NLME_SetPollRate( 2000 ); } break; case ZCL_OTA_DL_COMPLETE_CALLBACK: if (pMsg->hdr.status == ZSuccess) { // Reset the CRC Shadow and reboot. The bootloader will see the // CRC shadow has been cleared and switch to the new image HalOTAInvRC(); SystemReset(); } else { // slow the poll rate back down. RxOnIdle = FALSE; ZMacSetReq( ZMacRxOnIdle, &RxOnIdle ); NLME_SetPollRate(DEVICE_POLL_RATE); } break; default: break; } }
/********************************************************************* * @fn ipd_PublishPriceCB * * @brief Callback from the ZCL SE Profile Pricing Cluster Library when * it received a Publish Price for this application. * * @param pCmd - pointer to structure for Publish Price command * @param srcAddr - source address * @param seqNum - sequence number for this command * * @return none */ static void ipd_PublishPriceCB( zclCCPublishPrice_t *pCmd, afAddrType_t *srcAddr, uint8 seqNum ) { if ( pCmd ) { // display Provider ID field HalLcdWriteString("Provider ID", HAL_LCD_LINE_1); HalLcdWriteValue( pCmd->providerId, 10, HAL_LCD_LINE_2 ); } #if defined ( INTER_PAN ) ZMacSetReq( ZMacRxOnIdle, &rxOnIdle ); // set receiver on when idle flag to false // after getting publish price command via INTER-PAN #endif }
void set_panid( uint16 u16NewPanid) { uint8 u8BackCode; _NIB.nwkPanId = u16NewPanid; macRadioSetPanID ( _NIB.nwkPanId); ZMacSetReq( ZMacPanId, (byte *)& _NIB.nwkPanId); u8BackCode = osal_nv_write(ZCD_NV_PANID, 0, 2, &u16NewPanid); if( u8BackCode == ZSUCCESS) { NLME_UpdateNV(0x01); // HAL_SYSTEM_RESET(); } else { uprint("set_panid failed"); } }
/*************************************************************************************************** * @fn MT_SysSetExtAddr * * @brief Set the Extended Address * * @param pBuf * * @return None ***************************************************************************************************/ void MT_SysSetExtAddr(uint8 *pBuf) { uint8 retValue = ZFailure; uint8 cmdId; /* parse header */ cmdId = pBuf[MT_RPC_POS_CMD1]; pBuf += MT_RPC_FRAME_HDR_SZ; if ( ZMacSetReq(ZMacExtAddr, pBuf) == ZMacSuccess ) { // CC253X MAC Network Processor does not have NV support #if !defined(CC253X_MACNP) retValue = osal_nv_write(ZCD_NV_EXTADDR, 0, Z_EXTADDR_LEN, pBuf); #endif } /* Build and send back the response */ MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_SRSP | (uint8)MT_RPC_SYS_SYS), cmdId, 1, &retValue); }
/*************************************************************************************************** * @fn MT_SysOsalNVWrite * * @brief * * @param uint8 pData - pointer to the data * * @return None ***************************************************************************************************/ void MT_SysOsalNVWrite(uint8 *pBuf) { uint16 nvId; uint8 nvItemLen=0, nvItemOffset=0; uint8 rtrn; /* Skip over RPC header */ pBuf += MT_RPC_FRAME_HDR_SZ; /* Get the ID */ nvId = BUILD_UINT16(pBuf[0], pBuf[1]); /* Get the offset */ nvItemOffset = pBuf[2]; /* Get the length */ nvItemLen = pBuf[3]; pBuf += 4; /* Default to ZFailure */ rtrn = ZFailure; /* Set the Z-Globals value of this NV item. */ zgSetItem( nvId, (uint16)nvItemLen, pBuf ); if ((osal_nv_write(nvId, (uint16)nvItemOffset, (uint16)nvItemLen, pBuf)) == ZSUCCESS) { if (nvId == ZCD_NV_EXTADDR) { rtrn = ZMacSetReq(ZMacExtAddr, pBuf); } else { rtrn = ZSuccess; } } /* Build and send back the response */ MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_SRSP | (uint8)MT_RPC_SYS_SYS), MT_SYS_OSAL_NV_WRITE, 1, &rtrn); }
/****************************************************************************** * @fn StubAPS_SetInterPanChannel * * @brief This function changes the device's channel for inter-PAN communication. * * @param channel - new channel * * @return ZStatus_t */ ZStatus_t StubAPS_SetInterPanChannel( uint8 channel ) { uint8 currChannel; uint8 rxOnIdle; if ( channelChangeInProgress ) return ( ZFailure ); ZMacGetReq( ZMacChannel, &currChannel ); if ( currChannel == channel ) { // inter PANs communication within the same channel return ( ZSuccess ); } // go into channel transition state channelChangeInProgress = TRUE; // set NWK task to idle nwk_setStateIdle( TRUE ); // turn MAC receiver off rxOnIdle = false; ZMacSetReq( ZMacRxOnIdle, &rxOnIdle ); // try to change to the new channel if ( StubAPS_SetNewChannel( channel ) == ZSuccess ) return ( ZSuccess ); // save the new channel for retry newChannel = channel; // ask StubAPS task to retry it later osal_start_timerEx( StubAPS_TaskID, CHANNEL_CHANGE_EVT, CHANNEL_CHANGE_RETRY_TIMEOUT ); return ( ZApsNotAllowed ); } /* StubAPS_SetInterPanChannel */
void Serial_callBack(uint8 port, uint8 event) { char theMessageData[] = "Hello"; zAddrType_t dstAddr; zAddrType_t ZAddr; afAddrType_t myaddr; // use for p2p char pbuf[3]; char pbuf1[3]; uint16 cmd; uint8 buff[128]; uint8 readBytes = 0; uint16 short_ddr; uint16 panid; uint8 *ieeeAddr; uint16 *p1; byte cnt = 0; uint8 yy1; uint8 yy2; uint8 i; byte nr; uint16 devlist[ NWK_MAX_DEVICES + 1]; associated_devices_t *adp; // delete devices //short_ddr = GenericApp_DstAddr.addr.shortAddr; uint8 startOptions; uint8 logicalType; logicalType = (uint8)ZDO_Config_Node_Descriptor.LogicalType; readBytes = HalUARTRead(SER_PORT, buff, 127); if (readBytes > 0) { //HalUARTWrite( SER_PORT, "DataRead: ",10); // HalUARTWrite( SER_PORT, buff, readBytes); if(readBytes == 4) { if(buff[0] == 'p' && buff[1] == 'i' && buff[2]=='n' && buff[3] == 'g') { UART_Send_String( "pong", 4 ); } } if( readBytes == 1) { yy1 = 1; if(buff[0]== 's') { /// short address short_ddr = _NIB.nwkDevAddress; UART_Send_String( (uint8*)&short_ddr, 2); } if(buff[0] == 'p') { /// pan id panid = _NIB.nwkPanId; UART_Send_String( (uint8*)&panid, 2); } if(buff[0] == 'c')/// channel { yy2 = _NIB.nwkLogicalChannel; UART_Send_String( (uint8*)&yy2, 1); } if(buff[0] =='m') // mac address { ieeeAddr = NLME_GetExtAddr(); UART_Send_String( ieeeAddr, 8); } if( buff[0] ==0xc0) // coordinator { set_coordi(); return; } if( buff[0] ==0xe0) // router { set_router(); return; } if(buff[0] == 0xCA) { // 使命的招唤 // read self AssociatedDevList for(i=0;i< NWK_MAX_DEVICES; i++) { nr = AssociatedDevList[ i ].nodeRelation; if(nr > 0 && nr < 5) //CHILD_RFD CHILD_RFD_RX_IDLE CHILD_FFD CHILD_FFD_RX_IDLE //if( nr != 0XFF) { // myaddr.addrMode = (afAddrMode_t)Addr16Bit; // myaddr.endPoint = GENERICAPP_ENDPOINT; // if( AssociatedDevList[ i ].shortAddr != 0x0000) // { //if( AssocIsChild( AssociatedDevList[ i ].shortAddr ) != 1 || AssociatedDevList[ i ].age > NWK_ROUTE_AGE_LIMIT) //if( AssocIsChild( AssociatedDevList[ i ].shortAddr ) == 1 && AssociatedDevList[ i ].age > NWK_ROUTE_AGE_LIMIT ) // { // myaddr.addr.shortAddr = AssociatedDevList[ i ].shortAddr; /* if ( AF_DataRequest( &myaddr, &GenericApp_epDesc, GENERICAPP_CLUSTERID,(byte)osal_strlen( theMessageData ) + 1, (byte *)&theMessageData, &GenericApp_TransID, AF_ACK_REQUEST, AF_DEFAULT_RADIUS ) != afStatus_SUCCESS ) { uprint("delete asso"); */ // delete_asso( AssociatedDevList[ i ]. addrIdx); // } // else // { devlist[yy1] = AssociatedDevList[ i ].shortAddr; yy1++; // } // } }//else {break;} } devlist[0] = BUILD_UINT16(0xce, AssocCount(1, 4) ); UART_Send_String( (uint8*)&devlist[0], yy1*2); //p1 = AssocMakeList( &cnt ); //UART_Send_String( (uint8*)p1, AssocCount(1, 4)*2); //osal_mem_free(p1); return; } } #if defined( ZDO_COORDINATOR ) // only coordinator can have this function if(readBytes == 3) { if( buff[0] == 0xCA || buff[0] == 0x6d) { // CA xx xx ,send CA to a node ,with it's short address ///uprint("it's CA "); short_ddr = BUILD_UINT16( buff[1], buff[2] ); myaddr.addrMode = (afAddrMode_t)Addr16Bit; myaddr.endPoint = GENERICAPP_ENDPOINT; myaddr.addr.shortAddr = short_ddr; if ( AF_DataRequest( &myaddr, &GenericApp_epDesc, GENERICAPP_CLUSTERID, 1, (byte *)&buff, &GenericApp_TransID, AF_DISCV_ROUTE, AF_DEFAULT_RADIUS ) != afStatus_SUCCESS ) { AF_DataRequest( &myaddr, &GenericApp_epDesc, GENERICAPP_CLUSTERID, 1, (byte *)&buff, &GenericApp_TransID, AF_DISCV_ROUTE, AF_DEFAULT_RADIUS ); // send twice only, if it is still not ok, f**k it } return; } } #endif if( readBytes >= 2) { if( buff[0] == 'e' && buff[1] == '#') { uprint("EndDevice match"); HalLedSet ( HAL_LED_1, HAL_LED_MODE_OFF ); dstAddr.addrMode = Addr16Bit; dstAddr.addr.shortAddr = 0x0000; // Coordinator ZDP_EndDeviceBindReq( &dstAddr, NLME_GetShortAddr(), GenericApp_epDesc.endPoint, GENERICAPP_PROFID, GENERICAPP_MAX_CLUSTERS, (cId_t *)GenericApp_ClusterList, GENERICAPP_MAX_CLUSTERS, (cId_t *)GenericApp_ClusterList, FALSE ); } if( buff[0] == 'r' && buff[1] == '#') { uprint("Router Device match"); HalLedSet ( HAL_LED_1, HAL_LED_MODE_FLASH ); dstAddr.addrMode = AddrBroadcast; dstAddr.addr.shortAddr = NWK_BROADCAST_SHORTADDR; ZDP_MatchDescReq( &dstAddr, NWK_BROADCAST_SHORTADDR, GENERICAPP_PROFID, GENERICAPP_MAX_CLUSTERS, (cId_t *)GenericApp_ClusterList, GENERICAPP_MAX_CLUSTERS, (cId_t *)GenericApp_ClusterList, FALSE ); } if(readBytes == 6) { if(buff[0] == 'p' && buff[1]==':') // pan id { strncpy(pbuf, &buff[2],2); pbuf[2] = '\0'; strncpy(pbuf1, &buff[4],2); pbuf1[2] = '\0'; set_panid( BUILD_UINT16( strtol(pbuf1,NULL,16),strtol(pbuf,NULL,16) )); if(_NIB.nwkPanId == 0xffff) { zgWriteStartupOptions (ZG_STARTUP_SET, ZCD_STARTOPT_DEFAULT_NETWORK_STATE); SystemReset(); } //SystemResetSoft(); } if(buff[0] == 's' && buff[1]==':') // short address { /* strncpy(pbuf, &buff[2],2); pbuf[2] = '\0'; strncpy(pbuf1, &buff[4],2); pbuf1[2] = '\0'; _NIB.nwkDevAddress = BUILD_UINT16( strtol(pbuf1,NULL,16),strtol(pbuf,NULL,16)); */ } } cmd = BUILD_UINT16(buff[ 1 + 1], buff[1]); if( ( buff[ 0 ] == CPT_SOP) && (cmd == SYS_PING_REQUEST) ) { sysPingReqRcvd(); return; } if( readBytes == 2) { if( buff[0] == 0xcc ) { if( buff[1] > 0x0a && buff[1] < 0x1b ) { _NIB.nwkLogicalChannel = buff[1]; NLME_UpdateNV(0x01); ZMacSetReq( ZMacChannel, &buff[1]); osal_nv_item_init( ZCD_NV_CHANLIST, sizeof(zgDefaultChannelList), &zgDefaultChannelList); if( buff[1] == 0x0b) { zgDefaultChannelList = 0x00000800; } if (buff[1] == 0x0c ) { zgDefaultChannelList = 0x00001000; } if (buff[1] == 0x0d ) { zgDefaultChannelList = 0x00002000; } if (buff[1] == 0x0e ) { zgDefaultChannelList = 0x00004000; } if (buff[1] == 0x0f ) { zgDefaultChannelList = 0x00008000; } if (buff[1] == 0x10 ) { zgDefaultChannelList = 0x00010000; } if (buff[1] == 0x11 ) { zgDefaultChannelList = 0x00020000; } if (buff[1] == 0x12 ) { zgDefaultChannelList = 0x00040000; } if (buff[1] == 0x13 ) { zgDefaultChannelList = 0x00080000; } if (buff[1] == 0x14 ) { zgDefaultChannelList = 0x00100000; } if (buff[1] == 0x15 ) { zgDefaultChannelList = 0x00200000; } if (buff[1] == 0x16 ) { zgDefaultChannelList = 0x00400000; } if (buff[1] == 0x17 ) { zgDefaultChannelList = 0x00800000; } if (buff[1] == 0x18 ) { zgDefaultChannelList = 0x01000000; } if (buff[1] == 0x19 ) { zgDefaultChannelList = 0x02000000; } if (buff[1] == 0x1a ) { zgDefaultChannelList = 0x04000000; } osal_nv_write( ZCD_NV_CHANLIST, 0 ,sizeof(zgDefaultChannelList), &zgDefaultChannelList); UART_Send_String( (uint8*)&zgDefaultChannelList, sizeof(zgDefaultChannelList) ); /* _NIB.nwkLogicalChannel = buff[1]; NLME_UpdateNV(0x01); if( osal_nv_write(ZCD_NV_CHANLIST, 0, osal_nv_item_len( ZCD_NV_CHANLIST ), &tmp32) != ZSUCCESS) { uprint("change channel to nv failed"); } */ /* _NIB.nwkLogicalChannel = buff[1]; ZMacSetReq( ZMacChannel, &buff[1]); ZDApp_NwkStateUpdateCB(); _NIB.nwkTotalTransmissions = 0; nwkTransmissionFailures( TRUE ); */ } } }// readBytes==2 ser_process( buff,readBytes );// 中讯威易的协议最小也是2 字节 }//if( readBytes >= 2) AF_DataRequest( &GenericApp_DstAddr, &GenericApp_epDesc, GENERICAPP_CLUSTERID, readBytes, (byte *)&buff, &GenericApp_TransID, AF_DISCV_ROUTE, AF_DEFAULT_RADIUS ); } //if (readBytes > 0) }
/********************************************************************* * @fn ipd_HandleKeys * * @brief Handles all key events for this device. * * @param shift - true if in shift/alt. * @param keys - bit field for key events. Valid entries: * HAL_KEY_SW_4 * HAL_KEY_SW_3 * HAL_KEY_SW_2 * HAL_KEY_SW_1 * * @return none */ static void ipd_HandleKeys( uint8 shift, uint8 keys ) { // Shift is used to make each button/switch dual purpose. if ( shift ) { if ( keys & HAL_KEY_SW_1 ) { } if ( keys & HAL_KEY_SW_2 ) { } if ( keys & HAL_KEY_SW_3 ) { } if ( keys & HAL_KEY_SW_4 ) { } } else { if ( keys & HAL_KEY_SW_1 ) { ZDOInitDevice(0); // join the network } if ( keys & HAL_KEY_SW_2 ) { #if defined( INTER_PAN ) uint8 x = true; ZMacGetReq( ZMacRxOnIdle, &rxOnIdle ); ZMacSetReq( ZMacRxOnIdle, &x ); afAddrType_t dstAddr; uint8 option = 1; // Send a request for public pricing information using the INTERP-DATA SAP. // The request is sent as a broadcast to all PANs within the discovered // channel. Receiving devices that implement the INTRP-DATA SAP will process // it and, if any such device is able to respond, it will respond directly // to the requestor. After receiving at least one response the requestor may // store the PAN ID and device address of one or more responders so that it // may query them directly in future. dstAddr.addrMode = afAddrBroadcast; dstAddr.addr.shortAddr = NWK_BROADCAST_SHORTADDR_DEVALL; dstAddr.endPoint = STUBAPS_INTER_PAN_EP; dstAddr.panId = 0xFFFF; zclSE_Pricing_Send_GetCurrentPrice( IPD_ENDPOINT, &dstAddr, option, TRUE, 0 ); #endif } if ( keys & HAL_KEY_SW_3 ) { } if ( keys & HAL_KEY_SW_4 ) { } } }