diff --git a/src/httpserver/new_http.c b/src/httpserver/new_http.c
index 4dbb7a18a..fa289059c 100644
--- a/src/httpserver/new_http.c
+++ b/src/httpserver/new_http.c
@@ -417,6 +417,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)) ;
+}
int HTTP_ProcessPacket(http_request_t *request) {
int i, j;
@@ -754,6 +764,39 @@ int HTTP_ProcessPacket(http_request_t *request) {
poststr(request,htmlReturnToCfg);
HTTP_AddBuildFooter(request);
poststr(request,htmlEnd);
+ } else if(http_checkUrlBase(urlStr,"cfg_mac")) {
+ // must be unsigned, else print below prints negatives as e.g. FFFFFFFe
+ unsigned char mac[6];
+
+ http_setup(request, httpMimeTypeHTML);
+ 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] ) ;
+ }
+ WiFI_SetMacAddress((char*)mac);
+ //sscanf(tmpA,"%02X%02X%02X%02X%02X%02X",&mac[0],&mac[1],&mac[2],&mac[3],&mac[4],&mac[5]);
+ poststr(request,"
New MAC set!
");
+ }
+
+ WiFI_GetMacAddress((char *)mac);
+
+ sprintf(tmpA,"%02X%02X%02X%02X%02X%02X",mac[0],mac[1],mac[2],mac[3],mac[4],mac[5]);
+
+ poststr(request," Here you can change MAC address.
");
+ poststr(request," ");
+ poststr(request,htmlReturnToCfg);
+ HTTP_AddBuildFooter(request);
+ poststr(request,htmlEnd);
} else if(http_checkUrlBase(urlStr,"flash_read_tool")) {
int len = 16;
int ofs = 1970176;
@@ -945,6 +988,7 @@ int HTTP_ProcessPacket(http_request_t *request) {
poststr(request,"");
poststr(request,"");
poststr(request,"");
+ poststr(request,"");
poststr(request,"");
poststr(request,"");
poststr(request,"");
diff --git a/src/new_cfg.c b/src/new_cfg.c
index 1794b9b1d..7b7d0b8b7 100644
--- a/src/new_cfg.c
+++ b/src/new_cfg.c
@@ -99,7 +99,6 @@ void WiFI_GetMacAddress(char *mac) {
#elif PLATFORM_XR809
sysinfo_t *inf;
- int res;
inf = sysinfo_get();
if(inf == 0) {
mac[0] = 'E'; mac[1] = 'R'; mac[2] = 'R'; mac[3] = 'O'; mac[4] = 'R'; mac[5] = '!';
@@ -111,7 +110,26 @@ void WiFI_GetMacAddress(char *mac) {
wifi_get_mac_address((char *)mac, CONFIG_ROLE_STA);
#endif
}
+void WiFI_SetMacAddress(char *mac) {
+#if WINDOWS
+#elif PLATFORM_XR809
+ sysinfo_t *inf;
+ int res;
+ inf = sysinfo_get();
+ if(inf == 0) {
+ printf("WiFI_SetMacAddress: sysinfo_get returned 0!\n\r");
+ return;
+ }
+ memcpy(inf->mac_addr,mac,6);
+ res = sysinfo_save_wrapper();
+ if(res != 0) {
+ printf("WiFI_SetMacAddress: sysinfo_save error - %i!\n\r",res);
+ }
+#else
+ wifi_set_mac_address((char *)mac);
+#endif
+}
void CFG_CreateDeviceNameUnique()
{
// must be unsigned, else print below prints negatives as e.g. FFFFFFFe
@@ -260,7 +278,10 @@ int sysinfo_save_wrapper() {
printf("sysinfo_save_wrapper: going to calc checksum!\n\r");
inf->checksum = sysinfo_checksum(inf);
printf("sysinfo_save_wrapper: going to call save!\n\r");
- sysinfo_save();
+ res = sysinfo_save();
+ if(res != 0) {
+ printf("sysinfo_save_wrapper: sysinfo_save returned error!\n\r");
+ }
printf("sysinfo_save_wrapper: done!\n\r");
return 0;
}
diff --git a/src/new_cfg.h b/src/new_cfg.h
index 9990ea05e..30dedb253 100644
--- a/src/new_cfg.h
+++ b/src/new_cfg.h
@@ -27,4 +27,5 @@ const char *CFG_LoadWebappRoot();
void CFG_SetWebappRoot(const char *s);
void CFG_InitAndLoad();
void WiFI_GetMacAddress(char *mac);
+void WiFI_SetMacAddress(char *mac);