#include "../new_common.h" #include "ctype.h" #include "http_fns.h" #include "../new_pins.h" #include "../new_cfg.h" #include "../ota/ota.h" #ifdef WINDOWS // nothing #elif PLATFORM_XR809 #include #elif defined(PLATFORM_BK7231N) // tuya-iotos-embeded-sdk-wifi-ble-bk7231n/sdk/include/tuya_hal_storage.h #include "tuya_hal_storage.h" #include "BkDriverFlash.h" #include "../flash_config/flash_config.h" #else // REALLY? A typo in Tuya SDK? Storge? // tuya-iotos-embeded-sdk-wifi-ble-bk7231t/platforms/bk7231t/tuya_os_adapter/include/driver/tuya_hal_storge.h #include "../logging/logging.h" #include "tuya_hal_storge.h" #include "BkDriverFlash.h" #include "../flash_config/flash_config.h" #endif typedef struct template_s { void (*setter)(); const char *name; } template_t; template_t g_templates [] = { { Setup_Device_Empty, "Empty"}, // BK7231N devices { Setup_Device_BK7231N_CB2S_QiachipSmartSwitch, "[BK7231N][CB2S] QiaChip Smart Switch"}, // BK7231T devices { Setup_Device_BK7231T_WB2S_QiachipSmartSwitch, "[BK7231T][WB2S] QiaChip Smart Switch"}, { Setup_Device_TuyaWL_SW01_16A, "WL SW01 16A"}, { Setup_Device_TuyaSmartLife4CH10A, "Smart Life 4CH 10A"}, { Setup_Device_IntelligentLife_NF101A, "Intelligent Life NF101A"}, { Setup_Device_TuyaLEDDimmerSingleChannel, "Tuya LED Dimmer Single Channel PWM WB3S"}, { Setup_Device_CalexLEDDimmerFiveChannel, "Calex RGBWW LED Dimmer Five Channel PWM BK7231S"}, { Setup_Device_CalexPowerStrip_900018_1v1_0UK, "Calex UK power strip 900018.1 v1.0 UK"}, { Setup_Device_ArlecCCTDownlight, "Arlec CCT LED Downlight ALD029CHA"}, { Setup_Device_NedisWIFIPO120FWT_16A, "Nedis WIFIPO120FWT SmartPlug 16A"}, { Setup_Device_NedisWIFIP130FWT_10A, "Nedis WIFIP130FWT SmartPlug 10A"}, { Setup_Device_BK7231T_Raw_PrimeWiFiSmartOutletsOutdoor_CCWFIO232PK, "Prime SmartOutlet Outdoor 2x Costco"}, { Setup_Device_EmaxHome_EDU8774, "Emax Home EDU8774 SmartPlug 16A"}, { Setup_Device_TuyaSmartPFW02G, "Tuya Smart PFW02-G"} }; int g_total_templates = sizeof(g_templates)/sizeof(g_templates[0]); unsigned char hexdigit( char hex ) { return (hex <= '9') ? hex - '0' : toupper((unsigned char)hex) - 'A' + 10 ; } unsigned char hexbyte( const char* hex ) { return (hexdigit(*hex) << 4) | hexdigit(*(hex+1)) ; } int http_fn_empty_url(http_request_t *request) { poststr(request,"HTTP/1.1 302 OK\nLocation: /index\nConnection: close\n\n"); poststr(request, NULL); return 0; } int http_fn_index(http_request_t *request) { int relayFlags; int pwmFlags; int j, i; char tmpA[128]; relayFlags = 0; pwmFlags = 0; http_setup(request, httpMimeTypeHTML); poststr(request,htmlHeader); poststr(request,""); poststr(request,g_header); if(http_getArg(request->url,"tgl",tmpA,sizeof(tmpA))) { j = atoi(tmpA); hprintf128(request,"

Toggled %i!

",j); CHANNEL_Toggle(j); } if(http_getArg(request->url,"on",tmpA,sizeof(tmpA))) { j = atoi(tmpA); hprintf128(request,"

Enabled %i!

",j); CHANNEL_Set(j,255,1); } if(http_getArg(request->url,"off",tmpA,sizeof(tmpA))) { j = atoi(tmpA); hprintf128(request,"

Disabled %i!

",j); CHANNEL_Set(j,0,1); } if(http_getArg(request->url,"pwm",tmpA,sizeof(tmpA))) { int newPWMValue = atoi(tmpA); http_getArg(request->url,"pwmIndex",tmpA,sizeof(tmpA)); j = atoi(tmpA); hprintf128(request,"

Changed pwm %i to %i!

",j,newPWMValue); CHANNEL_Set(j,newPWMValue,1); } for(i = 0; i < GPIO_MAX; i++) { int role = PIN_GetPinRoleForPinIndex(i); int ch = PIN_GetPinChannelForPinIndex(i); if(role == IOR_Relay || role == IOR_Relay_n || role == IOR_LED || role == IOR_LED_n) { BIT_SET(relayFlags,ch); } if(role == IOR_PWM) { BIT_SET(pwmFlags,ch); } } for(i = 0; i < CHANNEL_MAX; i++) { if(BIT_CHECK(relayFlags,i)) { const char *c; if(CHANNEL_Check(i)) { c = "r"; } else { c = "g"; } poststr(request,"
"); hprintf128(request,"",i); hprintf128(request,"
",c,i); } if(BIT_CHECK(pwmFlags,i)) { int pwmValue; pwmValue = CHANNEL_Get(i); hprintf128(request,"
",i); hprintf128(request,"",i,pwmValue); hprintf128(request,"",i); hprintf128(request,"
",i); poststr(request,""); } } // strcat(outbuf,""); if(http_getArg(request->url,"restart",tmpA,sizeof(tmpA))) { poststr(request,"
Module will restart soon
"); #if WINDOWS #elif PLATFORM_XR809 #else RESET_ScheduleModuleReset(3); #endif } poststr(request,"
"); poststr(request,"
\ \ \
"); poststr(request,"
"); poststr(request,htmlReturnToMenu); HTTP_AddBuildFooter(request); poststr(request,htmlEnd); poststr(request, NULL); return 0; } int http_fn_about(http_request_t *request){ http_setup(request, httpMimeTypeHTML); poststr(request,htmlHeader); poststr(request,g_header); poststr(request,"About us page."); poststr(request,htmlReturnToMenu); HTTP_AddBuildFooter(request); poststr(request,htmlEnd); poststr(request, NULL); return 0; } int http_fn_cfg_mqtt(http_request_t *request) { int i; http_setup(request, httpMimeTypeHTML); poststr(request,htmlHeader); poststr(request,g_header); poststr(request,"

Use this to connect to your MQTT

"); poststr(request,"
\
\
\
\

\
\
\
\
\
\
\ \
"); poststr(request,htmlReturnToCfg); HTTP_AddBuildFooter(request); poststr(request,htmlEnd); poststr(request, NULL); return 0; } int http_fn_cfg_mqtt_set(http_request_t *request) { char tmpA[128]; http_setup(request, httpMimeTypeHTML); poststr(request,htmlHeader); poststr(request,g_header); if(http_getArg(request->url,"host",tmpA,sizeof(tmpA))) { CFG_SetMQTTHost(tmpA); } if(http_getArg(request->url,"port",tmpA,sizeof(tmpA))) { CFG_SetMQTTPort(atoi(tmpA)); } if(http_getArg(request->url,"user",tmpA,sizeof(tmpA))) { CFG_SetMQTTUserName(tmpA); } if(http_getArg(request->url,"password",tmpA,sizeof(tmpA))) { CFG_SetMQTTPass(tmpA); } if(http_getArg(request->url,"client",tmpA,sizeof(tmpA))) { CFG_SetMQTTBrokerName(tmpA); } if(CFG_SaveMQTT()) { poststr(request,"MQTT mode set!"); } else { poststr(request,"Error saving MQTT settings to flash!"); } poststr(request,"Please wait for module to connect... if there is problem, restart it..."); poststr(request,"
"); poststr(request,"Return to MQTT settings"); poststr(request,"
"); poststr(request,htmlReturnToCfg); HTTP_AddBuildFooter(request); poststr(request,htmlEnd); poststr(request, NULL); return 0; } int http_fn_cfg_webapp(http_request_t *request) { http_setup(request, httpMimeTypeHTML); poststr(request,htmlHeader); poststr(request,g_header); poststr(request,"

Use this to set the URL of the Webapp

"); poststr(request,"
\
\
\ \
"); poststr(request,htmlReturnToCfg); HTTP_AddBuildFooter(request); poststr(request,htmlEnd); poststr(request, NULL); return 0; } int http_fn_cfg_webapp_set(http_request_t *request) { char tmpA[128]; http_setup(request, httpMimeTypeHTML); poststr(request,htmlHeader); poststr(request,g_header); if(http_getArg(request->url,"url",tmpA,sizeof(tmpA))) { if(CFG_SetWebappRoot(tmpA)) { hprintf128(request,"Webapp url set to %s", tmpA); } else { hprintf128(request,"Webapp url change error - failed to save to flash."); } } else { poststr(request,"Webapp url not set because you didn't specify the argument."); } poststr(request,"
"); poststr(request,htmlReturnToCfg); HTTP_AddBuildFooter(request); poststr(request,htmlEnd); poststr(request, NULL); return 0; } int http_fn_cfg_wifi(http_request_t *request) { // for a test, show password as well... const char *cur_ssid, *cur_pass; char tmpA[128]; int i; http_setup(request, httpMimeTypeHTML); poststr(request,htmlHeader); poststr(request,g_header); /*bChanged = 0; if(http_getArg(recvbuf,"ssid",tmpA,sizeof(tmpA))) { CFG_SetWiFiSSID(tmpA); poststr(request,"

WiFi SSID set!

"); bChanged = 1; } if(http_getArg(recvbuf,"pass",tmpA,sizeof(tmpA))) { CFG_SetWiFiPass(tmpA); poststr(request,"

WiFi Password set!

"); bChanged = 1; } if(bChanged) { poststr(request,"

Device will reconnect after restarting

"); }*/ poststr(request,"

Check networks reachable by module

This will lag few seconds.
"); if(http_getArg(request->url,"scan",tmpA,sizeof(tmpA))) { #ifdef WINDOWS poststr(request,"Not available on Windows
"); #elif PLATFORM_XR809 poststr(request,"TODO XR809
"); #elif PLATFORM_BK7231T AP_IF_S *ar; uint32_t num; bk_printf("Scan begin...\r\n"); tuya_hal_wifi_all_ap_scan(&ar,&num); bk_printf("Scan returned %i networks\r\n",num); for(i = 0; i < num; i++) { hprintf128(request,"[%i/%i] SSID: %s, Channel: %i, Signal %i
",i,(int)num,ar[i].ssid, ar[i].channel, ar[i].rssi); } tuya_hal_wifi_release_ap(ar); #elif PLATFORM_BK7231N poststr(request,"TODO: BK7231N support for scan
"); #else #error "Unknown platform" poststr(request,"Unknown platform
"); #endif } poststr(request,"
\ \ \
"); poststr(request,"

Use this to disconnect from your WiFi

"); poststr(request,"
\ \ \
"); poststr(request,"

Use this to connect to your WiFi

"); poststr(request,"
\
\
\
\

