First attempt at some form of autodiscovery of an mbed based device by periodically broadcasting our IP in a UDP packet.
BroadcastMessage.h
00001 #ifndef BROADCAST_MESSAGE_H 00002 #define BROADCAST_MESSAGE_H 00003 00004 #include "mbed.h" 00005 #include "UDPSocket.h" 00006 00007 /* 00008 Class: AutoDiscoveryBroadcaster 00009 Periodically sends out hostname 00010 and IP address on UDP port 2010 00011 */ 00012 class BroadcastMessage { 00013 public: 00014 // Constructor: AutoDiscoveryBroadcaster 00015 // Creates the UDP sockets 00016 BroadcastMessage(); 00017 // Destructor: ~AutoDiscoveryBroadcaster 00018 // Deletes the UDP socket 00019 ~BroadcastMessage(); 00020 void init(); 00021 // Function: getBytes 00022 // Returns the message to transmit 00023 char* getBytes(); 00024 int getLength(); 00025 private: 00026 char buff[1024]; 00027 int len; 00028 }; 00029 00030 #endif 00031
Generated on Sat Jul 16 2022 15:44:47 by 1.7.2