Skip to content

Commit 680f149

Browse files
authored
Merge branch 'openshwprojects:main' into tuyamcu
2 parents 787d448 + 33e5f1b commit 680f149

File tree

6 files changed

+43
-10
lines changed

6 files changed

+43
-10
lines changed

src/hal/win32/hal_wifi_win32.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,21 @@ int WiFI_SetMacAddress(char *mac) {
6161

6262
}
6363
void WiFI_GetMacAddress(char *mac) {
64+
#ifndef LINUX
6465
mac[0] = 0xBA;
6566
mac[1] = 0xDA;
6667
mac[2] = 0x31;
6768
mac[3] = 0x45;
6869
mac[4] = 0xCA;
6970
mac[5] = 0xFF;
71+
#else
72+
mac[0] = 0xCA;
73+
mac[1] = 0xFF;
74+
mac[2] = 0xEE;
75+
mac[3] = 0xCA;
76+
mac[4] = 0xFF;
77+
mac[5] = 0xEE;
78+
#endif
7079
}
7180

7281
void HAL_PrintNetworkInfo() {

src/httpserver/rest_interface.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,14 @@ static int http_rest_post(http_request_t* request) {
278278

279279
static int http_rest_app(http_request_t* request) {
280280
const char* webhost = CFG_GetWebappRoot();
281-
const char* ourip = HAL_GetMyIPString(); //CFG_GetOurIP();
281+
// const char* ourip = HAL_GetMyIPString(); //CFG_GetOurIP();
282282
http_setup(request, httpMimeTypeHTML);
283-
if (webhost && ourip) {
283+
// if (webhost && ourip) {
284+
// we don't need to rely on any function here for our IP.
285+
// If this code is used, someone is accessing the webif, so we
286+
// know our ip (and port) inside the browser (JS "location").
287+
// Knowing/using the port from location.host is very usefull e.g. in simulator ;-)
288+
if (webhost) {
284289
poststr(request, htmlDoctype);
285290

286291
poststr(request, "<head><title>");
@@ -289,7 +294,7 @@ static int http_rest_app(http_request_t* request) {
289294

290295
poststr(request, htmlShortcutIcon);
291296
poststr(request, htmlHeadMeta);
292-
hprintf255(request, "<script>var root='%s',device='http://%s';</script>", webhost, ourip);
297+
hprintf255(request, "<script>var root='%s',device='http://'+location.host;</script>", webhost);
293298
hprintf255(request, "<script src='%s/startup.js'></script>", webhost);
294299
poststr(request, "</head><body></body></html>");
295300
}

src/new_common.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,17 @@ extern unsigned char hexbyte(const char* hex);
4242
void OTA_RequestDownloadFromHTTP(const char *s);
4343

4444
#if WINDOWS
45+
#ifndef LINUX
4546
#define DEVICENAME_PREFIX_FULL "WinTest"
4647
#define DEVICENAME_PREFIX_SHORT "WT"
4748
#define PLATFORM_MCU_NAME "WIN32"
4849
#define MANUFACTURER "Microsoft"
50+
#else
51+
#define DEVICENAME_PREFIX_FULL "LinuxSim"
52+
#define DEVICENAME_PREFIX_SHORT "LS"
53+
#define PLATFORM_MCU_NAME "LIN"
54+
#define MANUFACTURER "Linux"
55+
#endif
4956
#elif PLATFORM_XR806
5057
#define DEVICENAME_PREFIX_FULL "OpenXR806"
5158
#define DEVICENAME_PREFIX_SHORT "oxr"
@@ -207,7 +214,11 @@ This platform is not supported, error!
207214
// but it may not be set while doing a test build on developer PC
208215
#ifndef USER_SW_VER
209216
#ifdef WINDOWS
217+
#ifndef LINUX
210218
#define USER_SW_VER "Win_Test"
219+
#else
220+
#define USER_SW_VER "Lin_Test"
221+
#endif
211222
#elif PLATFORM_XR809
212223
#define USER_SW_VER "XR809_Test"
213224
#elif PLATFORM_XR872

src/win32/stubs/win_rtos_stub.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
#define DWORD uint
1717

1818
#define SOCKET_ERROR SO_ERROR
19-
#define Sleep sleep
19+
// sleep ms, not seconds!
20+
//#define Sleep sleep
21+
#define Sleep(x) usleep((x*1000))
2022
#define ioctlsocket ioctl
2123
#define closesocket close
2224
#define GETSOCKETERRNO() (errno)

src/win_main.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
#include <arpa/inet.h>
2525
#include <unistd.h>
2626

27-
#define Sleep sleep
27+
// sleep ms, not seconds!
28+
//#define Sleep sleep
29+
#define Sleep(x) usleep((x*1000))
2830

2931
#endif
3032

@@ -621,6 +623,10 @@ int __cdecl main(int argc, char **argv)
621623

622624
#ifndef LINUX
623625
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF);
626+
#else
627+
// I still didn't figure out, where Init_Main is called in Windows binyry if g_selfTestsMode is 0
628+
// but we need it, so commands are registered and HTTPServer_Start() is called ...
629+
SIM_StartOBK(0);
624630
#endif
625631

626632
if (g_selfTestsMode)
@@ -644,15 +650,15 @@ int __cdecl main(int argc, char **argv)
644650
#endif
645651

646652
CMD_ExecuteCommand("startDriver MQTTServer", 0);
647-
#if 1
653+
#ifndef LINUX
648654
CMD_ExecuteCommand("MQTTHost 192.168.0.113", 0);
649655
CMD_ExecuteCommand("MqttPassword ma1oovoo0pooTie7koa8Eiwae9vohth1vool8ekaej8Voohi7beif5uMuph9Diex", 0);
650656
CMD_ExecuteCommand("MqttClient WindowsOBK", 0);
651657
CMD_ExecuteCommand("MqttUser homeassistant", 0);
652658
#else
653-
CMD_ExecuteCommand("MQTTHost 192.168.0.118", 0);
654-
CMD_ExecuteCommand("MqttPassword Test1", 0);
655-
CMD_ExecuteCommand("MqttClient WindowsOBK", 0);
659+
CMD_ExecuteCommand("MQTTHost 192.168.0.113", 0);
660+
CMD_ExecuteCommand("MqttPassword ma1oovoo0pooTie7koa8Eiwae9vohth1vool8ekaej8Voohi7beif5uMuph9Diex", 0);
661+
CMD_ExecuteCommand("MqttClient LinuxOBK", 0);
656662
CMD_ExecuteCommand("MqttUser homeassistant", 0);
657663
#endif
658664
CMD_ExecuteCommand("reboot", 0);

0 commit comments

Comments
 (0)