\ \
"); poststr(request,htmlReturnToCfg); HTTP_AddBuildFooter(request); poststr(request,htmlEnd); poststr(request, NULL); return 0; } int http_fn_cfg_wifi_set(http_request_t *request) { char tmpA[128]; printf("HTTP_ProcessPacket: generating cfg_wifi_set \r\n"); http_setup(request, httpMimeTypeHTML); poststr(request,htmlHeader); poststr(request,g_header); if(http_getArg(request->url,"open",tmpA,sizeof(tmpA))) { CFG_SetWiFiSSID(""); CFG_SetWiFiPass(""); poststr(request,"WiFi mode set: open access point."); } else { if(http_getArg(request->url,"ssid",tmpA,sizeof(tmpA))) { CFG_SetWiFiSSID(tmpA); } if(http_getArg(request->url,"pass",tmpA,sizeof(tmpA))) { CFG_SetWiFiPass(tmpA); } poststr(request,"WiFi mode set: connect to WLAN."); } printf("HTTP_ProcessPacket: calling CFG_SaveWiFi \r\n"); CFG_SaveWiFi(); printf("HTTP_ProcessPacket: done CFG_SaveWiFi \r\n"); poststr(request,"Please wait for module to reset..."); poststr(request,"
"); poststr(request,"Return to WiFi settings"); poststr(request,"
"); poststr(request,htmlReturnToCfg); HTTP_AddBuildFooter(request); poststr(request,htmlEnd); poststr(request, NULL); return 0; } int http_fn_cfg_loglevel_set(http_request_t *request) { char tmpA[128]; printf("HTTP_ProcessPacket: generating cfg_loglevel_set \r\n"); http_setup(request, httpMimeTypeHTML); poststr(request,htmlHeader); poststr(request,g_header); if(http_getArg(request->url,"loglevel",tmpA,sizeof(tmpA))) { #if PLATFORM_BK7231T loglevel = atoi(tmpA); #endif poststr(request,"LOG level changed."); } poststr(request,"
\
\

\ \
"); poststr(request,"
"); poststr(request,"Return to config settings"); poststr(request,"
"); poststr(request,htmlReturnToCfg); HTTP_AddBuildFooter(request); poststr(request,htmlEnd); poststr(request, NULL); return 0; } int http_fn_cfg_mac(http_request_t *request) { // must be unsigned, else print below prints negatives as e.g. FFFFFFFe unsigned char mac[6]; char tmpA[128]; int i; http_setup(request, httpMimeTypeHTML); poststr(request,htmlHeader); poststr(request,g_header); if(http_getArg(request->url,"mac",tmpA,sizeof(tmpA))) { for( i = 0; i < 6; i++ ) { mac[i] = hexbyte( &tmpA[i * 2] ) ; } //sscanf(tmpA,"%02X%02X%02X%02X%02X%02X",&mac[0],&mac[1],&mac[2],&mac[3],&mac[4],&mac[5]); if(WiFI_SetMacAddress((char*)mac)) { poststr(request,"

New MAC set!

"); } else { poststr(request,"

MAC change error?

"); } } WiFI_GetMacAddress((char *)mac); poststr(request,"

Here you can change MAC address.

"); poststr(request,"
\
\

\ \
"); poststr(request,htmlReturnToCfg); HTTP_AddBuildFooter(request); poststr(request,htmlEnd); poststr(request, NULL); return 0; } int http_fn_flash_read_tool(http_request_t *request) { int len = 16; int ofs = 1970176; int res; int rem; int now; int nowOfs; int hex; int i; char tmpA[128]; char tmpB[64]; http_setup(request, httpMimeTypeHTML); poststr(request,htmlHeader); poststr(request,g_header); poststr(request,"

Flash Read Tool

