📄 test_aplp.nc
字号:
//#define OPEN_ZB_MAC
/*
* @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
* @author Andre Cunha
* @author Ricardo Severino <rars@isep.ipp.pt>
*
*/
#include <Timer.h>
#include "printfUART.h"
module Test_APLP {
uses interface Boot;
uses interface Leds;
uses interface NLDE_DATA;
//NLME NWK Management services
uses interface NLME_NETWORK_DISCOVERY;
uses interface NLME_NETWORK_FORMATION;
uses interface NLME_START_ROUTER;
uses interface NLME_JOIN;
uses interface NLME_LEAVE;
uses interface NLME_SYNC;
/*
uses interface NLME_PERMIT_JOINING;
uses interface NLME_DIRECT_JOIN;*/
uses interface NLME_RESET;
uses interface NLME_GET;
uses interface NLME_SET;
uses interface Timer<TMilli> as T_init;
uses interface Timer<TMilli> as T_test;
uses interface Timer<TMilli> as T_schedule;
//user button
uses interface Get<button_state_t>;
uses interface Notify<button_state_t>;
}
implementation {
//descriptor of the Parent device
networkdescriptor PAN_network;
//boolean variable definig if the device has joined to the PAN
uint8_t joined =0x00;
//boolean variable defining if the device is waiting for the beacon request response
uint8_t requested_scheduling = 0x00;
//function used to start the beacon broadcast (router devices)
task void start_sending_beacons_request();
//function used to schedule the beacon requests (PAN coordinator)
void process_beacon_scheduling(uint16_t source_address,uint8_t beacon_order, uint8_t superframe_order);
void process_beacon_scheduling(uint16_t source_address,uint8_t beacon_order, uint8_t superframe_order)
{
uint8_t nsdu_pay[6];
beacon_scheduling *beacon_scheduling_ptr;
beacon_scheduling_ptr = (beacon_scheduling *)&nsdu_pay[0];
switch(source_address)
{
/*****************************************************************************/
/*DEPTH
mwkMaxChildren (Cm) 6
nwkMaxDepth (Lm) 4
mwkMaxRouters (Rm) 4
*/
/*
case 0x0001:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x00;
beacon_scheduling_ptr->transmission_offset[1] = 0x3C;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
case 0x0002:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x00;
beacon_scheduling_ptr->transmission_offset[1] = 0x3C;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
case 0x0021:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x01;
beacon_scheduling_ptr->transmission_offset[1] = 0x2C;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
case 0x0003:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x00;
beacon_scheduling_ptr->transmission_offset[1] = 0x3C;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
case 0x0022:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x00;
beacon_scheduling_ptr->transmission_offset[1] = 0x3C;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
case 0x0004:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x00;
beacon_scheduling_ptr->transmission_offset[1] = 0x3C;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
case 0x0005:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x00;
beacon_scheduling_ptr->transmission_offset[1] = 0x78;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
case 0x0023:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x00;
beacon_scheduling_ptr->transmission_offset[1] = 0x3C;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
case 0x0024:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x00;
beacon_scheduling_ptr->transmission_offset[1] = 0x78;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
*/
/*****************************************************************************/
/*NORMAL TEST
mwkMaxChildren (Cm) 6
nwkMaxDepth (Lm) 3
mwkMaxRouters (Rm) 4
*/
case 0x0001:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x00;
beacon_scheduling_ptr->transmission_offset[1] = 0x3C;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
case 0x0020:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x01;
beacon_scheduling_ptr->transmission_offset[1] = 0xE0;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
case 0x0002:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x00;
beacon_scheduling_ptr->transmission_offset[1] = 0x3C;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
case 0x0009:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x00;
beacon_scheduling_ptr->transmission_offset[1] = 0xF0;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
case 0x0021:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x00;
beacon_scheduling_ptr->transmission_offset[1] = 0x3C;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
case 0x0028:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x00;
beacon_scheduling_ptr->transmission_offset[1] = 0xF0;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
case 0x0003:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x00;
beacon_scheduling_ptr->transmission_offset[1] = 0x3C;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
case 0x0004:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x00;
beacon_scheduling_ptr->transmission_offset[1] = 0x78;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
case 0x000a:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x00;
beacon_scheduling_ptr->transmission_offset[1] = 0x3C;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
case 0x000b:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x00;
beacon_scheduling_ptr->transmission_offset[1] = 0x78;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
case 0x0022:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x00;
beacon_scheduling_ptr->transmission_offset[1] = 0x3C;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
case 0x0023:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x00;
beacon_scheduling_ptr->transmission_offset[1] = 0x78;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
case 0x0029:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x00;
beacon_scheduling_ptr->transmission_offset[1] = 0x3C;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
case 0x002a:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x00;
beacon_scheduling_ptr->transmission_offset[1] = 0x78;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
/*******************************************************************/
/*
case 0x0001:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x00;
beacon_scheduling_ptr->transmission_offset[1] = 0x3C;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
case 0x0002:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x00;
beacon_scheduling_ptr->transmission_offset[1] = 0x3C;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
break;
case 0x0009:
beacon_scheduling_ptr->request_type = SCHEDULING_ACCEPT;
beacon_scheduling_ptr->beacon_order = beacon_order;
beacon_scheduling_ptr->superframe_order = superframe_order;
beacon_scheduling_ptr->transmission_offset[0] = 0x00;
beacon_scheduling_ptr->transmission_offset[1] = 0x78;
beacon_scheduling_ptr->transmission_offset[2] = 0x00;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -