云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 低功耗的无线传感器网络节点设计

低功耗的无线传感器网络节点设计

  • 62 次阅读
  • 3 次下载
  • 2026/4/26 4:29:08

黑龙江工程学院本科生毕业设计

} }

//########## Callbacks ##########

//callback for anytime the Zero Endpoint RX handles a command //user can use the APS functions to access the arguments //and take additional action is desired.

//the callback occurs after the ZEP has already taken //its action.

LRWPAN_STATUS_ENUM usrZepRxCallback(void){

return LRWPAN_STATUS_SUCCESS; }

//callback from APS when packet is received //user must do something with data as it is freed //within the stack upon return.

LRWPAN_STATUS_ENUM usrRxPacketCallback(void) { //just print out this data conPrintROMString(\ //check the endpoint if (aplGetRxDstEp() == LIGHT_EP) { conPrintROMString(\ //our \ if (EVB_LED1_STATE()) { EVB_LED1_OFF(); } else { EVB_LED1_ON(); } } return (LRWPAN_STATUS_SUCCESS); }

31

黑龙江工程学院本科生毕业设计

#ifdef LRWPAN_FFD

//Callback to user level to see if OK for this node //to join - implement Access Control Lists here based //upon IEEE address if desired

BOOL usrJoinVerifyCallback(LADDR *ptr, BYTE capinfo){\\

#if 0 //set this to '1' if you want to test through a router //only accept routers.

//only let routers join us if we are coord #ifdef LRWPAN_COORDINATOR

if (LRWPAN_GET_CAPINFO_DEVTYPE(capinfo)) { //this is a router, let it join conPrintROMString(\ return TRUE; }else { conPrintROMString(\ return FALSE; } #else

return TRUE; #endif

#else

return TRUE;

#endif }

BOOL usrJoinNotifyCallback(LADDR *ptr){ //allow anybody to join conPrintROMString(\ conPrintLADDR(ptr); conPCRLF(); DEBUG_PRINTNEIGHBORS(DBG_INFO); return TRUE; }

#endif

//called when the slow timer interrupt occurs

32

黑龙江工程学院本科生毕业设计

#ifdef LRWPAN_ENABLE_SLOW_TIMER void usrSlowTimerInt(void ) {} #endif

//general interrupt callback , when this is called depends on the HAL layer. void usrIntCallback(void){}

#ifdef LRWPAN_COORDINATOR #ifdef LRWPAN_USE_PC_BIND

//This callback is a way for you to extend the PC client binding demo //with your own commands that you send to the coordinator via the serial //link from the PC. See the documentation for details. If you use this //callback, then you will be compatiable with future releases. //See the file pcbind.c for when this callback is invoked. void usrPbdCallback(UINT16 pktlen, BYTE crc){} #endif #endif

#include \

#ifndef LRWPAN_COORDINATOR

#define PING_DELAY 2 //wait before bouncing back #else

#define PING_DELAY 0 //coordinator does not wait #endif

#define RX_PING_TIMEOUT 5 //seconds

//this is assumed to be the long address of our coordinator, in little endian order //used to test LONG ADDRESSING back to coordinator

UINT16 ping_cnt; UINT32 my_timer; UINT32 last_tx_start;

LADDR_UNION dstADDR; /*

四种状态切换:开始接收、等待接收、发送、等待发送 */

33

黑龙江工程学院本科生毕业设计

typedef enum _PP_STATE_ENUM { PP_STATE_START_RX, PP_STATE_WAIT_FOR_RX, PP_STATE_SEND, PP_STATE_WAIT_FOR_TX }PP_STATE_ENUM;

PP_STATE_ENUM ppState;

BYTE rxFlag; //set from within usrRxPacketCallback 接收标志 BYTE payload[2]; //收发数据 UINT16 numTimeouts; //延时 BOOL first_packet; //第一包数据

void PingPong(void);

void PingPong (void ) { apsFSM();//应用层无线数据收发处理 switch (ppState) { case PP_STATE_START_RX: if (!first_packet) { my_timer= halGetMACTimer(); ppState = PP_STATE_WAIT_FOR_RX; }else if (rxFlag) { //on first packet, do not start timer, just wait for a packet. ppState = PP_STATE_WAIT_FOR_RX; first_packet = FALSE; } break; case PP_STATE_WAIT_FOR_RX: //rxFlag is set from within usrRxPacketCallback if (rxFlag || halMACTimerNowDelta(my_timer) > MSECS_TO_MACTICKS( RX_PING_TIMEOUT *1000 )) { if (!rxFlag) numTimeouts++; //got tired of waiting for a response, send again rxFlag = 0; //clear flag if (EVB_LED1_STATE()) EVB_LED1_OFF(); else EVB_LED1_ON(); //start timer my_timer= halGetMACTimer(); ppState = PP_STATE_SEND; } break; case PP_STATE_SEND: if ((halMACTimerNowDelta(my_timer))>

34

搜索更多关于: 低功耗的无线传感器网络节点设计 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

黑龙江工程学院本科生毕业设计 } } //########## Callbacks ########## //callback for anytime the Zero Endpoint RX handles a command //user can use the APS functions to access the arguments //and take additional action is desired. //the callback occurs after the ZEP has already taken //its action. LRWPAN_STATUS_ENUM usrZepRxCallback(void){ return LRWPAN_STAT

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com