diff --git a/src/httpserver/rest_interface.c b/src/httpserver/rest_interface.c
index 97d298afb..070185f51 100644
--- a/src/httpserver/rest_interface.c
+++ b/src/httpserver/rest_interface.c
@@ -130,11 +130,12 @@ const char* apppage4 = "startup.js\">"
/* Extracts string token value into outBuffer (128 char). Returns true if the operation was successful. */
bool tryGetTokenString(const char* json, jsmntok_t* tok, char* outBuffer) {
+ int length;
if (tok == NULL || tok->type != JSMN_STRING) {
return false;
}
- int length = tok->end - tok->start;
+ length = tok->end - tok->start;
//Don't have enough buffer
if (length > MAX_JSON_VALUE_LENGTH) {
@@ -842,12 +843,13 @@ static int http_rest_post_pins(http_request_t* request) {
i += t[i + 1].size + 1;
}
else if (strcmp(tokenStrValue, "deviceFlag") == 0) {
+ int flag;
jsmntok_t* flagTok = &t[i + 1];
if (flagTok == NULL || flagTok->type != JSMN_PRIMITIVE) {
continue;
}
- int flag = atoi(json_str + flagTok->start);
+ flag = atoi(json_str + flagTok->start);
ADDLOG_DEBUG(LOG_FEATURE_API, "received deviceFlag %d", flag);
if (flag >= 0 && flag <= 10) {
diff --git a/src/logging/logging.c b/src/logging/logging.c
index 26c934fb2..e6437fc6d 100644
--- a/src/logging/logging.c
+++ b/src/logging/logging.c
@@ -86,7 +86,7 @@ void LOG_SetRawSocketCallback(int newFD)
g_extraSocketToSendLOG = newFD;
}
-#ifdef WINDOWS
+#ifdef WINDOWS_SIMPLE_LOGGER
void addLogAdv(int level, int feature, const char* fmt, ...)
{
va_list argList;
@@ -281,6 +281,10 @@ void addLogAdv(int level, int feature, const char* fmt, ...)
{
char* tmp;
char* t;
+ int len;
+ va_list argList;
+ BaseType_t taken;
+ int i;
if (fmt == 0)
{
@@ -293,13 +297,12 @@ void addLogAdv(int level, int feature, const char* fmt, ...)
return;
}
- va_list argList;
// if not initialised, direct output
if (!initialised) {
initLog();
}
- BaseType_t taken = xSemaphoreTake(logMemory.mutex, 100);
+ taken = xSemaphoreTake(logMemory.mutex, 100);
tmp = g_loggingBuffer;
memset(tmp, 0, LOGGING_BUFFER_SIZE);
t = tmp;
@@ -326,10 +329,13 @@ void addLogAdv(int level, int feature, const char* fmt, ...)
if (tmp[strlen(tmp) - 1] == '\n') tmp[strlen(tmp) - 1] = '\0';
if (tmp[strlen(tmp) - 1] == '\r') tmp[strlen(tmp) - 1] = '\0';
- int len = strlen(tmp); // save 3 bytes at end for /r/n/0
+ len = strlen(tmp); // save 3 bytes at end for /r/n/0
tmp[len++] = '\r';
tmp[len++] = '\n';
tmp[len] = '\0';
+#if WINDOWS
+ printf(tmp);
+#endif
#if PLATFORM_XR809
printf(tmp);
#endif
@@ -361,7 +367,7 @@ void addLogAdv(int level, int feature, const char* fmt, ...)
return;
}
- for (int i = 0; i < len; i++)
+ for ( i = 0; i < len; i++)
{
logMemory.log[logMemory.head] = tmp[i];
logMemory.head = (logMemory.head + 1) % LOGSIZE;
@@ -397,11 +403,15 @@ void addLogAdv(int level, int feature, const char* fmt, ...)
static int getData(char* buff, int buffsize, int* tail) {
- if (!initialised) return 0;
- BaseType_t taken = xSemaphoreTake(logMemory.mutex, 100);
+ BaseType_t taken;
+ int count;
+ char* p;
+ if (!initialised)
+ return 0;
+ taken = xSemaphoreTake(logMemory.mutex, 100);
- int count = 0;
- char* p = buff;
+ count = 0;
+ p = buff;
while (buffsize > 1) {
if (*tail == logMemory.head) {
break;
@@ -510,6 +520,7 @@ void startSerialLog() {
void log_server_thread(beken_thread_arg_t arg)
{
//(void)( arg );
+ int tcp_select_fd;
OSStatus err = kNoErr;
struct sockaddr_in server_addr, client_addr;
socklen_t sockaddr_t_size = sizeof(client_addr);
@@ -518,7 +529,7 @@ void log_server_thread(beken_thread_arg_t arg)
fd_set readfds;
tcp_listen_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- int tcp_select_fd = tcp_listen_fd + 1;
+ tcp_select_fd = tcp_listen_fd + 1;
server_addr.sin_family = AF_INET;
server_addr.sin_addr.s_addr = INADDR_ANY;/* Accept conenction request on all network interface */
@@ -613,8 +624,8 @@ static void log_serial_thread(beken_thread_arg_t arg)
static int http_getlograw(http_request_t* request) {
- http_setup(request, httpMimeTypeHTML);
int len = 0;
+ http_setup(request, httpMimeTypeHTML);
// get log in small chunks, posting on http
do {
@@ -630,12 +641,12 @@ static int http_getlograw(http_request_t* request) {
}
static int http_getlog(http_request_t* request) {
+ char* post = "";
http_setup(request, httpMimeTypeHTML);
http_html_start(request, "Log");
poststr(request, htmlFooterReturnToMenu);
poststr(request, "
");
- char* post = "
";
http_getlograw(request);
diff --git a/src/new_common.h b/src/new_common.h
index 07f4af275..78c72f37b 100644
--- a/src/new_common.h
+++ b/src/new_common.h
@@ -88,11 +88,14 @@ This platform is not supported, error!
#include
+#define bk_printf printf
+
// generic
typedef int bool;
#define true 1
#define false 0
+typedef int BaseType_t;
typedef unsigned char u8;
typedef unsigned char u8_t;
typedef unsigned int u32;
@@ -112,6 +115,7 @@ typedef unsigned short u16_t;
//#define UINT32_MAX (0xffffffff)
//#endif
+#define LWIP_UNUSED_ARG(x)
#define LWIP_CONST_CAST(target_type, val) ((target_type)(val))
// os
@@ -119,8 +123,11 @@ typedef unsigned short u16_t;
#define os_malloc malloc
#define os_strlen strlen
#define os_memset memset
+#define os_memcpy memcpy
#define os_strstr strstr
#define os_strcpy strcpy
+#define os_strchr strchr
+#define os_strcmp strcmp
#define os_memmove memmove
// RTOS
@@ -302,6 +309,8 @@ typedef unsigned char byte;
#include
#include
#include
+#include
+#include
#else
diff --git a/src/win_main.c b/src/win_main.c
index 62e70a194..e32666e3c 100644
--- a/src/win_main.c
+++ b/src/win_main.c
@@ -29,8 +29,22 @@ int snprintf(char *buffer, unsigned int len, const char *fmt, ...) {
va_end(val);
return rv;
}
+void CMD_StartTCPCommandLine() {
+}
+void Main_SetupPingWatchDog(const char *target/*, int delayBetweenPings_Seconds*/) {
+
+}
+void Main_PingWatchDogSilent() {
+
+}
+int PingWatchDog_GetTotalLost() {
+ return 0;
+}
+int PingWatchDog_GetTotalReceived() {
+ return 0;
+}
void strcat_safe_test(){
char tmpA[16];
char tmpB[16];
@@ -63,14 +77,14 @@ void strcat_safe_test(){
urldecode2_safe(buff,"qqqqqq%40qqqq",sizeof(buff));
- misc_formatUpTimeString(15, timeStrA);
- misc_formatUpTimeString(65, timeStrB);
- misc_formatUpTimeString(125, timeStrC);
- misc_formatUpTimeString(60*60, timeStrD);
- misc_formatUpTimeString(4*60*60, timeStrE);
- misc_formatUpTimeString(24*60*60, timeStrF);
- misc_formatUpTimeString(24*60*60+60*60+50, timeStrG);
- misc_formatUpTimeString(100*24*60*60+60*60+15*60+50, timeStrH);
+ //misc_formatUpTimeString(15, timeStrA);
+ //misc_formatUpTimeString(65, timeStrB);
+ //misc_formatUpTimeString(125, timeStrC);
+ //misc_formatUpTimeString(60*60, timeStrD);
+ //misc_formatUpTimeString(4*60*60, timeStrE);
+ //misc_formatUpTimeString(24*60*60, timeStrF);
+ //misc_formatUpTimeString(24*60*60+60*60+50, timeStrG);
+ //misc_formatUpTimeString(100*24*60*60+60*60+15*60+50, timeStrH);
// some command examples, compatible with Tasmota syntax
//CMD_ExecuteCommand("TuyaSend3 108,ff0000646464ff");
@@ -86,15 +100,15 @@ void strcat_safe_test(){
//CMD_ExecuteCommand("Tuyqqqqqqqqqq");
}
-int Time_getUpTimeSeconds() {
- return rand()% 100000;
-}
+
// placeholder - TODO
char myIP[] = "127.0.0.1";
char *getMyIp(){
return myIP;
}
+void __asm__(const char *s) {
+}
DWORD WINAPI Thread_EverySecond(void* arg)
{
while(1){
@@ -134,9 +148,6 @@ DWORD WINAPI Thread_SimulateTUYAMCUSendingData(void* arg)
return 0;
}
-int Main_IsConnectedToWiFi() {
- return 1;
-}
//void addLogAdv(int level, int feature, char *fmt, ...){
// char t[512];
// va_list argList;
@@ -147,7 +158,59 @@ int Main_IsConnectedToWiFi() {
//
// printf(t);
//}
+
int __cdecl main(void)
+{
+ int accum_time = 0;
+
+ WSADATA wsaData;
+ int iResult;
+ // Initialize Winsock
+ iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
+ if (iResult != 0) {
+ printf("WSAStartup failed with error: %d\n", iResult);
+ return 1;
+ }
+
+ Main_Init();
+
+ while(1) {
+ accum_time += 5;
+ Sleep(5);
+ PIN_ticks(0);
+ HTTPServer_RunQuickTick();
+ if(accum_time>1000){
+ accum_time = 0;
+ Main_OnEverySecond();
+ }
+ }
+ return 0;
+}
+UINT32 flash_read(char* user_buf, UINT32 count, UINT32 address){
+ return 0;
+}
+// initialise OTA flash starting at startaddr
+int init_ota(unsigned int startaddr) {
+ return 0;
+}
+
+// add any length of data to OTA
+void add_otadata(unsigned char *data, int len) {
+ return;
+}
+
+// finalise OTA flash (write last sector if incomplete)
+void close_ota() {
+ return;
+}
+
+void otarequest(const char *urlin) {
+ return;
+}
+
+int ota_progress();
+int ota_total_bytes();
+int __cdecl main_old(void)
{
WSADATA wsaData;
int iResult;
@@ -183,9 +246,9 @@ int __cdecl main(void)
printf("WSAStartup failed with error: %d\n", iResult);
return 1;
}
- NTP_SendRequest_BlockingMode();
- Sleep(500);
- return 1;
+ //NTP_SendRequest_BlockingMode();
+ //Sleep(500);
+ // return 1;
CreateThread(NULL, 0, Thread_EverySecond, 0, 0, NULL);
CreateThread(NULL, 0, Thread_SimulateTUYAMCUSendingData, 0, 0, NULL);
@@ -197,6 +260,7 @@ int __cdecl main(void)
hints.ai_protocol = IPPROTO_TCP;
hints.ai_flags = AI_PASSIVE;
+ HTTPServer_Start();
// Resolve the server address and port
iResult = getaddrinfo(NULL, DEFAULT_PORT, &hints, &result);
if ( iResult != 0 ) {
diff --git a/windowsTest_msvc2008.vcproj b/windowsTest_msvc2008.vcproj
index c4089e106..9f05a98b8 100644
--- a/windowsTest_msvc2008.vcproj
+++ b/windowsTest_msvc2008.vcproj
@@ -316,6 +316,7 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -574,10 +615,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -2430,7 +2515,6 @@
+
+
+
+
+
+