当前位置:首页 >> 能源/化工 >>

Zigbee组网程序


SappleApp.c
#include "OSAL.h" #include "ZGlobals.h" #include "AF.h" #include "aps_groups.h" #include "ZDApp.h" #include "SampleApp.

h" #include "SampleAppHw.h" #include "OnBoard.h" /* HAL */ #include "hal_lcd.h" #include "hal_led.h" #include "hal_key.h" #include "string.h" #include "MT_UART.h" //#include "Lcd128X64.h" #include "UtOled.h" #include "sensor.h" #include "HAL_ADC.h" #include "exsensor.h" #include "lcd128_64.h" const cId_t SampleApp_ClusterList[SAMPLEAPP_MAX_CLUSTERS] = { SAMPLEAPP_PERIODIC_CLUSTERID, SAMPLEAPP_FLASH_CLUSTERID }; const SimpleDescriptionFormat_t SampleApp_SimpleDesc = { SAMPLEAPP_ENDPOINT, // int Endpoint; SAMPLEAPP_PROFID, // uint16 AppProfId[2]; SAMPLEAPP_DEVICEID, // uint16 AppDeviceId[2]; SAMPLEAPP_DEVICE_VERSION, // int AppDevVer:4; SAMPLEAPP_FLAGS, // int AppFlags:4; SAMPLEAPP_MAX_CLUSTERS, // uint8 AppNumInClusters; (cId_t *)SampleApp_ClusterList, // uint8 *pAppInClusterList; SAMPLEAPP_MAX_CLUSTERS, // uint8 AppNumInClusters; (cId_t *)SampleApp_ClusterList // uint8 *pAppInClusterList; };

endPointDesc_t SampleApp_epDesc; uint8 SampleApp_TaskID; devStates_t SampleApp_NwkState; uint8 SampleApp_TransID; uint8 changeline[2]={0x0a,0x0d}; union h{ uint8 RxBuf[70]; Union_DATA RXDATA; }UartRxBuf;//串口接收缓冲区 union e{ uint8 TxBuf[70]; Union_DATA TXDATA; }UartTxBuf;//串口发送缓冲区 union f{ uint8 RxBuf[70]; Union_DATA RXDATA; }RfRx;//无线接收缓冲区 union g{ uint8 TxBuf[70]; Union_DATA TXDATA; }RfTx;//无线接收缓冲区 void SampleApp_MessageMSGCB( afIncomingMSGPacket_t *pckt ); void SampleApp_SendData(unsigned char buff[],uint8 length); static void rxCB(uint8 port, uint8 event); void SampleApp_Init( uint8 task_id ) { halUARTCfg_t uartConfig; SampleApp_TaskID = task_id; SampleApp_NwkState = DEV_INIT; SampleApp_TransID = 0; SampleApp_epDesc.endPoint = SAMPLEAPP_ENDPOINT; SampleApp_epDesc.task_id = &SampleApp_TaskID; SampleApp_epDesc.simpleDesc = (SimpleDescriptionFormat_t *)&SampleApp_SimpleDesc; SampleApp_epDesc.latencyReq = noLatencyReqs; afRegister( &SampleApp_epDesc ); RegisterForKeys( SampleApp_TaskID ); MT_UartRegisterTaskID(SampleApp_TaskID); LCDInit();

ClearScreen(); Print(0,10,"COORDINATOR",1); Print(2,5,"ZhangHang",1); Print(4,5,"FengGuangWen",1); Print(6,5,"YaoJiaDong",1);

uartConfig.configured = TRUE; uartConfig.baudRate = HAL_UART_BR_115200; uartConfig.flowControl = FALSE; uartConfig.callBackFunc = rxCB ; //uartConfig.callBackFunc = NULL ; HalUARTOpen( 0, &uartConfig); } uint16 SampleApp_ProcessEvent( uint8 task_id, uint16 events ) { afIncomingMSGPacket_t *MSGpkt; (void)task_id; if ( events & SYS_EVENT_MSG ) { MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( SampleApp_TaskID ); while ( MSGpkt ) { switch ( MSGpkt->hdr.event ) { case ZDO_STATE_CHANGE: SampleApp_NwkState = (devStates_t)(MSGpkt->hdr.status); HalLedBlink(0x02,0,50,500); uint8 *buff; buff[0]='A'; buff[1]='B'; buff[2]='C'; HalUARTWrite(0,buff,3); HalUARTWrite(0,changeline,2); break; case AF_INCOMING_MSG_CMD: HalLedBlink(0x01,0,50,500); SampleApp_MessageMSGCB( MSGpkt ); break; /*case SPI_INCOMING_ZTOOL_PORT: HalLedBlink(0x02,0,50,500); rxCBX();*/ default:

