diff --git a/src/httpserver/new_http.c b/src/httpserver/new_http.c index fa289059c..e776d1c39 100644 --- a/src/httpserver/new_http.c +++ b/src/httpserver/new_http.c @@ -305,7 +305,10 @@ template_t g_templates [] = { { 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_ArlecCCTDownlight, "Arlec CCT LED Downlight ALD029CHA"}, + { Setup_Device_NedisWIFIPO120FWT_16A, "Nedis WIFIPO120FWT 16A"}, + { Setup_Device_NedisWIFIP130FWT_10A, "Nedis WIFIP130FWT 10A"} + }; int g_total_templates = sizeof(g_templates)/sizeof(g_templates[0]); @@ -417,16 +420,16 @@ int hprintf128(http_request_t *request, const char *fmt, ...){ return postany(request, tmp, strlen(tmp)); } -uint8_t hexdigit( char hex ) -{ - return (hex <= '9') ? hex - '0' : - toupper(hex) - 'A' + 10 ; -} - -uint8_t hexbyte( const char* hex ) -{ - return (hexdigit(*hex) << 4) | hexdigit(*(hex+1)) ; -} +uint8_t hexdigit( char hex ) +{ + return (hex <= '9') ? hex - '0' : + toupper(hex) - 'A' + 10 ; +} + +uint8_t hexbyte( const char* hex ) +{ + return (hexdigit(*hex) << 4) | hexdigit(*(hex+1)) ; +} int HTTP_ProcessPacket(http_request_t *request) { int i, j; @@ -772,10 +775,10 @@ int HTTP_ProcessPacket(http_request_t *request) { poststr(request,htmlHeader); poststr(request,g_header); - if(http_getArg(recvbuf,"mac",tmpA,sizeof(tmpA))) { - for( i = 0; i < 6; i++ ) - { - mac[i] = hexbyte( &tmpA[i * 2] ) ; + if(http_getArg(recvbuf,"mac",tmpA,sizeof(tmpA))) { + for( i = 0; i < 6; i++ ) + { + mac[i] = hexbyte( &tmpA[i * 2] ) ; } WiFI_SetMacAddress((char*)mac); //sscanf(tmpA,"%02X%02X%02X%02X%02X%02X",&mac[0],&mac[1],&mac[2],&mac[3],&mac[4],&mac[5]); @@ -832,7 +835,7 @@ int HTTP_ProcessPacket(http_request_t *request) { now = rem; } #if PLATFORM_XR809 - //uint32_t flash_read(uint32_t flash, uint32_t addr,void *buf, uint32_t size) + //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 diff --git a/src/new_builtin_devices.c b/src/new_builtin_devices.c index e948c76f0..482cb52d9 100644 --- a/src/new_builtin_devices.c +++ b/src/new_builtin_devices.c @@ -168,3 +168,56 @@ void Setup_Device_ArlecCCTDownlight() { PIN_SaveToFlash(); } + +// https://www.elektroda.pl/rtvforum/topic3804553.html +// SmartSwitch Nedis WIFIPO120FWT +void Setup_Device_NedisWIFIPO120FWT_16A() { + + // WB2S + // Pins are: + // Led - PWM0 + // BL0937 CF - PWM1 + // BL0937 CF1 - PWM2 + // Button = TX1 + // BL0937 SEL - PWM4 + // Relay = PWM5 + + + PIN_ClearPins(); + // Button stat + PIN_SetPinRoleForPinIndex(6, IOR_LED); + PIN_SetPinChannelForPinIndex(6, 1); + // Button + PIN_SetPinRoleForPinIndex(10, IOR_Button); + PIN_SetPinChannelForPinIndex(10, 1); + // Relay + PIN_SetPinRoleForPinIndex(26, IOR_Relay_n); + PIN_SetPinChannelForPinIndex(26, 1); + + PIN_SaveToFlash(); +} + +// https://www.elektroda.pl/rtvforum/topic3804553.html +// SmartSwitch Nedis WIFIP130FWT +void Setup_Device_NedisWIFIP130FWT_10A() { + + // WB2S + // Pins are: + // Led - PWM0 + // Button = TX1 + // Relay = PWM5 + + + PIN_ClearPins(); + // Button stat + PIN_SetPinRoleForPinIndex(6, IOR_LED); + PIN_SetPinChannelForPinIndex(6, 1); + // Button + PIN_SetPinRoleForPinIndex(10, IOR_Button); + PIN_SetPinChannelForPinIndex(10, 1); + // Relay + PIN_SetPinRoleForPinIndex(26, IOR_Relay); + PIN_SetPinChannelForPinIndex(26, 1); + + PIN_SaveToFlash(); +} \ No newline at end of file