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 UDP_V1_0 by
Revision 1:be0485e31b72, committed 2018-06-27
- Comitter:
- Martin1997
- Date:
- Wed Jun 27 09:56:10 2018 +0000
- Parent:
- 0:acad836c53e8
- Commit message:
- Working Code
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Jun 05 12:26:56 2018 +0000
+++ b/main.cpp Wed Jun 27 09:56:10 2018 +0000
@@ -1,5 +1,3 @@
-//code working
-
#if !FEATURE_LWIP
#error [NOT_SUPPORTED] LWIP not supported for this target
#endif
@@ -26,17 +24,29 @@
"\r\n" \
HTTP_MESSAGE_BODY "\r\n"
+//EDIT Martin Zeitler
+//Definieren der Netzwerkparameter
+
+#define IPADDRESS "192.168.0.109"
+#define NETMASK "255.255.255.0"
+#define GATEWAY "192.168.0.1"
+#define PORT_RECEIVE 2223
+
+//EDIT END
+
int main()
{
printf("Basic HTTP server example\n");
EthernetInterface eth;
+ eth.set_network(IPADDRESS,NETMASK,GATEWAY);
eth.connect();
+
+
printf("The target IP address is '%s'\r\n", eth.get_ip_address());
UDPSocket socket;
- printf("Hello Succ\r\n");
if(socket.open(ð)!=0)
{
@@ -44,16 +54,26 @@
while(1);
}
- if(socket.bind(2223)!=0)
+
+ //EDIT
+ //if(socket.bind(2223)!=0)
+ if(socket.bind(PORT_RECEIVE)!=0)
{
printf("Binding failed\r\n");
while(1);
+ }
+ else
+ {
+ printf("Binding service on Port '%d' \n", PORT_RECEIVE);
}
-
+ //EDIT END
+
+
char buf[256];
SocketAddress sender;
- printf("Before while...\r\n");
- while (true) {
+
+ while (true)
+ {
int recBytes = socket.recvfrom(&sender,buf,256);
printf("Received packet. Size: %d\r\n",recBytes);
if(recBytes)
--- a/mbed.bld Tue Jun 05 12:26:56 2018 +0000 +++ b/mbed.bld Wed Jun 27 09:56:10 2018 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/mbed_official/code/mbed/builds/5aab5a7997ee \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/a7c7b631e539 \ No newline at end of file