break; } osal_msg_deallocate( (uint8 *)MSGpkt ); MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( SampleApp_TaskID ); } return (events ^ SYS_EVENT_MSG); } return 0; } static uint8 SerialApp_TxLen; void SampleApp_MessageMSGCB( afIncomingMSGPacket_t *pkt ) { unsigned char buffer[42]; osal_memcpy(buffer,pkt->cmd.Data ,42); HalUARTWrite(0,buffer,42); HalUARTWrite(0,changeline,2);

/* unsigned char buffer[100]; osal_memcpy(buffer,pkt->cmd.Data ,100); SerialApp_TxLen=HalUARTRead(0,buffer,100); HalUARTWrite(0,buffer,SerialApp_TxLen); HalUARTWrite(0,changeline,2); */

} void SampleApp_SendData(uint8 buff[],uint8 length) { afAddrType_t SendDataAddr; SendDataAddr.addrMode = (afAddrMode_t)AddrBroadcast; SendDataAddr.endPoint = SAMPLEAPP_ENDPOINT; SendDataAddr.addr.shortAddr = 0xffff; AF_DataRequest( &SendDataAddr, &SampleApp_epDesc, 2, length, buff, &SampleApp_TransID, AF_DISCV_ROUTE, AF_DEFAULT_RADIUS );

} static void rxCB(uint8 port, uint8 event) { uint8 length = Hal_UART_RxBufLen(0); uint8 *buff; buff = osal_mem_alloc(length); HalUARTRead(0,buff,length); if(length!=0) { SampleApp_SendData(buff,length); Printn8(5,5,length,1,3); } osal_mem_free(buff); }

Router.c
#include "OSAL.h" #include "ZGlobals.h" #include "AF.h" #include "aps_groups.h" #include "ZDApp.h" #include "SampleApp.h" #include "SampleAppHw.h" #include "OnBoard.h" #include "ioCC2530.h" /* HAL */ #include "hal_lcd.h" #include "hal_led.h" #include "hal_key.h" #include "string.h" #include "MT_UART.h" //#include "Lcd128X64.h" #include "UtOled.h" #include "sensor.h" #include "HAL_ADC.h" #include "exsensor.h"

#include "lcd128_64.h" const cId_t SampleApp_ClusterList[SAMPLEAPP_MAX_CLUSTERS] = { SAMPLEAPP_PERIODIC_CLUSTERID, SAMPLEAPP_FLASH_CLUSTERID }; const SimpleDescriptionFormat_t SampleApp_SimpleDesc = { SAMPLEAPP_ENDPOINT, // int Endpoint; SAMPLEAPP_PROFID, // uint16 AppProfId[2]; SAMPLEAPP_DEVICEID, // uint16 AppDeviceId[2]; SAMPLEAPP_DEVICE_VERSION, // int AppDevVer:4; SAMPLEAPP_FLAGS, // int AppFlags:4; SAMPLEAPP_MAX_CLUSTERS, // uint8 AppNumInClusters; (cId_t *)SampleApp_ClusterList, // uint8 *pAppInClusterList; SAMPLEAPP_MAX_CLUSTERS, // uint8 AppNumInClusters; (cId_t *)SampleApp_ClusterList // uint8 *pAppInClusterList; };

endPointDesc_t SampleApp_epDesc; uint8 SampleApp_TaskID; devStates_t SampleApp_NwkState; uint8 SampleApp_TransID; uint8 myMac[16];//物理地址 uint8 myShort[4];//本节点网络地址 uint8 temp; uint16 NWK; uint8 readbuf[50]; uint8 sendbuf[50]; uint8 changeline[2]={0x0a,0x0d}; uint8 LEDSTATE =1; uint8 LEDSTATE5=1; uint8 LEDSTATE6=1; uint8 PEOPLE=0; uint8 PEOPLE1=0; uint8 PEOPLE2=0; uint8 LIGHT=115; int timexx1=0; int timexx2=0;