"); if( http_getArg(request->url,"hex",tmpA,sizeof(tmpA))){ hex = atoi(tmpA); } else { hex = 0; } if( http_getArg(request->url,"offset",tmpA,sizeof(tmpA)) && http_getArg(request->url,"len",tmpB,sizeof(tmpB))) { unsigned char buffer[128]; len = atoi(tmpB); ofs = atoi(tmpA); hprintf128(request,"Memory at %i with len %i reads: ",ofs,len); poststr(request,"
"); ///res = bekken_hal_flash_read (ofs, buffer,len); //sprintf(tmpA,"Result %i",res); // strcat(outbuf,tmpA); /// strcat(outbuf,"
"); nowOfs = ofs; rem = len; while(1) { if(rem > sizeof(buffer)) { now = sizeof(buffer); } else { now = rem; } #if PLATFORM_XR809 //uint32_t flash_read(uint32_t flash, uint32_t addr,void *buf, uint32_t size) #define FLASH_INDEX_XR809 0 res = flash_read(FLASH_INDEX_XR809, nowOfs, buffer, now); #else res = bekken_hal_flash_read (nowOfs, buffer,now); #endif for(i = 0; i < now; i++) { unsigned char val = buffer[i]; if(!hex && isprint(val)) { hprintf128(request,"'%c' ",val); } else { hprintf128(request,"%02X ",val); } } rem -= now; nowOfs += now; if(rem <= 0) { break; } } poststr(request,"
"); } poststr(request,"
"); poststr(request,"
"); poststr(request,"
\
",ofs); poststr(request,"
\ ",len); poststr(request,"

\ \
"); poststr(request,htmlReturnToCfg); HTTP_AddBuildFooter(request); poststr(request,htmlEnd); poststr(request, NULL); return 0; } #if PLATFORM_BK7231T | PLATFORM_BK7231N void test_ty_read_uart_data_to_buffer(int port, void* param) { int rc = 0; while((rc = uart_read_byte(port)) != -1) { // if(__ty_uart_read_data_size(port) < (ty_uart[port].buf_len-1)) // { // ty_uart[port].buf[ty_uart[port].in++] = rc; /// if(ty_uart[port].in >= ty_uart[port].buf_len){ /// ty_uart[port].in = 0; /// } // } } } #endif #if PLATFORM_BK7231T | PLATFORM_BK7231N #include "../../beken378/func/user_driver/BkDriverUart.h" #endif void TuyaMCU_Bridge_InitUART(int baud) { #if PLATFORM_BK7231T | PLATFORM_BK7231N bk_uart_config_t config; config.baud_rate = 9600; config.data_width = 0x03; config.parity = 0; //0:no parity,1:odd,2:even config.stop_bits = 0; //0:1bit,1:2bit config.flow_control = 0; //FLOW_CTRL_DISABLED config.flags = 0; bk_uart_initialize(0, &config, NULL); bk_uart_set_rx_callback(0, test_ty_read_uart_data_to_buffer, NULL); #else #endif } void TuyaMCU_Bridge_SendUARTByte(byte b) { #if PLATFORM_BK7231T | PLATFORM_BK7231N bk_send_byte(0, b); #elif WINDOWS // STUB - for testing printf("%02X", b); #else #endif } void TuyaMCU_Send(byte *data, int size) { int i; unsigned char check_sum; TuyaMCU_Bridge_InitUART(9600); check_sum = 0; for(i = 0; i < size; i++) { byte b = data[i]; check_sum += b; TuyaMCU_Bridge_SendUARTByte(b); } TuyaMCU_Bridge_SendUARTByte(check_sum); printf("\nWe sent %i bytes to Tuya MCU\n",size+1); } int http_fn_uart_tool(http_request_t *request) { char tmpA[256]; byte results[128]; int resultLen = 0; http_setup(request, httpMimeTypeHTML); poststr(request,htmlHeader); poststr(request,g_header); poststr(request,"

UART Tool

"); if(http_getArg(request->url,"data",tmpA,sizeof(tmpA))) { hprintf128(request,"

Sent %s!

