Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of webserverBlinky by
Diff: PPP-Blinky/ppp-blinky.cpp
- Revision:
- 174:e5a3f16421a5
- Parent:
- 173:6774a0c851c4
- Child:
- 176:011dbb3f7d03
--- a/PPP-Blinky/ppp-blinky.cpp Mon Sep 04 15:59:53 2017 +0000 +++ b/PPP-Blinky/ppp-blinky.cpp Wed Sep 06 14:27:04 2017 +0000 @@ -686,6 +686,23 @@ } } +unsigned int ip( int a, int b, int c, int d){ + return a<<24 | b<<16 | c<<8 | d; +} + +/// UDP demo that sends a udp packet containing a character received from the second debug serial port. +/// Sends a 48 byte IP/UDP header for every 1 byte of data so line-mode would probably be better. +void sendUdpData() +{ +#ifdef SERIAL_PORT_MONITOR_YES + if (xx.readable()) { + char inchar = xx.getc(); + xx.putc( inchar ); // echo the char + sendUdp(ip(172,10,10,2), ip(172,10,10,1), 1, 12345, &inchar, 1); // send 1 byte message to 172.10.10.2:12345 + } +#endif +} + /// handle a PING ICMP (internet control message protocol) packet void ICMPpacket() // internet control message protocol { @@ -1237,7 +1254,8 @@ void waitForPppFrame() { while(1) { - checkPc(); // handle received characters + checkPc(); // handle received characters from the PC + sendUdpData(); // handle received characters from the DEBUG TERMINAL if ( ppp.rx.head != ppp.rx.tail ) { int oldTail = ppp.rx.tail; // remember where the character is located in the buffer int rx = pc_getBuf(); // get the character @@ -1284,3 +1302,4 @@ debugPrintf("\x1b[2J\x1b[H\x1b[30mmbed PPP-Blinky HTTP & WebSocket server ready :)\n"); // VT100 codes for clear_screen, home, black_text - Tera Term is a handy VT100 terminal pppInitStruct(); // initialize all the PPP properties } +