⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 senderm.nc

📁 主要用于无线传感网络的编写的书籍.对于初学者有着很大的用处
💻 NC
字号:
module senderM {  provides {    interface StdControl;  }  uses {    interface SendMsg as tx;    interface ReceiveMsg as rx;    interface Leds as leds;    interface Timer as ledTimer;    interface Timer as timer;  }}implementation {#include "config.h"  TOS_Msg txBuf;  bool txPending;  command result_t StdControl.init() {    call leds.init();    txPending = false;    txBuf.data[0] = 0x1;    txBuf.data[1] = 0x2;    txBuf.data[2] = 0x3;    txBuf.data[3] = 0x4;    txBuf.length = 4;    return SUCCESS;  }  command result_t StdControl.start() {    call leds.redOn();    call leds.greenOn();    call leds.yellowOn();    call ledTimer.start(TIMER_ONE_SHOT, 500);    call timer.start(TIMER_REPEAT, 1500);    return SUCCESS;  }  command result_t StdControl.stop() {    return SUCCESS;  }    event result_t ledTimer.fired() {    call leds.redOff();    call leds.greenOff();    call leds.yellowOff();    return SUCCESS;  }  event result_t timer.fired() {    bool drop = true;    atomic {      if (!txPending) {        drop = false;        txPending = true;      }    }    if (drop) return SUCCESS;    call leds.greenOn();    call tx.send(TOS_UART_ADDR, txBuf.length, &txBuf);    return SUCCESS;  }  event result_t tx.sendDone(TOS_MsgPtr m, result_t success) {    atomic { txPending = false; }    call leds.greenOff();    return SUCCESS;  }  event TOS_MsgPtr rx.receive(TOS_MsgPtr m) {    call leds.yellowOn();    call ledTimer.start(TIMER_ONE_SHOT, 300);    return m;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -