Student project by David Berlin and Boris Dogadov made for the Embedded Systems Workshop course given in Tel-Aviv University on 2010 by Sivan Toledo. Visit the project website for more details: http://davidberlin.co.il/sadna/ .
Dependencies: EthernetNetIf NTPClient_NetServices mbed HTTPServer HTTPClient CyaSSL
Diff: HttpHandlerSetup.cpp
- Revision:
- 1:b05231650f32
- Parent:
- 0:3e7d6f496a67
--- a/HttpHandlerSetup.cpp Sun Apr 17 21:30:10 2011 +0000 +++ b/HttpHandlerSetup.cpp Mon Apr 25 12:31:46 2011 +0000 @@ -6,7 +6,7 @@ FILE* settingsFile = fopen("/usb/DBSet.txt", "r"); if (settingsFile) { - //printf("before fseek %d\n\r", settingsFile); + printf("before fseek %d\n\r", settingsFile); fseek(settingsFile, 9L, SEEK_SET); fgets(username, 32, settingsFile); fseek(settingsFile, 9L, SEEK_CUR); @@ -15,7 +15,7 @@ int len = strlen(username); username[len - 2] = 0; // remove /r/n //printf("ReadSettings %s, %s, %d, %d, %s\r\n", username, password, len, ftell(settingsFile), data); - + //printf("ReadSettings OK %s, %s\r\n", username, password); fclose(settingsFile); } @@ -52,19 +52,20 @@ } void HttpHandlerSetup::UpdateSettingsFile() -{ +{ if (m_WasDataRead) { return; } - + char buffer[256]; int dataLength = dataLen(); int readBytes = readData(buffer, 45 + dataLength); if (readBytes > 0) { - int offset = readBytes > dataLength ? 45 : 0; // Inconsistency id data reading + //printf("UpdateSettingsFile %s \r\n", buffer); + int offset = readBytes > dataLength ? 45 : 0; // Inconsistent data reading char* c1 = strchr(buffer, '&'); char* c2 = strchr(buffer + offset, '=') + 1; char* c3 = strchr(c1, '=') + 1; @@ -177,13 +178,14 @@ { printf("onReadable\r\n"); UpdateSettingsFile(); + close(); } void HttpHandlerSetup::onWriteable() //Data has been written & buf is free { // printf("onWriteable() password: %s, username:%s \r\n", Password, Username); printf("onWriteable\r\n"); - //close(); //Data written, we can close the connection + close(); //Data written, we can close the connection } void HttpHandlerSetup::onClose() //Connection is closing