Skip to content

Commit

Permalink
Merge branch 'main' into multiple-BLE-devices
Browse files Browse the repository at this point in the history
  • Loading branch information
KlausMu committed Dec 7, 2024
2 parents 2b61db4 + 47018a6 commit 83dcbb8
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Platformio/hardware/hardwareLayer.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#if defined(WIN32) || defined(__linux__)
#if defined(WIN32) || defined(__linux__) || defined(__APPLE__)
#include "windows_linux/include_hal_windows_linux.h"
#elif defined(ARDUINO)
#include "ESP32/include_hal_esp32.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#if defined(__APPLE__)
#include <stdlib.h>
#else
#include <malloc.h>
#endif

#if defined(WIN32)
// https://www.daniweb.com/programming/software-development/threads/135188/calculate-the-amount-of-heap-memory
Expand All @@ -20,7 +24,7 @@ long HeapUsed()
return used;
}

#elif defined(__linux__)
#elif defined(__linux__) || defined(__APPLE__)
long HeapUsed() {
// don't know how to get used heap size in linux
return 800000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#include <sys/socket.h>
#include <netdb.h>
#include <sys/ioctl.h>
#if !defined(__APPLE__)
#include <linux/if.h>
#endif
#else
#include <ws2tcpip.h>
#endif
Expand Down Expand Up @@ -50,7 +52,7 @@ int open_nb_socket(const char* addr, const char* port, char *MACaddress) {
continue;
}

#if !defined(WIN32)
#if !defined(WIN32) && !defined(__APPLE__)
// get MAC address
struct ifreq s;
ioctl(sockfd, SIOCGIFHWADDR, &s);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void reconnect_mqtt(struct mqtt_client *mqttClient, void**) {
}
}

#if !defined(WIN32)
#if !defined(WIN32) && !defined(__APPLE__)
std::string getMACaddress() {
struct ifreq s;
int fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
Expand Down
8 changes: 8 additions & 0 deletions Platformio/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,11 @@ build_flags =
-m32
;linker option
-Wl,-mi386pe

[env:macOS]
extends = env:linux_64bit
build_flags =
${env:linux_64bit.build_flags}
-I/opt/homebrew/include
-L/opt/homebrew/lib
-std=c++11
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if defined(WIN32) || defined(__linux__)
#if defined(WIN32) || defined(__linux__) || defined(__APPLE__)

#include "applicationInternal/hardware/arduinoLayer.h"
#include <stdarg.h>
Expand Down
2 changes: 1 addition & 1 deletion Platformio/src/applicationInternal/hardware/arduinoLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// for env:esp32 we need "Arduino.h" e.g. for Serial, delay(), millis()
#include <Arduino.h>

#elif defined(WIN32) || defined(__linux__)
#elif defined(WIN32) || defined(__linux__) || defined(__APPLE__)
#include <stdint.h>
// For Windows and Linux there is no Arduino framework available. So we have to simulate at least those very few calls to Arduino functions which are left in the code.
// Note: Of course there is a lot more Arduino code in folder "hardware/ESP32/*", but this code is only active in case of esp32, so we don't have to simulate this in the Arduino layer if Windows/Linux is active.
Expand Down
6 changes: 3 additions & 3 deletions Platformio/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
// in case of Arduino we have a setup() and a loop()
void setup() {

#elif defined(WIN32) || defined(__linux__)
#elif defined(WIN32) || defined(__linux__) || defined(__APPLE__)
// in case of Windows/Linux, we have only a main() function, no setup() and loop(), so we have to simulate them
// forward declaration of loop()
void loop(unsigned long *pIMUTaskTimer, unsigned long *pUpdateStatusTimer);
Expand Down Expand Up @@ -155,7 +155,7 @@ int main(int argc, char *argv[]) {

omote_log_i("Setup finished in %lu ms.\r\n", millis());

#if defined(WIN32) || defined(__linux__)
#if defined(WIN32) || defined(__linux__) || defined(__APPLE__)
// In Windows/Linux there is no loop function that is automatically being called. So we have to do this on our own infinitely here in main()
unsigned long IMUTaskTimer = 0;
unsigned long updateStatusTimer = 0;
Expand All @@ -172,7 +172,7 @@ unsigned long updateStatusTimer = 0;
unsigned long *pIMUTaskTimer = &IMUTaskTimer;
unsigned long *pUpdateStatusTimer = &updateStatusTimer;
void loop() {
#elif defined(WIN32) || defined(__linux__)
#elif defined(WIN32) || defined(__linux__) || defined(__APPLE__)
void loop(unsigned long *pIMUTaskTimer, unsigned long *pUpdateStatusTimer) {
#endif

Expand Down

0 comments on commit 83dcbb8

Please sign in to comment.