union h{ uint8 RxBuf[70]; Union_DATA RXDATA; }UartRxBuf;//串口接收缓冲区

union e{ uint8 TxBuf[70]; Union_DATA TXDATA; }UartTxBuf;//串口发送缓冲区 union f{ uint8 RxBuf[70]; Union_DATA RXDATA; }RfRx;//无线接收缓冲区 union g{ uint8 TxBuf[70]; Union_DATA TXDATA; }RfTx;//无线接收缓冲区 typedef struct RFTXBUF { uint8 myNWK[4]; uint8 myMAC[16]; uint8 pNWK[4]; uint8 pMAC[16]; }RFTX; void SampleApp_HandleKey( uint8 shift, uint8 keys ); void SampleApp_SendData(void); void DataPack(void); void SampleApp_MessageMSGCB( afIncomingMSGPacket_t *pkt ); void ToString(uint8 *dest, char *src ,uint8 length); void ShowScreen(void); void HalInit(void); void DoLight(void); void SampleApp_Init( uint8 task_id ) { halUARTCfg_t uartConfig; SampleApp_TaskID = task_id; SampleApp_NwkState = DEV_INIT; SampleApp_TransID = 0;

SampleApp_epDesc.endPoint = SAMPLEAPP_ENDPOINT; SampleApp_epDesc.task_id = &SampleApp_TaskID; SampleApp_epDesc.simpleDesc = (SimpleDescriptionFormat_t *)&SampleApp_SimpleDesc; SampleApp_epDesc.latencyReq = noLatencyReqs; afRegister( &SampleApp_epDesc ); RegisterForKeys( SampleApp_TaskID ); MT_UartRegisterTaskID(SampleApp_TaskID); HalInit(); uartConfig.configured = TRUE; uartConfig.baudRate = HAL_UART_BR_115200; uartConfig.flowControl = FALSE; uartConfig.callBackFunc = NULL; HalUARTOpen( 0, &uartConfig); } uint16 SampleApp_ProcessEvent( uint8 task_id, uint16 events ) { afIncomingMSGPacket_t *MSGpkt; (void)task_id; if ( events & SYS_EVENT_MSG ) { MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( SampleApp_TaskID ); while ( MSGpkt ) { switch ( MSGpkt->hdr.event ) { case ZDO_STATE_CHANGE: SampleApp_NwkState = (devStates_t)(MSGpkt->hdr.status); if(SampleApp_NwkState == DEV_ROUTER) { HalLedBlink(0x02,0,50,500); // DataPack(); // osal_set_event(SampleApp_TaskID,SEND_DATA_EVENT); // osal_set_event(SampleApp_TaskID,SHOW_DATA_EVENT); // osal_set_event(SampleApp_TaskID,LIGHT_EVENT);

// ClearScreen(); uint8 *buff; buff[0]='A'; buff[1]='B'; buff[2]='C'; HalUARTWrite(0,buff,3); HalUARTWrite(0,changeline,2); } break; case AF_INCOMING_MSG_CMD: HalLedBlink(0x01,0,50,500); SampleApp_MessageMSGCB(MSGpkt); break; default: break; } osal_msg_deallocate( (uint8 *)MSGpkt ); MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( SampleApp_TaskID ); } return (events ^ SYS_EVENT_MSG); } if(events & SEND_DATA_EVENT) { SampleApp_SendData(); osal_start_timerEx(SampleApp_TaskID,SEND_DATA_EVENT,1000); return (events ^ SEND_DATA_EVENT); } if(events & SHOW_DATA_EVENT) { ShowScreen(); DataPack(); DoLight(); osal_start_timerEx(SampleApp_TaskID,SHOW_DATA_EVENT,100); return (events ^ SHOW_DATA_EVENT); } return 0; } void DataPack(void) { sendbuf[0]='&';sendbuf[1]='S'; sendbuf[2]='C';sendbuf[3]='U'; sendbuf[4]='R';sendbuf[5]='O'; sendbuf[6]='3';

//数据包头包括节点类型

ToString(myMac,NLME_GetExtAddr(),8); for(int i=7;i<=22;i++)sendbuf[i]=myMac[i-7]; NWK= NLME_GetShortAddr(); ToString(myShort,(uint8 *)&NWK,2); for(int i=23;i<=26;i++)sendbuf[i]=myShort[i-23]; temp=ReadTemp(); sendbuf[27]=temp/10+'0'; sendbuf[28]=temp%10+'0'; //温度信息

//

物理地址

//网络地址

unsigned char adc=HalAdcRead(0x00,1); sendbuf[29]=adc/100+'0'; sendbuf[30]=(adc/10)%10+'0'; sendbuf[31]=adc%10+'0'; sendbuf[32]=LEDSTATE + '0'; sendbuf[33]=LEDSTATE5+ '0'; sendbuf[34]=LEDSTATE6+ '0'; PEOPLE=P0_4; sendbuf[35]= PEOPLE + '0'; sendbuf[36]=LIGHT;

//光感传感器值

//总灯光控制 //两路灯光控制

//来人检测

//光感阙值用于判断灯的亮否 //待用数据包

for(int i=37;i<=40;i++)sendbuf[i]='z'; sendbuf[41]='&'; sendbuf[42]='\0'; }

static uint8 SerialApp_TxLen; void SampleApp_SendData() { afAddrType_t SendDataAddr; SendDataAddr.addrMode = (afAddrMode_t)Addr16Bit; SendDataAddr.endPoint = SAMPLEAPP_ENDPOINT; SendDataAddr.addr.shortAddr = 0x00; AF_DataRequest( &SendDataAddr, &SampleApp_epDesc, 2, 42, sendbuf, &SampleApp_TransID, AF_DISCV_ROUTE,

AF_DEFAULT_RADIUS ); } void SampleApp_MessageMSGCB(afIncomingMSGPacket_t *pkt) { // uint8 buff[42]; // osal_memcpy(buff,pkt->cmd.Data,42); ///张航 unsigned char buffer[42]; osal_memcpy(buffer,pkt->cmd.Data ,42); HalUARTWrite(0,buffer,42); HalUARTWrite(0,changeline,2);

/* unsigned char buffer[100]; osal_memcpy(buffer,pkt->cmd.Data ,100); SerialApp_TxLen=HalUARTRead(0,buffer,100); HalUARTWrite(0,buffer,SerialApp_TxLen); HalUARTWrite(0,changeline,2); */ //任意长度字符串 /* if(buff[5]=='O'&&buff[6]=='3') { //uint8 changeline[2]={0x0A,0x0D}; //HalUARTWrite(0,buff,42); //HalUARTWrite(0,changeline,2); if(buff[32]=='0')LEDSTATE =0; else LEDSTATE =1; if(buff[33]=='0')LEDSTATE5=0; else LEDSTATE5=1; if(buff[34]=='0')LEDSTATE6=0; else LEDSTATE6=1; if(buff[35]=='0')PEOPLE=0; else PEOPLE=1; LIGHT=buff[36];

}*/ } void ToString(uint8 *dest, char *src ,uint8 length) { uint8 *xad; uint8 i = 0; uint8 ch; xad = src +length -1; for(i=0;i<length;i++,xad--) { ch=(*xad>>4)&0x0f; dest[i<<1]=ch+((ch<10)?'0':'7'); ch=*xad & 0x0f; dest[(i<<1)+1]=ch+((ch<10)?'0':'7'); } } void ShowScreen() { Print(0,30," Router3",1); uint16 temper; Print(2,1,"Tempe:",1); temper=ReadTemp()-6; Printn8(2,48,temper,1,2); Print(2,65,"C",1); uint16 light; Print(4,1,"Light:",1); light=HalAdcRead(0x00,1); Printn8(4,48,light,1,3); if(LEDSTATE==1)Print(4,80,"on ",0); else Print(4,80,"off",0); Print(6,1,"People:",1); if(PEOPLE==1)Print(6,80,"yes",0); else Print(6,80,"no ",0); } void HalInit(void) { LCDInit(); ClearScreen();

Print(0,30," SCU",1); Print(2,10,"ZhangHang",1); Print(4,10,"FengGuangWen",1); Print(6,10,"YaoJiaDong",1); P0SEL &=~0x10;//热释电红外传感器的初始化 P0DIR &=~0x10; P0INP |= 0x10; P0DIR |= 0x61; //两路路灯的硬件初始化 P0_5 =LEDSTATE5; P0_6 =LEDSTATE6; } void DoLight() { unsigned char adc=HalAdcRead(0x00,1); if(LEDSTATE==0) { P0_5=1; P0_6=1; LEDSTATE5=LEDSTATE6=0; } else if(LEDSTATE==1) { if(LEDSTATE5==0)P0_5=1; else if(LEDSTATE5==1) { if(adc>LIGHT) { if(timexx1>20) { if(PEOPLE==0)P0_5=1; timexx1=0; goto ll; } if(PEOPLE==1){P0_5=0;timexx1=0;} else if(PEOPLE==0)timexx1++; } else P0_5=1; } ll :; if(LEDSTATE6==0)P0_6=1; else if(LEDSTATE6==1)

{ if(adc>LIGHT) { if(timexx2>20) { if(PEOPLE==0)P0_6=1; timexx2=0; goto xx; } if(PEOPLE==1){P0_6=0;timexx2=0;} else if(PEOPLE==0)timexx2++; } else P0_6=1; } xx:; } }

Enddevice.c
#include "OSAL.h" #include "ZGlobals.h" #include "AF.h" #include "aps_groups.h" #include "ZDApp.h" #include "SampleApp.h" #include "SampleAppHw.h" #include "OnBoard.h" /* HAL */ #include "hal_lcd.h" #include "hal_led.h" #include "hal_key.h" #include "string.h" #include "MT_UART.h" //#include "Lcd128X64.h" #include "UtOled.h" #include "sensor.h" #include "HAL_ADC.h" #include "exsensor.h" #include "lcd128_64.h"

const cId_t SampleApp_ClusterList[SAMPLEAPP_MAX_CLUSTERS] = { SAMPLEAPP_PERIODIC_CLUSTERID, SAMPLEAPP_FLASH_CLUSTERID }; const SimpleDescriptionFormat_t SampleApp_SimpleDesc = { SAMPLEAPP_ENDPOINT, // int Endpoint; SAMPLEAPP_PROFID, // uint16 AppProfId[2]; SAMPLEAPP_DEVICEID, // uint16 AppDeviceId[2]; SAMPLEAPP_DEVICE_VERSION, // int AppDevVer:4; SAMPLEAPP_FLAGS, // int AppFlags:4; SAMPLEAPP_MAX_CLUSTERS, // uint8 AppNumInClusters; (cId_t *)SampleApp_ClusterList, // uint8 *pAppInClusterList; SAMPLEAPP_MAX_CLUSTERS, // uint8 AppNumInClusters; (cId_t *)SampleApp_ClusterList // uint8 *pAppInClusterList; };

endPointDesc_t SampleApp_epDesc; uint8 SampleApp_TaskID; devStates_t SampleApp_NwkState; uint8 SampleApp_TransID; uint8 myMac[16];//物理地址 uint8 myShort[4];//本节点网络地址 uint8 temp; uint16 NWK; uint8 readbuf[50]; uint8 sendbuf[50]; uint8 changeline[2]={0x0a,0x0d}; uint8 LEDSTATE=0; uint8 PEOPLE=0; union h{ uint8 RxBuf[70]; Union_DATA RXDATA; }UartRxBuf;//串口接收缓冲区

union e{ uint8 TxBuf[70]; Union_DATA TXDATA;

}UartTxBuf;//串口发送缓冲区 union f{ uint8 RxBuf[70]; Union_DATA RXDATA; }RfRx;//无线接收缓冲区 union g{ uint8 TxBuf[70]; Union_DATA TXDATA; }RfTx;//无线接收缓冲区 typedef struct RFTXBUF { uint8 myNWK[4]; uint8 myMAC[16]; uint8 pNWK[4]; uint8 pMAC[16]; }RFTX; void SampleApp_HandleKey( uint8 shift, uint8 keys ); void SampleApp_SendData(void); void DataPack(void); void SampleApp_MessageMSGCB( afIncomingMSGPacket_t *pkt ); void ToString(uint8 *dest, char *src ,uint8 length); void ShowScreen(void); void SampleApp_Init( uint8 task_id ) { halUARTCfg_t uartConfig; SampleApp_TaskID = task_id; SampleApp_NwkState = DEV_INIT; SampleApp_TransID = 0; SampleApp_epDesc.endPoint = SAMPLEAPP_ENDPOINT; SampleApp_epDesc.task_id = &SampleApp_TaskID; SampleApp_epDesc.simpleDesc = (SimpleDescriptionFormat_t *)&SampleApp_SimpleDesc; SampleApp_epDesc.latencyReq = noLatencyReqs; afRegister( &SampleApp_epDesc ); RegisterForKeys( SampleApp_TaskID ); MT_UartRegisterTaskID(SampleApp_TaskID);

LCDInit(); Print(0,30," SCU",1); Print(2,10,"ZhangHang",1); Print(4,10,"FengGuangWen",1); Print(6,10,"YaoJiaDong",1); uartConfig.configured = TRUE; uartConfig.baudRate = HAL_UART_BR_115200; uartConfig.flowControl = FALSE; uartConfig.callBackFunc = NULL; HalUARTOpen( 0, &uartConfig); } uint16 SampleApp_ProcessEvent( uint8 task_id, uint16 events ) { afIncomingMSGPacket_t *MSGpkt; (void)task_id; if ( events & SYS_EVENT_MSG ) { MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( SampleApp_TaskID ); while ( MSGpkt ) { switch ( MSGpkt->hdr.event ) { case ZDO_STATE_CHANGE: SampleApp_NwkState = (devStates_t)(MSGpkt->hdr.status); if(SampleApp_NwkState == DEV_END_DEVICE) { HalLedBlink(0x02,0,50,500); osal_set_event(SampleApp_TaskID,SEND_DATA_EVENT); ClearScreen(); } break; case AF_INCOMING_MSG_CMD: SampleApp_MessageMSGCB(MSGpkt); break; default: break; } osal_msg_deallocate( (uint8 *)MSGpkt ); MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( SampleApp_TaskID ); } return (events ^ SYS_EVENT_MSG);

} if(events & SEND_DATA_EVENT) { DataPack(); SampleApp_SendData(); ShowScreen(); osal_start_timerEx(SampleApp_TaskID,SEND_DATA_EVENT,3000); return (events ^ SEND_DATA_EVENT); } /*if(events & SHOW_DATA_EVENT) { ShowScreen(); osal_start_timerEx(SampleApp_TaskID,SHOW_DATA_EVENT,1000); return (events ^ SHOW_DATA_EVENT); }*/ return 0; } void SampleApp_MessageMSGCB(afIncomingMSGPacket_t *pkt) { uint8 buff[42]; osal_memcpy(buff,pkt->cmd.Data,42); if(buff[5]=='F'||buff[6]=='1') { uint8 changeline[2]={0x0A,0x0D}; HalUARTWrite(0,buff,42); HalUARTWrite(0,changeline,2); if(buff[32]=='z'||buff[32]=='.')HalLedSet(0x01,LEDSTATE); if(buff[32]=='0') { HalLedSet(0x01,0); LEDSTATE=0; } else { HalLedSet(0x01,1); LEDSTATE=1; } } } void DataPack(void) { uint16 site; sendbuf[0]='&';sendbuf[1]='S';

sendbuf[2]='C';sendbuf[3]='U'; sendbuf[4]='R';sendbuf[5]='F'; sendbuf[6]='1'; //sendbuf[6]='2';//数据包头包括节点类型

ToString(myMac,NLME_GetExtAddr(),8); for(int i=7;i<=22;i++)sendbuf[i]=myMac[i-7]; NWK= NLME_GetShortAddr(); ToString(myShort,(uint8 *)&NWK,2); for(int i=23;i<=26;i++)sendbuf[i]=myShort[i-23]; temp=ReadTemp(); sendbuf[27]=temp/10+'0'; sendbuf[28]=temp%10+'0'; //温度信息

//

物理地址

//网络地址

unsigned char adc=HalAdcRead(0x00,1); sendbuf[29]=adc/100+'0'; sendbuf[30]=(adc/10)%10+'0'; sendbuf[31]=adc%10+'0';

//光感传感器值

for(int i=32;i<=40;i++)sendbuf[i]='z'; sendbuf[41]='&'; sendbuf[42]='\0';

//待用数据包

} void SampleApp_SendData() { afAddrType_t SendDataAddr; SendDataAddr.addrMode = (afAddrMode_t)Addr16Bit; SendDataAddr.endPoint = SAMPLEAPP_ENDPOINT; SendDataAddr.addr.shortAddr = 0x00; AF_DataRequest( &SendDataAddr, &SampleApp_epDesc, 2, 42, sendbuf, &SampleApp_TransID, AF_DISCV_ROUTE, AF_DEFAULT_RADIUS ); }

void ToString(uint8 *dest, char *src ,uint8 length) { uint8 *xad; uint8 i = 0; uint8 ch; xad = src +length -1; for(i=0;i<length;i++,xad--) { ch=(*xad>>4)&0x0f; dest[i<<1]=ch+((ch<10)?'0':'7'); ch=*xad & 0x0f; dest[(i<<1)+1]=ch+((ch<10)?'0':'7'); } } void ShowScreen() { Print(0,30,"EndDevice1",1); uint16 temper; Print(2,1,"Tempe:",1); temper=ReadTemp()-6; Printn8(2,48,temper,1,2); Print(2,65,"C",1); uint16 light; Print(4,1,"Light:",1); light=HalAdcRead(0x00,1); Printn8(4,48,light,1,3); if(LEDSTATE==1)Print(4,80,"on ",0); else Print(4,80,"off",0); Print(6,1,"People:",1); if(PEOPLE==1)Print(6,80,"yes",0); else Print(6,80,"no",0); }


相关文章:
Zigbee组网程序
Zigbee组网程序_能源/化工_工程科技_专业资料 暂无评价|0人阅读|0次下载|举报文档 Zigbee组网程序_能源/化工_工程科技_专业资料。今日推荐 ...
zigbee组网程序解读
zigbee组网程序解读_计算机硬件及网络_IT/计算机_专业资料。学习zigbee必备Zigbee 组网过程解读 第一个功能:协调器的组网,终端设备和路由设备发现网络以及加入网络 //...
Zigbee组网流程
Zigbee组网流程_电子/电路_工程科技_专业资料。1、网络形成 组网开始时,网络层首先向 MAC 层请求分配协议所规定的信道,或者由 PHY 层进行有效 信道扫描, 网络层管...
Zigbee组网流程——理论
Zigbee组网流程——理论 隐藏>> 星形网络和树型网络可以看成是网状网络的一个特殊子集,所以接下来分析如何组建一个 Zigbee 网状网络。 组建一个完整的 Zigbee 网络...
zigbee组网过程
zigbee组网过程_计算机硬件及网络_IT/计算机_专业资料。int main( void ) { // Initialize the operating system osal_init_system(); //初始化操作系统 ... ...
zigbee的组网流程
zigbee组网流程_信息与通信_工程科技_专业资料。zigbee如何组网的过程ZIGBee...即 ZDO_CB_MSG,ZDApp 层任务事件处理函数将进行处理:也就是调用下面的程序。 ...
zigbee的系统结构和组网方式
zigbee的系统结构和组网方式_计算机硬件及网络_IT/计算机_专业资料。zigbee的协议,结构,组网方式,硬件架构简介ZigBee 是一种新兴的短距离、低功耗、低数据传输速率的...
ZigBee组网实验
ZigBee组网实验_计算机软件及应用_IT/计算机_专业资料。www.iblueye.com 南京...我们可以先下 载 程序到未来星开发板, 然后可以看到随便发什么都可以打印出来提示...
Zigbee组网原理与应用剖析
协调器设备的 组网程序流程如图 4 所示。 3.2 LM3S9B96+CC2520 与 CC2530 组网研究 ZigBee 有着大规模的组网能力,每个网络理论上最大可支持 65 535 个节点,...
zigbee组网
zigbee组网_计算机硬件及网络_IT/计算机_专业资料。第一个功能:协调器的组网,终端...即 ZDO_CB_MSG,ZDApp 层任务事件处理函数将进行处理:也就是调用下面的程序。 ...
更多相关标签:
zigbee组网 | zigbee如何组网 | zigbee自组网原理 | zigbee组网流程图 | zigbee组网方案 | zigbee自组网 | zigbee组网过程 | zigbee组网方式 |