",tmpA); if(0){ TuyaMCU_Send(tmpA, strlen(tmpA)); // bk_send_string(0,tmpA); } else { byte b; const char *p; p = tmpA; while(*p) { b = hexbyte(p); results[resultLen] = b; resultLen++; p+=2; } TuyaMCU_Send(results, resultLen); } } else { strcpy(tmpA,"Hello UART world"); } poststr(request,"
"); poststr(request,"
\
",tmpA); poststr(request,"
\ \
"); poststr(request,htmlReturnToCfg); HTTP_AddBuildFooter(request); poststr(request,htmlEnd); poststr(request, NULL); return 0; } int http_fn_config_dump_table(http_request_t *request) { http_setup(request, httpMimeTypeHTML); poststr(request,htmlHeader); poststr(request,g_header); #if WINDOWS poststr(request,"Not implemented
"); #elif PLATFORM_XR809 poststr(request,"Not implemented
"); #else poststr(request,"Dumped to log
"); config_dump_table(); #endif poststr(request,htmlReturnToCfg); HTTP_AddBuildFooter(request); poststr(request,htmlEnd); poststr(request, NULL); return 0; } int http_fn_cfg_quick(http_request_t *request) { char tmpA[128]; int j; http_setup(request, httpMimeTypeHTML); poststr(request,htmlHeader); poststr(request,g_header); poststr(request,"

Quick Config

"); if(http_getArg(request->url,"dev",tmpA,sizeof(tmpA))) { j = atoi(tmpA); hprintf128(request,"

Set dev %i!

",j); g_templates[j].setter(); } poststr(request,"
"); poststr(request, ""); poststr(request,"
"); poststr(request,htmlReturnToCfg); HTTP_AddBuildFooter(request); poststr(request,htmlEnd); poststr(request, NULL); return 0; } int http_fn_cfg_ha(http_request_t *request) { int relayFlags = 0; int pwmFlags = 0; int relayCount = 0; int pwmCount = 0; const char *baseName; int i; //char tmpA[128]; baseName = CFG_GetShortDeviceName(); http_setup(request, httpMimeTypeHTML); poststr(request,htmlHeader); poststr(request,g_header); poststr(request,"

Home Assistant Cfg

"); poststr(request,"

Paste this to configuration yaml

"); poststr(request,"
Make sure that you have \"switch:\" keyword only once! Home Assistant doesn't like dup keywords.
"); poststr(request,"
You can also use \"switch MyDeviceName:\" to avoid keyword duplication!
"); poststr(request,""); poststr(request,htmlReturnToCfg); HTTP_AddBuildFooter(request); poststr(request,htmlEnd); poststr(request, NULL); return 0; } int http_fn_cfg(http_request_t *request) { int i,j,k; http_setup(request, httpMimeTypeHTML); poststr(request,htmlHeader); poststr(request,g_header); poststr(request,"
"); poststr(request,"
"); poststr(request,"
"); poststr(request,"
"); poststr(request,"
"); poststr(request,"
"); poststr(request,"
"); poststr(request,"
"); poststr(request,"
"); poststr(request,"
"); poststr(request,"
"); #if PLATFORM_BK7231T | PLATFORM_BK7231N k = config_get_tableOffsets(BK_PARTITION_NET_PARAM,&i,&j); hprintf128(request,"BK_PARTITION_NET_PARAM: bOk %i, at %i, len %i
",k,i,j); k = config_get_tableOffsets(BK_PARTITION_RF_FIRMWARE,&i,&j); hprintf128(request,"BK_PARTITION_RF_FIRMWARE: bOk %i, at %i, len %i
",k,i,j); k = config_get_tableOffsets(BK_PARTITION_OTA,&i,&j); hprintf128(request,"BK_PARTITION_OTA: bOk %i, at %i, len %i
",k,i,j); #endif poststr(request,"Launch Web Application
"); poststr(request,htmlReturnToMenu); HTTP_AddBuildFooter(request); poststr(request,htmlEnd); poststr(request, NULL); return 0; } int http_fn_cfg_pins(http_request_t *request) { int iChanged = 0; int iChangedRequested = 0; int i; char tmpA[128]; char tmpB[64]; http_setup(request, httpMimeTypeHTML); poststr(request,htmlHeader); poststr(request,g_header); poststr(request,"
First textfield is used to enter channel index (relay index), used to support multiple relays and buttons
"); poststr(request,"
(so, first button and first relay should have channel 1, second button and second relay have channel 2, etc)
"); poststr(request,"
Second textfield (only for buttons) is used to enter channel to toggle when doing double click
"); poststr(request,"
(second textfield shows up when you change role to button and save...)
"); for(i = 0; i < GPIO_MAX; i++) { sprintf(tmpA, "%i",i); if(http_getArg(request->url,tmpA,tmpB,sizeof(tmpB))) { int role; int pr; iChangedRequested++; role = atoi(tmpB); pr = PIN_GetPinRoleForPinIndex(i); if(pr != role) { PIN_SetPinRoleForPinIndex(i,role); iChanged++; } } sprintf(tmpA, "r%i",i); if(http_getArg(request->url,tmpA,tmpB,sizeof(tmpB))) { int rel; int prevRel; iChangedRequested++; rel = atoi(tmpB); prevRel = PIN_GetPinChannelForPinIndex(i); if(prevRel != rel) { PIN_SetPinChannelForPinIndex(i,rel); iChanged++; } } sprintf(tmpA, "e%i",i); if(http_getArg(request->url,tmpA,tmpB,sizeof(tmpB))) { int rel; int prevRel; iChangedRequested++; rel = atoi(tmpB); prevRel = PIN_GetPinChannel2ForPinIndex(i); if(prevRel != rel) { PIN_SetPinChannel2ForPinIndex(i,rel); iChanged++; } } } if(iChangedRequested>0) { PIN_SaveToFlash(); hprintf128(request, "Pins update - %i reqs, %i changed!

