64 lines
1.5 KiB
C
64 lines
1.5 KiB
C
#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);
|
|
} |