1 / 19

Wireless Networks Lab – Wireless

Wireless Networks Lab – Wireless. 2007/11/07 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

rollin
Download Presentation

Wireless Networks Lab – Wireless

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Wireless Networks Lab – Wireless 2007/11/07 Chia-Hung Tsai

  2. Lab5 • FontalBSP • LED • UART • Stack • Wireless • Application Queue API • Hardware interrupt • Mcps interrupt

  3. 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)

  4. MAC layer PIB access • Get a handle to the PIB

  5. MAC layer PIB access • Some attributes needs to be done using auxiliary functions

  6. Transmit a Packet for MAC PIB • Set a PAN ID • Set the short address

  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. Physical layer PIB access example • eAppApiPlmeGet • eAppApiPlmeSet

  9. Transmit a Packet for PHY PIB • Set the transmitting channel

  10. 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);

  11. Lab5 sample • tx.c • A counter application • After triggering LEDs according to the counting value, it will send the value in a packet to rx node. • rx.c • When it receive a packet from tx node, it will parse the value in the packet and trigger its LEDs by the value. • So, rx.c is still a counter application

  12. Lab sample PUBLIC void AppColdStart(void) { InitSystem(); while (TRUE) { vAHI_CpuDoze(); } }

  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. Send packet PRIVATE void sendPacket(void) { MAC_McpsSyncCfm_s sMcpsSyncCfm; MAC_McpsReqRsp_s sMcpsReqRsp; uint8 *pu8Payload; 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 = 1; pu8Payload = sMcpsReqRsp.uParam.sReqData.sFrame.au8Sdu; pu8Payload[0] = u8Value; vAppApiMcpsRequest(&sMcpsReqRsp, &sMcpsSyncCfm); }

  15. Receive packet • Step1: Poll the MCPS queue to get an interrupt PRIVATE void ReceiveISR(void) { MAC_McpsDcfmInd_s *psMcpsInd; // poll the MCPS queue do { psMcpsInd = psAppQApiReadMcpsInd(); if (psMcpsInd != NULL) { vProcessIncomingData(psMcpsInd); vAppQApiReturnMcpsIndBuffer(psMcpsInd); } } while (psMcpsInd != NULL); }

  16. Receive packet • Step2: Parse the interruptto get data PRIVATE void vProcessIncomingData(MAC_McpsDcfmInd_s *psMcpsInd){ MAC_RxFrameData_s *psFrame; uint8 au8DeviceData[8]; if (psMcpsInd->u8Type == MAC_MCPS_IND_DATA) { psFrame = &psMcpsInd->uParam.sIndData.sFrame; …… …… // Store the received data for(i = 0; i < 8; i++) { au8DeviceData[i] = psFrame->au8Sdu[i]; } } }

  17. MAC_Mcps • In mac_sap.h typedef struct { uint8 u8Type; /* Indication type */ uint8 u8ParamLength; /* Parameter length in following union */ uint16 u16Pad; /* Padding to force alignment */ MAC_McpsDcfmIndParam_u uParam; /* Union of all possible Indications */ } MAC_McpsDcfmInd_s; typedef union { MAC_McpsCfmData_s sDcfmData; /* transmit data confirm */ MAC_McpsCfmPurge_s sDcfmPurge; /* purge confirm */ MAC_McpsIndData_s sIndData; /* data indication */ } MAC_McpsDcfmIndParam_u;

  18. MAC_Mcps • In mac_sap.h typedef struct { MAC_Addr_s sSrcAddr; /* Source address */ MAC_Addr_s sDstAddr; /* Destination address */ uint8 u8LinkQuality; /* Link quality of received frame */ uint8 u8SecurityUse; /* True if security was used */ uint8 u8AclEntry; /* Security suite used */ uint8 u8SduLength; /* Length of payload */ uint8 au8Sdu[MAC_MAX_DATA_PAYLOAD_LEN]; /* Payload */ } MAC_RxFrameData_s; typedef struct { MAC_RxFrameData_s sFrame; /* Frame received */ } MAC_McpsIndData_s;

  19. Lab5 • Implement a small game that is similar with the bonus part in Lab4 • Using wireless to replace the UART • Requirement • Server node will be setting a number by hyper terminal through UART • Client node will guess a number through UART and send this number to server node • If client node is guessed a smaller number, server node will relay “the answer is bigger” to client node through wireless • Else , if client node is guessed a bigger number, server node will reply “the answer is smaller” • Else, reply “you are right”

More Related