150 likes | 320 Vues
Wireless Networks Lab – Wireless. 2007/10/31 Chia-Hung Tsai. Lab5. FontalBSP LED UART Stack Wireless Application Queue API Hardware interrupt Mcps interrupt. PIB. PIB P AN I nformation B ase Consist of a number of parameters used by MAC and Physical layers Access
E N D
Wireless Networks Lab – Wireless 2007/10/31 Chia-Hung Tsai
Lab5 • FontalBSP • LED • UART • Stack • Wireless • Application Queue API • Hardware interrupt • Mcps interrupt
PIB • PIB • PAN Information Base • Consist of a number of parameters used by MAC and Physical layers • Access • The mechanism that a network layer can used is reading (GET) and writing (Set)
MAC layer PIB access • Get a handle to the PIB
MAC layer PIB access • Some attributes needs to be done using auxiliary functions
Transmit a Packet for MAC PIB • Set a PAN ID • Set the short address
Physical layer PIB access • PHY PIB parameter values • can be returned to the network layer using the eAppApiPlmeGet routine • can be changed by the network layer using the PLME-Set request primitive • eAppApiPlmeSet routine
Physical layer PIB access example • eAppApiPlmeGet • eAppApiPlmeSet
Transmit a Packet for PHY PIB • Set the transmitting channel
macRxOnWhenIdle • macRxOnWhenIdle • Indication of whether the MAC sublayer is to enable its receiver during idle periods • BeaconOlder default is set to 15 • If BO is equal to 15, the value of macRxOnWhenIdle shall be considered relevant at all times • MAC_vPibSetRxOnWhenIdle(s_pvMac, TRUE, FALSE);
Lab5 sample • tx.c • A blink application • When it toggle its LED0, it will send a packet to rx node • rx.c • When it receive a packet from tx node, it will toggle its LED0 also • So, rx.c is still a blink application
Lab sample PUBLIC void AppColdStart(void) { InitSystem(); while (TRUE) { vAHI_CpuDoze(); } }
Lab5 sample PRIVATE void InitSystem(void) { u32AHI_Init(); u32AppQApiInit(NULL, ReceiveISR, NULL); s_pvMac = pvAppApiGetMacHandle(); s_psMacPib = MAC_psPibGetHandle(s_pvMac); MAC_vPibSetPanId(s_pvMac, PAN_ID); MAC_vPibSetShortAddr(s_pvMac, RX); eAppApiPlmeSet(PHY_PIB_ATTR_CURRENT_CHANNEL, CHANNEL); MAC_vPibSetRxOnWhenIdle(s_pvMac, TRUE, FALSE); led_init(); led_on(LED0); led_on(LED1); }
Send packet PRIVATE void sendPacket(void) { MAC_McpsSyncCfm_s sMcpsSyncCfm; MAC_McpsReqRsp_s sMcpsReqRsp; sMcpsReqRsp.u8Type = MAC_MCPS_REQ_DATA; sMcpsReqRsp.u8ParamLength = sizeof(MAC_McpsReqData_s); sMcpsReqRsp.uParam.sReqData.u8Handle=0; sMcpsReqRsp.uParam.sReqData.sFrame.sSrcAddr.u8AddrMode=2; sMcpsReqRsp.uParam.sReqData.sFrame.sSrcAddr.u16PanId=PAN_ID; sMcpsReqRsp.uParam.sReqData.sFrame.sSrcAddr.uAddr.u16Short =TX; sMcpsReqRsp.uParam.sReqData.sFrame.sDstAddr.u8AddrMode=2; sMcpsReqRsp.uParam.sReqData.sFrame.sDstAddr.u16PanId=PAN_ID; sMcpsReqRsp.uParam.sReqData.sFrame.sDstAddr.uAddr.u16Short = RX; sMcpsReqRsp.uParam.sReqData.sFrame.u8TxOptions = 1; sMcpsReqRsp.uParam.sReqData.sFrame.u8SduLength = 0; sMcpsReqRsp.uParam.sReqData.sFrame.au8Sdu[0] = '\0'; vAppApiMcpsRequest(&sMcpsReqRsp, &sMcpsSyncCfm); }
Lab5 • Implement a small game that is similar with the bonus part in Lab4 • Using wireless to replace the UART • Requirement • Tx node will be setting a number by hyper terminal through UART • Rx node will guess a number through UART and send this number to Tx node • If Rx is guessed a smaller number, Tx will relay “the answer is bigger” • Else , if Rx is guessed a bigger number, Tx will reply “the answer is smaller” • Else, reply “you are right”