This library contains a simple device driver for the X10 CM17a module. It also contains a simple X10Server, which listens for network commands to be forwarded to the module.
X10Server.h@1:4006f1419bc2, 2015-07-07 (annotated)
- Committer:
- WiredHome
- Date:
- Tue Jul 07 13:58:42 2015 +0000
- Revision:
- 1:4006f1419bc2
- Parent:
- 0:12ed8bd4909a
Tuned up the baudrate based on a number of trials;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
WiredHome | 0:12ed8bd4909a | 1 | |
WiredHome | 0:12ed8bd4909a | 2 | #ifndef X10SERVER_H |
WiredHome | 0:12ed8bd4909a | 3 | #define X10SERVER_H |
WiredHome | 0:12ed8bd4909a | 4 | |
WiredHome | 0:12ed8bd4909a | 5 | #include "mbed.h" |
WiredHome | 0:12ed8bd4909a | 6 | #include "rtos.h" |
WiredHome | 0:12ed8bd4909a | 7 | #include "EthernetInterface.h" |
WiredHome | 0:12ed8bd4909a | 8 | |
WiredHome | 0:12ed8bd4909a | 9 | /// The X10Server class, which will listen for X10 commands from |
WiredHome | 0:12ed8bd4909a | 10 | /// the network. |
WiredHome | 0:12ed8bd4909a | 11 | /// |
WiredHome | 0:12ed8bd4909a | 12 | class X10Server |
WiredHome | 0:12ed8bd4909a | 13 | { |
WiredHome | 0:12ed8bd4909a | 14 | public: |
WiredHome | 0:12ed8bd4909a | 15 | /// X10Server Constructor, which also assigns the port. |
WiredHome | 0:12ed8bd4909a | 16 | /// |
WiredHome | 0:12ed8bd4909a | 17 | /// This constructs the X10Server object, and sets it to |
WiredHome | 0:12ed8bd4909a | 18 | /// listen for incoming messages. |
WiredHome | 0:12ed8bd4909a | 19 | /// |
WiredHome | 0:12ed8bd4909a | 20 | /// @param[in] fptr is an optional pointer to a function that can |
WiredHome | 0:12ed8bd4909a | 21 | /// accept and process the received message. |
WiredHome | 0:12ed8bd4909a | 22 | /// This function is called with a pointer to the message and |
WiredHome | 0:12ed8bd4909a | 23 | /// the size of the message as parameters. |
WiredHome | 0:12ed8bd4909a | 24 | /// @param[in] port is an optional parameter to set the port |
WiredHome | 0:12ed8bd4909a | 25 | /// to listen to. The default is 10630. |
WiredHome | 0:12ed8bd4909a | 26 | /// |
WiredHome | 0:12ed8bd4909a | 27 | X10Server(void(*fptr)(char * buffer, int size) = NULL, uint16_t port = 10630); |
WiredHome | 0:12ed8bd4909a | 28 | |
WiredHome | 0:12ed8bd4909a | 29 | /// The process to call where there is free time, to see |
WiredHome | 0:12ed8bd4909a | 30 | /// if there is a request, and to handle it. |
WiredHome | 0:12ed8bd4909a | 31 | /// |
WiredHome | 0:12ed8bd4909a | 32 | void poll(void); |
WiredHome | 0:12ed8bd4909a | 33 | |
WiredHome | 0:12ed8bd4909a | 34 | private: |
WiredHome | 0:12ed8bd4909a | 35 | void (*callback)(char * buffer, int size); |
WiredHome | 0:12ed8bd4909a | 36 | uint16_t listenPort; |
WiredHome | 0:12ed8bd4909a | 37 | TCPSocketServer svr; |
WiredHome | 0:12ed8bd4909a | 38 | TCPSocketConnection client; |
WiredHome | 0:12ed8bd4909a | 39 | bool serverIsListening; |
WiredHome | 0:12ed8bd4909a | 40 | bool clientIsConnected; |
WiredHome | 0:12ed8bd4909a | 41 | }; |
WiredHome | 0:12ed8bd4909a | 42 | |
WiredHome | 0:12ed8bd4909a | 43 | #endif // X10SERVER_H |