Download presentation
Presentation is loading. Please wait.
1
Wireless Networks Lab – Wireless 2007/10/31 Chia-Hung Tsai
2
yctseng: 2 Lab5 FontalBSP LED UART Stack Wireless Application Queue API Hardware interrupt Mcps interrupt
3
yctseng: 3 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)
4
yctseng: 4 MAC layer PIB access Get a handle to the PIB #include “mac_pib.h” PRIVATE void *s_pvMac; PRIVATE MAC_Pib_s *s_psMacPib; s_pvMac=pvAppApiGetMacHandle(); s_psMacPib=MAC_psPibGetHandle(s_pvMac); psPib->u8BeaconOrder = 5;
5
yctseng: 5 MAC layer PIB access Some attributes needs to be done using auxiliary functions
6
yctseng: 6 Transmit a Packet for MAC PIB Set a PAN ID Set the short address MAC_vPibSetPanId(s_pvMac, YOUR_PAN_ID); MAC_vPibSetShortAddr(s_pvMac, YOUR_SHORT_ADDR);
7
yctseng: 7 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
8
yctseng: 8 Physical layer PIB access example eAppApiPlmeGet eAppApiPlmeSet
9
yctseng: 9 Transmit a Packet for PHY PIB Set the transmitting channel eAppApiPlmeSet(PHY_PIB_ATTR_CURRENT_C HANNEL, YOUR_CHANNEL);
10
yctseng: 10 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);
11
yctseng: 11 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
12
yctseng: 12 Lab sample PUBLIC void AppColdStart(void) { InitSystem(); while (TRUE) { vAHI_CpuDoze(); }
13
yctseng: 13 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); }
14
yctseng: 14 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); }
15
yctseng: 15 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”
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.