diff --git a/cube/Makefile b/cube/Makefile index b303ca6..cf38ef1 100644 --- a/cube/Makefile +++ b/cube/Makefile @@ -37,7 +37,7 @@ BUILD_DIR = build ###################################### # C sources C_SOURCES = \ -User/Src/mqttComm.c User/Src/tcpTest.c User/Src/ports.c User/Src/eeprom.c User/Src/frontend.c User/Src/logger.c User/Src/loopCtrl.c User/Src/main2.c User/Src/mbusComm.c User/Src/ringbuffer.c User/Src/show.c User/Src/utils.c User/Src/wizHelper.c hottislib/PontCoopScheduler.c \ +User/Src/httpTest.c User/Src/mqttComm.c User/Src/tcpTest.c User/Src/ports.c User/Src/eeprom.c User/Src/frontend.c User/Src/logger.c User/Src/loopCtrl.c User/Src/main2.c User/Src/mbusComm.c User/Src/ringbuffer.c User/Src/show.c User/Src/utils.c User/Src/wizHelper.c hottislib/PontCoopScheduler.c \ libmbus/mbus/mbus-protocol.c \ Core/Src/main.c \ Core/Src/gpio.c \ @@ -125,7 +125,7 @@ C_INCLUDES = \ -IUser/Inc \ -IioLibrary_Driver/Ethernet \ -IioLibrary_Driver/Internet/DHCP \ --IioLibrary_Driver/Internet/MQTT \ +-IioLibrary_Driver/Internet/httpServer \ -Ipubsubc/src \ -ICore/Inc \ -IDrivers/STM32F1xx_HAL_Driver/Inc \ diff --git a/cube/User/Inc/httpTest.h b/cube/User/Inc/httpTest.h new file mode 100644 index 0000000..45c65fb --- /dev/null +++ b/cube/User/Inc/httpTest.h @@ -0,0 +1,9 @@ +#ifndef _HTTPTEST_H_ +#define _HTTPTEST_H_ + +#include + +void httpTestInit(); + + +#endif /* _HTTPTEST_H_ */ diff --git a/cube/User/Src/eeprom.c b/cube/User/Src/eeprom.c index caa60ce..146e2a2 100644 --- a/cube/User/Src/eeprom.c +++ b/cube/User/Src/eeprom.c @@ -20,7 +20,7 @@ static const uint8_t EEPROM_WREN = 0x06; // static const uint8_t EEPROM_WRSR = 0x01; -static const uint32_t EEPROM_MAGIC = 0xaffe0005; +static const uint32_t EEPROM_MAGIC = 0xaffe0006; typedef union { diff --git a/cube/User/Src/httpTest.c b/cube/User/Src/httpTest.c new file mode 100644 index 0000000..4167187 --- /dev/null +++ b/cube/User/Src/httpTest.c @@ -0,0 +1,64 @@ +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + + +extern const uint8_t HTTP_SOCK_1; +extern const uint8_t HTTP_SOCK_2; +extern const uint8_t HTTP_SOCK_3; +#define MAX_HTTPSOCK 3 +uint8_t HTTPTEST_SOCKS[] = { 3, 4, 5 }; + +#define DATA_BUF_SIZE 1024 +uint8_t RX_BUF[DATA_BUF_SIZE], TX_BUF[DATA_BUF_SIZE]; + +static uint8_t webpath[] = "hello"; +static uint8_t message[] = "Hello World!\n\r"; + + +void httpTestHandler(void *handle) { + static uint8_t state = 0; + if (isNetworkAvailable()) { + switch (state) { + case 0: + coloredMsg(LOG_YELLOW, "hth, initializing server"); + + httpServer_init(TX_BUF, RX_BUF, MAX_HTTPSOCK, HTTPTEST_SOCKS); + reg_httpServer_webContent(webpath, message); + state = 1; + break; + + case 1: + coloredMsg(LOG_YELLOW, "hth, running"); + state = 2; + break; + + case 2: + for (uint8_t i = 0; i < MAX_HTTPSOCK; i++) { + httpServer_run(i); + } + break; + + case 255: + coloredMsg(LOG_YELLOW, "hth, error state, will stop here"); + schDel(httpTestHandler, NULL); + break; + } + } else { + coloredMsg(LOG_YELLOW, "hth, network not yet ready"); + } +} + +void httpTestInit() { + schAdd(httpTestHandler, NULL, 0, 100); +} \ No newline at end of file diff --git a/cube/User/Src/main2.c b/cube/User/Src/main2.c index a01a610..fc6c779 100644 --- a/cube/User/Src/main2.c +++ b/cube/User/Src/main2.c @@ -18,7 +18,7 @@ #include #include #include - +// #include void my_setup_1() { schInit(); @@ -193,7 +193,7 @@ void my_setup_2() { wizInit(); mqttCommInit(); - +// httpTestInit(); frontendInit(); frontendSetThreshold(240); diff --git a/cube/User/Src/ports.c b/cube/User/Src/ports.c index 6f75a21..6e388cf 100644 --- a/cube/User/Src/ports.c +++ b/cube/User/Src/ports.c @@ -6,4 +6,7 @@ const uint8_t DHCP_SOCK = 0; const uint8_t MQTT_SOCK = 1; -const uint8_t TCPTEST_SOCK = 2; \ No newline at end of file +const uint8_t TCPTEST_SOCK = 2; +const uint8_t HTTP_SOCK_1 = 3; +const uint8_t HTTP_SOCK_2 = 4; +const uint8_t HTTP_SOCK_3 = 5; \ No newline at end of file