",iChangedRequested,iChanged); } // strcat(outbuf,""); poststr(request,"
"); for( i = 0; i < GPIO_MAX; i++) { int si, ch, ch2; int j; si = PIN_GetPinRoleForPinIndex(i); ch = PIN_GetPinChannelForPinIndex(i); ch2 = PIN_GetPinChannel2ForPinIndex(i); #if PLATFORM_XR809 poststr(request,PIN_GetPinNameAlias(i)); poststr(request," "); #else hprintf128(request, "P%i ",i); #endif hprintf128(request, ""); hprintf128(request, "",i,ch); if(si == IOR_Button || si == IOR_Button_n) { // extra param. For button, is relay index to toggle on double click hprintf128(request, "",i,ch2); } poststr(request,"
"); } poststr(request,"
"); poststr(request,htmlReturnToCfg); HTTP_AddBuildFooter(request); poststr(request,htmlEnd); poststr(request, NULL); return 0; } int http_fn_ota_exec(http_request_t *request) { char tmpA[128]; //char tmpB[64]; http_setup(request, httpMimeTypeHTML); poststr(request,htmlHeader); if(http_getArg(request->url,"host",tmpA,sizeof(tmpA))) { hprintf128(request,"

OTA requested for %s!

",tmpA); #if WINDOWS #elif PLATFORM_XR809 //cmd_ota_http_exec(tmpA); xr809_do_ota_next_frame(tmpA); #else otarequest(tmpA); #endif } poststr(request,htmlReturnToMenu); HTTP_AddBuildFooter(request); poststr(request,htmlEnd); poststr(request, NULL); return 0; } int http_fn_ota(http_request_t *request) { http_setup(request, httpMimeTypeHTML); poststr(request,htmlHeader); poststr(request,"
\
\
\ \
"); poststr(request,htmlReturnToMenu); HTTP_AddBuildFooter(request); poststr(request,htmlEnd); poststr(request, NULL); return 0; } int http_fn_other(http_request_t *request) { http_setup(request, httpMimeTypeHTML); poststr(request,htmlHeader); poststr(request,g_header); poststr(request,"Not found.
"); poststr(request,htmlReturnToMenu); HTTP_AddBuildFooter(request); poststr(request,htmlEnd); poststr(request, NULL); return 0; }