networking library files
Revision 10:b8214cc88e85, committed 2019-01-02
- Comitter:
- Swabey89
- Date:
- Wed Jan 02 19:45:02 2019 +0000
- Parent:
- 9:e22fd5795831
- Commit message:
- Updated to use queues more
Changed in this revision
Networking.cpp | Show annotated file Show diff for this revision Revisions of this file |
Networking.hpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r e22fd5795831 -r b8214cc88e85 Networking.cpp --- a/Networking.cpp Fri Dec 28 12:04:38 2018 +0000 +++ b/Networking.cpp Wed Jan 02 19:45:02 2019 +0000 @@ -7,9 +7,12 @@ EthernetInterface eth; eth.set_network(IP, NETMASK, GATEWAY); eth.connect(); + /* printlock.lock(); pc->printf("The target IP address is '%s'\n\n\n\r", eth.get_ip_address()); printlock.unlock(); + */ + printQueue.call(printf, "The target IP address is '%s'\n\n\n\r", eth.get_ip_address()); //Now setup a web server TCPServer srv; //TCP/IP Server @@ -34,9 +37,12 @@ if(logging) { + /* printlock.lock(); printf("Incoming connection accepted on %s:%d\r\n", clt_addr.get_ip_address(), clt_addr.get_port()); printlock.unlock(); + */ + printQueue.call(printf,"Incoming connection accepted on %s:%d\r\n", clt_addr.get_ip_address(), clt_addr.get_port()); } //Uses a C++ string to make it easier to concatinate @@ -54,7 +60,7 @@ bufferLock.unlock(); //Convert to a C String - printlock.lock(); //necessary? + //printlock.lock(); //necessary? sprintf(temp_str, "%5.2f", temp); sprintf(press_str, "%5.2f", press); sprintf(light_str, "%5.2f", light); @@ -78,16 +84,19 @@ response += HTTP_MESSAGE_FOOT; response += "\r\n"; - printlock.unlock(); + //printlock.unlock(); //Send static HTML response (as a C string) clt_sock.send(response.c_str(), response.size()); if(logging) { + /* printlock.lock(); pc->printf("Network thread responded with time: %s, temperature: %s, pressure:%s and light level: %s\r\n\n",time_str, temp_str, press_str, light_str); - printlock.unlock(); + printlock.unlock(); + */ + printQueue.call(printf, "Network thread responded with time: %s, temperature: %s, pressure:%s and light level: %s\r\n\n",time_str, temp_str, press_str, light_str); } } network_tout.detach();
diff -r e22fd5795831 -r b8214cc88e85 Networking.hpp --- a/Networking.hpp Fri Dec 28 12:04:38 2018 +0000 +++ b/Networking.hpp Wed Jan 02 19:45:02 2019 +0000 @@ -101,6 +101,7 @@ extern sensorData buffer[BUFFERSIZE]; extern unsigned int newestIndex; extern Mutex bufferLock; +extern EventQueue printQueue; extern void network(); extern Timeout network_tout; extern void network_toutISR(void);