http test, not working

This commit is contained in:
2020-11-15 23:10:03 +01:00
parent 4f27f18970
commit b9e1baee5b
6 changed files with 82 additions and 6 deletions

9
cube/User/Inc/httpTest.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef _HTTPTEST_H_
#define _HTTPTEST_H_
#include <stdint.h>
void httpTestInit();
#endif /* _HTTPTEST_H_ */

View File

@ -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 {

64
cube/User/Src/httpTest.c Normal file
View File

@ -0,0 +1,64 @@
#include <httpTest.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <socket.h>
#include <httpServer.h>
#include <logger.h>
#include <PontCoopScheduler.h>
#include <wizHelper.h>
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);
}

View File

@ -18,7 +18,7 @@
#include <eeprom.h>
#include <wizHelper.h>
#include <mqttComm.h>
// #include <httpTest.h>
void my_setup_1() {
schInit();
@ -193,7 +193,7 @@ void my_setup_2() {
wizInit();
mqttCommInit();
// httpTestInit();
frontendInit();
frontendSetThreshold(240);

View File

@ -6,4 +6,7 @@
const uint8_t DHCP_SOCK = 0;
const uint8_t MQTT_SOCK = 1;
const uint8_t TCPTEST_SOCK = 2;
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;