diff --git a/src/httpserver/http_tcp_server.c b/src/httpserver/http_tcp_server.c index 0bc91ccdb..25e1906d7 100644 --- a/src/httpserver/http_tcp_server.c +++ b/src/httpserver/http_tcp_server.c @@ -170,14 +170,18 @@ static void tcp_server_thread( beken_thread_arg_t arg ) if ( client_fd >= 0 ) { #if PLATFORM_XR809 +#if DISABLE_SEPARATE_THREAD_FOR_EACH_TCP_CLIENT + +#else OS_Thread_t clientThreadUnused ; +#endif #endif os_strcpy( client_ip_str, inet_ntoa( client_addr.sin_addr ) ); ADDLOG_DEBUG(LOG_FEATURE_HTTP, "TCP Client %s:%d connected, fd: %d", client_ip_str, client_addr.sin_port, client_fd ); #if DISABLE_SEPARATE_THREAD_FOR_EACH_TCP_CLIENT // Use main server thread (blocking all other clients) // right now, I am getting OS_ThreadCreate everytime on XR809 platform - tcp_client_thread(client_fd); + tcp_client_thread((beken_thread_arg_t)client_fd); #else // Create separate thread for client if ( kNoErr != diff --git a/src/httpserver/new_http.c b/src/httpserver/new_http.c index 7d1973802..f48121af0 100644 --- a/src/httpserver/new_http.c +++ b/src/httpserver/new_http.c @@ -783,7 +783,7 @@ int HTTP_ProcessPacket(http_request_t *request) { } #if PLATFORM_XR809 //uint32_t flash_read(uint32_t flash, uint32_t addr,void *buf, uint32_t size) -#define FLASH_INDEX_XR809 0 + #define FLASH_INDEX_XR809 0 res = flash_read(FLASH_INDEX_XR809, nowOfs, buffer, now); #else res = tuya_hal_flash_read (nowOfs, buffer,now); diff --git a/src/new_cfg.c b/src/new_cfg.c index 02f0351fa..03b5dea29 100644 --- a/src/new_cfg.c +++ b/src/new_cfg.c @@ -82,6 +82,18 @@ const char *CFG_GetDeviceName(){ const char *CFG_GetShortDeviceName(){ return g_shortDeviceName; } + +#if WINDOWS +#define DEVICENAME_PREFIX_FULL "WinTest" +#define DEVICENAME_PREFIX_SHORT "WT" +#elif PLATFORM_XR809 +#define DEVICENAME_PREFIX_FULL "OpenXR809" +#define DEVICENAME_PREFIX_SHORT "oxr" +#else +#define DEVICENAME_PREFIX_FULL "OpenBK7231T" +#define DEVICENAME_PREFIX_SHORT "obk" +#endif + void CFG_CreateDeviceNameUnique() { // must be unsigned, else print below prints negatives as e.g. FFFFFFFe @@ -93,8 +105,8 @@ void CFG_CreateDeviceNameUnique() #else wifi_get_mac_address((char *)mac, CONFIG_ROLE_STA); #endif - sprintf(g_deviceName,"OpenBK7231T_%02X%02X%02X%02X",mac[2],mac[3],mac[4],mac[5]); - sprintf(g_shortDeviceName,"obk%02X%02X%02X%02X",mac[2],mac[3],mac[4],mac[5]); + sprintf(g_deviceName,DEVICENAME_PREFIX_FULL"_%02X%02X%02X%02X",mac[2],mac[3],mac[4],mac[5]); + sprintf(g_shortDeviceName,DEVICENAME_PREFIX_SHORT"%02X%02X%02X%02X",mac[2],mac[3],mac[4],mac[5]); // NOT WORKING, I done it other way, see ethernetif.c //net_dhcp_hostname_set(g_shortDeviceName); @@ -157,8 +169,8 @@ void CFG_SaveWiFi() { printf("CFG_SaveWiFi: sysinfo_get returned 0!\n\r"); return; } - strcpy_safe(inf->wlan_sta_param.ssid, g_wifi_ssid, sizeof(inf->wlan_sta_param.ssid)); - strcpy_safe(inf->wlan_sta_param.psk, g_wifi_pass, sizeof(inf->wlan_sta_param.psk)); + strcpy_safe((char*)inf->wlan_sta_param.ssid, g_wifi_ssid, sizeof(inf->wlan_sta_param.ssid)); + strcpy_safe((char*)inf->wlan_sta_param.psk, g_wifi_pass, sizeof(inf->wlan_sta_param.psk)); res = sysinfo_save_wrapper(); if(res != 0) { @@ -183,8 +195,8 @@ void CFG_LoadWiFi() { printf("CFG_LoadWiFi: sysinfo_get returned 0!\n\r"); return; } - strcpy_safe(g_wifi_ssid,inf->wlan_sta_param.ssid,sizeof(g_wifi_ssid)); - strcpy_safe(g_wifi_pass,inf->wlan_sta_param.psk,sizeof(g_wifi_pass)); + strcpy_safe(g_wifi_ssid,(char*)inf->wlan_sta_param.ssid,sizeof(g_wifi_ssid)); + strcpy_safe(g_wifi_pass,(char*)inf->wlan_sta_param.psk,sizeof(g_wifi_pass)); #else { // try to read 'old' structure with extra 8 bytes @@ -212,14 +224,14 @@ void CFG_LoadWiFi() { #if PLATFORM_XR809 int sysinfo_checksum(sysinfo_t *inf) { int crc = 0; - crc ^= Tiny_CRC8(&inf->mac_addr,sizeof(inf->mac_addr)); - crc ^= Tiny_CRC8(&inf->wlan_mode,sizeof(inf->wlan_mode)); - crc ^= Tiny_CRC8(&inf->wlan_sta_param,sizeof(inf->wlan_sta_param)); - crc ^= Tiny_CRC8(&inf->wlan_ap_param,sizeof(inf->wlan_ap_param)); - crc ^= Tiny_CRC8(&inf->netif_sta_param,sizeof(inf->netif_sta_param)); - crc ^= Tiny_CRC8(&inf->netif_ap_param,sizeof(inf->netif_ap_param)); - crc ^= Tiny_CRC8(&inf->mqtt_param,sizeof(inf->mqtt_param)); - crc ^= Tiny_CRC8(&inf->pins,sizeof(inf->pins)); + crc ^= Tiny_CRC8((const char*)&inf->mac_addr,sizeof(inf->mac_addr)); + crc ^= Tiny_CRC8((const char*)&inf->wlan_mode,sizeof(inf->wlan_mode)); + crc ^= Tiny_CRC8((const char*)&inf->wlan_sta_param,sizeof(inf->wlan_sta_param)); + crc ^= Tiny_CRC8((const char*)&inf->wlan_ap_param,sizeof(inf->wlan_ap_param)); + crc ^= Tiny_CRC8((const char*)&inf->netif_sta_param,sizeof(inf->netif_sta_param)); + crc ^= Tiny_CRC8((const char*)&inf->netif_ap_param,sizeof(inf->netif_ap_param)); + crc ^= Tiny_CRC8((const char*)&inf->mqtt_param,sizeof(inf->mqtt_param)); + crc ^= Tiny_CRC8((const char*)&inf->pins,sizeof(inf->pins)); return crc; } diff --git a/src/new_common.h b/src/new_common.h index 4fce10823..61a396369 100644 --- a/src/new_common.h +++ b/src/new_common.h @@ -79,4 +79,6 @@ typedef unsigned char byte; int strcat_safe(char *tg, const char *src, int tgMaxLen); int strcpy_safe(char *tg, const char *src, int tgMaxLen); void urldecode2_safe(char *dst, const char *srcin, int maxDstLen); -int Time_getUpTimeSeconds(); +int Time_getUpTimeSeconds(); +char Tiny_CRC8(const char *data,int length); +