![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
UDPversion
Dependencies: XBee mbed NetServicesMin
Diff: tcpip/net_routing.cpp
- Revision:
- 1:3a46d2725374
- Parent:
- 0:84a3b029656e
diff -r 84a3b029656e -r 3a46d2725374 tcpip/net_routing.cpp --- a/tcpip/net_routing.cpp Sat Apr 14 03:53:45 2012 +0000 +++ b/tcpip/net_routing.cpp Sun Apr 15 10:49:08 2012 +0000 @@ -6,51 +6,138 @@ extern PrefServer pref; +extern PrefSender spref; +extern PrefReciever rpref; + extern Serial pc; void netRouting(Payload *_payload) { - - - #ifdef _SERVER_TEST_MODE_ - tcpSendPayload(_payload); + +// dumpPayload(_payload); - #else - - dumpPayload(_payload); - - uint32_t xbeeAdr=0; switch(_payload->frame.message.device) { case LED_SENDER: { - xbeeAdr = kLedSender; - xbeeSend(xbeeAdr,_payload); + #ifndef _SERVER_TEST_MODE_ + + xbeeSend(kLedSender,_payload); + #else + + switch(_payload->frame.message.command) + { + case PING: + { + dumpPrefSender(&spref); + memcpy(_payload->frame.message.data,&spref,sizeof(PrefSender)); + _payload->frame.message.device=LED_SENDER; + DBGF("******* [TEST MODE] sender ping! **************\r\n"); + } + break; + case SEND_SINGLE: + { + spref.continueusMode=0; + spref.currentFrameNumber=_payload->frame.message.frameNumber; + dumpPrefSender(&spref); + + memcpy(_payload->frame.message.data,&spref,sizeof(PrefSender)); + _payload->frame.message.device=LED_SENDER; + DBGF("******* [TEST MODE] sender single send! **************\r\n"); + + } + break; + case SEND_CONTINUEOUS: + { + spref.continueusMode=1; + spref.currentFrameNumber=_payload->frame.message.frameNumber; + dumpPrefSender(&spref); + + memcpy(_payload->frame.message.data,&spref,sizeof(PrefSender)); + _payload->frame.message.device=LED_SENDER; + DBGF("******* [TEST MODE] sender continues send! **************\r\n"); + + } + break; + case SEND_CONT_STOP: + { + spref.continueusMode=0; + spref.currentFrameNumber=_payload->frame.message.frameNumber; + dumpPrefSender(&spref); + + memcpy(_payload->frame.message.data,&spref,sizeof(PrefSender)); + _payload->frame.message.device=LED_SENDER; + DBGF("******* [TEST MODE] sender continues stop! **************\r\n"); + + } + break; + + case SET_TX_GAIN: + { + spref.gainData.gain=_payload->frame.message.data[0]; + spref.gainData.middleLevel=_payload->frame.message.data[1]; + + dumpPrefSender(&spref); + + memcpy(_payload->frame.message.data,&spref,sizeof(PrefSender)); + _payload->frame.message.device=LED_SENDER; + DBGF("******* [TEST MODE] sender tx lebel set! **************\r\n"); + } + break; + case SET_LIGHT_CONTROL: + { + spref.lightsw=_payload->frame.message.data[0]; + + dumpPrefSender(&spref); + + memcpy(_payload->frame.message.data,&spref,sizeof(PrefSender)); + _payload->frame.message.device=LED_SENDER; + DBGF("******* [TEST MODE] sender light on set! **************\r\n"); + + } + break; + } + dumpPayload(_payload); + udpSendPayload(_payload); + #endif break; } case LED_RECIEVER: { - xbeeAdr = kLedReciever; - xbeeSend(xbeeAdr,_payload); + #ifndef _SERVER_TEST_MODE_ + + xbeeSend(kLedReciever,_payload); + #else + if(_payload->frame.message.command==PING){ + dumpPrefReciever(&rpref); + memcpy(_payload->frame.message.data,&rpref,sizeof(PrefReciever)); + _payload->frame.message.device=LED_RECIEVER; + dumpPayload(_payload); + udpSendPayload(_payload); + DBGF("******* [TEST MODE] reciever ping! **************\r\n"); + + } + + #endif break; } case SERVER: { if(_payload->frame.message.command==PING){ - memcpy(_payload->frame.message.data,&pref,sizeof(pref)); + #ifdef _SERVER_TEST_MODE_ + dumpPrefServer(&pref); + #endif + memcpy(_payload->frame.message.data,&pref,sizeof(PrefServer)); _payload->frame.message.device=SERVER; udpSendPayload(_payload); - pc.printf("******* ping! **************\r\n"); + DBGF("******* server ping! **************\r\n"); } break; } } - - #endif - } \ No newline at end of file