42 lines
1013 B
C
Raw Normal View History

2020-11-11 14:19:02 +01:00
#include <tcpTest.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <socket.h>
#include <logger.h>
#include <PontCoopScheduler.h>
2020-11-11 14:26:28 +01:00
#include <wizHelper.h>
2020-11-11 14:19:02 +01:00
const uint8_t TCPTEST_SOCK;
void tcpTestHandler(void *handle) {
2020-11-11 14:26:28 +01:00
static bool socketInitialized = false;
if (isNetworkAvailable()) {
if (! socketInitialized) {
coloredMsg(LOG_YELLOW, "tth, initializing socket");
int8_t res = socket(TCPTEST_SOCK, Sn_MR_TCP, 12345, SF_IO_NONBLOCK);
coloredMsg(LOG_YELLOW, "tth, socket returns %d", res);
if (res == TCPTEST_SOCK) {
coloredMsg(LOG_YELLOW, "tth, socket is initialized");
socketInitialized = true;
}
} else {
coloredMsg(LOG_YELLOW, "tth, doing something useful with the socket");
}
} else {
colorMsg(LOG_YELLOW, "tth, network not yet ready");
}
2020-11-11 14:19:02 +01:00
}
void tcpTestInit() {
2020-11-11 14:26:28 +01:00
schAdd(tcpTestHandler, NULL, 0, 100);
2020-11-11 14:19:02 +01:00
}