Improve multiplatform building stuff

This commit is contained in:
2019-03-03 15:42:54 +03:00
parent 3e3b5f9f5f
commit c74575e0e9
15 changed files with 211 additions and 128 deletions

View File

@@ -1,6 +1,7 @@
#! /bin/bash
export FLAGS="$FLAGS -DCONTROLLINO"
export FLAGS="$FLAGS -DCUSTOM_FIRMWARE_MAC=de:ad:be:ef:fe:07"
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_controllino.sh
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
source $CUSTOM_BUILD_FLAGS_FILE

View File

@@ -1,6 +1,7 @@
#! /bin/bash
export FLAGS="$FLAGS -DWiz5500"
export FLAGS="$FLAGS -DARTNET_ENABLE"
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_due-5500.sh
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
source $CUSTOM_BUILD_FLAGS_FILE

View File

@@ -1,4 +1,5 @@
#! /bin/bash
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_due.sh
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
source $CUSTOM_BUILD_FLAGS_FILE

View File

@@ -1,4 +1,9 @@
#! /bin/bash
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
export FLAGS="$FLAGS -DDMX_DISABLE"
export FLAGS="$FLAGS -DMODBUS_DISABLE"
export FLAGS="$FLAGS -DOWIRE_DISABLE"
#export FLAGS="$FLAGS -std=gnu++11"
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_esp32.sh
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
source $CUSTOM_BUILD_FLAGS_FILE

View File

@@ -1,5 +1,6 @@
#! /bin/bash
export FLAGS="$FLAGS -DMODBUS_DISABLE"
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_esp8266.sh
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
source $CUSTOM_BUILD_FLAGS_FILE

View File

@@ -1,5 +1,6 @@
#! /bin/bash
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_mega2560-net.sh
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
source $CUSTOM_BUILD_FLAGS_FILE
fi

View File

@@ -1,7 +1,6 @@
#! /bin/bash
CUSTOM_BUILD_FLAGS_FILE="custom-build-flags/build_flags_mega2560.sh"
#CUSTOM_BUILD_FLAGS_FILE="custom-build-flags/build_flags_$PIOENV.sh"
#echo $PIOENV > custom-build-flags/1.txt
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
#TODO: make one file for all envs
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
source $CUSTOM_BUILD_FLAGS_FILE

View File

@@ -1,5 +1,13 @@
#! /bin/bash
export FLAGS="$FLAGS -DWiz5500"
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
export FLAGS="$FLAGS -DDMX_DISABLE"
export FLAGS="$FLAGS -DMODBUS_DISABLE"
export FLAGS="$FLAGS -DOWIRE_DISABLE"
export FLAGS="$FLAGS -std=gnu++11"
export FLAGS="$FLAGS -DWIFI_MANAGER_DISABLE"
export FLAGS="$FLAGS -DDHT_COUNTER_DISABLE"
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_nrf52840.sh
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
source $CUSTOM_BUILD_FLAGS_FILE

View File

@@ -1,5 +1,9 @@
#! /bin/bash
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_stm32.sh
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
export FLAGS="$FLAGS -DDMX_DISABLE"
export FLAGS="$FLAGS -DMODBUS_DISABLE"
export FLAGS="$FLAGS -DOWIRE_DISABLE"
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
source $CUSTOM_BUILD_FLAGS_FILE
fi

View File

@@ -64,11 +64,9 @@ ESP32
PWM Out
*/
#include "Arduino.h"
#include "main.h"
#include "options.h"
#include "utils.h"
#include "homiedef.h"
#if defined(__SAM3X8E__)
DueFlashStorage EEPROM;
@@ -80,18 +78,12 @@ EthernetClient ethClient;
#endif
#ifdef ARDUINO_ARCH_ESP8266
#include <ESP8266WiFi.h>
#include <user_interface.h>
WiFiClient ethClient;
#endif
#ifdef ARDUINO_ARCH_ESP32
#include <WiFiClient.h>
#include <WiFi.h>
#include <HTTPClient.h>
#include <EEPROM.h>
#include "Ethernet3.h"
WiFiClient ethClient;
NRFFlashStorage EEPROM;
#endif
#ifdef ARDUINO_ARCH_STM32F1
@@ -99,7 +91,7 @@ WiFiClient ethClient;
//#include <EthernetClient.h>
//#include "UIPEthernet.h"
//#include "UIPUdp.h"
#include <SPI.h>
//#include <SPI.h>
#include <Ethernet_STM.h>
#include "Dns.h"
@@ -110,7 +102,6 @@ EthernetClient ethClient;
#endif
#ifdef NRF5
#include <NRFFlashStorage.h>
NRFFlashStorage EEPROM;
EthernetClient ethClient;
#endif
@@ -171,7 +162,9 @@ bool wifiInitialized;
int mqttErrorRate;
#if defined(__SAM3X8E__)
void watchdogSetup(void) {} //Do not remove - strong re-definition WDT Init for DUE
#endif
void mqttCallback(char *topic, byte *payload, unsigned int length) {
debugSerial<<F("\n[")<<topic<<F("] ");
@@ -548,7 +541,7 @@ void onInitialStateInitLAN() {
#ifdef ARDUINO_ARCH_ESP32
if(!wifiInitialized) {
WiFi.mode(WIFI_STA);
// WiFi.mode(WIFI_STA);
WiFi.disconnect();
debugSerial<<F("WIFI AP/Password:")<<QUOTE(ESP_WIFI_AP)<<F("/")<<QUOTE(ESP_WIFI_PWD);
WiFi.begin(QUOTE(ESP_WIFI_AP), QUOTE(ESP_WIFI_PWD));
@@ -740,7 +733,7 @@ void cmdFunctionHelp(int arg_cnt, char **args)
void printCurentLanConfig() {
debugSerial << F("Current LAN config(ip,dns,gw,subnet):");
printIPAddress(Ethernet.localIP());
printIPAddress(Ethernet.dnsServerIP());
// printIPAddress(Ethernet.dnsServerIP());
printIPAddress(Ethernet.gatewayIP());
printIPAddress(Ethernet.subnetMask());
}
@@ -935,22 +928,32 @@ void cmdFunctionIp(int arg_cnt, char **args)
{
IPAddress ip0(0, 0, 0, 0);
IPAddress ip;
#if defined(ARDUINO_ARCH_AVR) || defined(__SAM3X8E__) || defined(NRF5)
DNSClient dns;
#define inet_aton(cp, addr) dns.inet_aton(cp, addr)
#else
#define inet_aton(cp, addr) inet_aton(cp, addr)
#endif
switch (arg_cnt) {
case 5:
if (dns.inet_aton(args[4], ip)) saveFlash(OFFSET_MASK, ip);
if (inet_aton(args[4], ip)) saveFlash(OFFSET_MASK, ip);
else saveFlash(OFFSET_MASK, ip0);
case 4:
if (dns.inet_aton(args[3], ip)) saveFlash(OFFSET_GW, ip);
if (inet_aton(args[3], ip)) saveFlash(OFFSET_GW, ip);
else saveFlash(OFFSET_GW, ip0);
case 3:
if (dns.inet_aton(args[2], ip)) saveFlash(OFFSET_DNS, ip);
if (inet_aton(args[2], ip)) saveFlash(OFFSET_DNS, ip);
else saveFlash(OFFSET_DNS, ip0);
case 2:
if (dns.inet_aton(args[1], ip)) saveFlash(OFFSET_IP, ip);
if (inet_aton(args[1], ip)) saveFlash(OFFSET_IP, ip);
else saveFlash(OFFSET_IP, ip0);
break;
case 1:
case 1: //dynamic IP
saveFlash(OFFSET_IP,ip0);
/*
IPAddress current_ip = Ethernet.localIP();
IPAddress current_mask = Ethernet.subnetMask();
IPAddress current_gw = Ethernet.gatewayIP();
@@ -963,7 +966,7 @@ void cmdFunctionIp(int arg_cnt, char **args)
printIPAddress(current_ip);
printIPAddress(current_dns);
printIPAddress(current_gw);
printIPAddress(current_mask);
printIPAddress(current_mask); */
}
debugSerial<<F("Saved\n");
}
@@ -1104,9 +1107,13 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
return READ_RE_CONFIG;//-11;
}
#endif
#if defined(__SAM3X8E__) || defined(ARDUINO_ARCH_STM32F1)
String response;
#if defined(__SAM3X8E__) || defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_ESP32)
#if defined(ARDUINO_ARCH_ESP32)
WiFiClient configEthClient;
#else
EthernetClient configEthClient;
#endif
String response;
HttpClient htclient = HttpClient(configEthClient, configServer, 80);
//htclient.stop(); //_socket =MAX
htclient.setHttpResponseTimeout(4000);
@@ -1142,7 +1149,7 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
return READ_RE_CONFIG;//-11; //Load from NVRAM
}
#endif
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
#if defined(ARDUINO_ARCH_ESP8266)
HTTPClient httpClient;
String fullURI = "http://";
fullURI+=configServer;
@@ -1194,6 +1201,8 @@ void postTransmission() {
}
void setup_main() {
//Serial.println("Hello");
//delay(1000);
setupCmdArduino();
printFirmwareVersionAndBuildOptions();

View File

@@ -1,5 +1,48 @@
#pragma once
#include "options.h"
#if defined(__SAM3X8E__)
#include <DueFlashStorage.h>
#include <watchdog.h>
#include <ArduinoHttpClient.h>
#endif
#if defined(ARDUINO_ARCH_AVR)
#include "HTTPClientAVR.h"
#include <avr/pgmspace.h>
#include <avr/wdt.h>
#include <EEPROM.h>
#endif
#if defined(ARDUINO_ARCH_ESP8266)
#include <FS.h> //this needs to be first, or it all crashes and burns...
#include <EEPROM.h>
#include <ESP8266HTTPClient.h>
#include <WiFiManager.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <ESP8266WiFi.h>
#include <user_interface.h>
#endif
#if defined ARDUINO_ARCH_ESP32
//#include <FS.h> //this needs to be first, or it all crashes and burns...
//#include <EEPROM.h>
#include <NRFFlashStorage.h>
#include <HttpClient.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiClientSecure.h>
#include <WebServer.h>
#include <WiFiManager.h>
#include <DNSServer.h>
#define Ethernet WiFi
#endif
#ifdef NRF5
#include <NRFFlashStorage.h>
#endif
#if defined(__SAM3X8E__)
#define wdt_res() watchdogReset()
@@ -56,18 +99,6 @@
#include "DallasTemperature.h"
#endif
#include "Arduino.h"
#include <PubSubClient.h>
#include <SPI.h>
#include "utils.h"
#include <string.h>
#include "aJSON.h"
#include <Cmd.h>
#include "stdarg.h"
#include "item.h"
#include "inputs.h"
#ifndef MODBUS_DISABLE
#include <ModbusMaster.h>
#endif
@@ -76,57 +107,23 @@
#include "FastLED.h"
#endif
#include "Dns.h"
//#include "hsv2rgb.h"
#if defined(__SAM3X8E__)
#include <DueFlashStorage.h>
#include <watchdog.h>
#include <ArduinoHttpClient.h>
#endif
#if defined(ARDUINO_ARCH_AVR)
#include "HTTPClientAVR.h"
#include <avr/pgmspace.h>
#include <avr/wdt.h>
#include <EEPROM.h>
#endif
#if defined(ESP8266)
#include <FS.h> //this needs to be first, or it all crashes and burns...
#include <EEPROM.h>
#include <ESP8266HTTPClient.h>
#include <WiFiManager.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#endif
#ifdef _owire
#include "owTerm.h"
#endif
#if defined(_dmxin) || defined(_dmxout) || defined (_artnet)
#include "dmx.h"
#endif
#if defined(ARDUINO_ARCH_AVR) || defined(__SAM3X8E__) || defined(ESP8266) || defined(NRF5)
#ifdef Wiz5500
#include <Ethernet2.h>
#else
#if defined(ARDUINO_ARCH_AVR) || defined(__SAM3X8E__) || defined(NRF5)
#include <Ethernet.h>
#endif
#endif
#ifdef ARDUINO_ARCH_ESP32
#include <SPI.h>
//#include <Ethernet3.h>
#endif
#ifdef _artnet
#include <Artnet.h>
@@ -136,6 +133,18 @@
#include "sd_card_w5100.h"
#endif
#include "Arduino.h"
#include "utils.h"
#include "homiedef.h"
#include <PubSubClient.h>
#include <SPI.h>
#include <string.h>
#include "aJSON.h"
#include <Cmd.h>
#include "stdarg.h"
#include "item.h"
#include "inputs.h"
#ifdef _artnet
extern Artnet *artnet;
#endif

View File

@@ -129,6 +129,10 @@
#endif
#if defined(ARDUINO_ARCH_ESP32)
#undef _dmxin
#undef _modbus
#undef _dmxout
#undef modbusSerial
#endif
#ifndef _dmxout

View File

@@ -265,5 +265,67 @@ void ReadUniqueID( unsigned int * pdwUniqueID )
}
int inet_aton(const char* aIPAddrString, IPAddress& aResult)
{
// See if we've been given a valid IP address
const char* p =aIPAddrString;
while (*p &&
( (*p == '.') || (*p >= '0') || (*p <= '9') ))
{
p++;
}
if (*p == '\0')
{
// It's looking promising, we haven't found any invalid characters
p = aIPAddrString;
int segment =0;
int segmentValue =0;
while (*p && (segment < 4))
{
if (*p == '.')
{
// We've reached the end of a segment
if (segmentValue > 255)
{
// You can't have IP address segments that don't fit in a byte
return 0;
}
else
{
aResult[segment] = (byte)segmentValue;
segment++;
segmentValue = 0;
}
}
else
{
// Next digit
segmentValue = (segmentValue*10)+(*p - '0');
}
p++;
}
// We've reached the end of address, but there'll still be the last
// segment to deal with
if ((segmentValue > 255) || (segment > 3))
{
// You can't have IP address segments that don't fit in a byte,
// or more than four segments
return 0;
}
else
{
aResult[segment] = (byte)segmentValue;
return 1;
}
}
else
{
return 0;
}
}
#pragma message(VAR_NAME_VALUE(debugSerial))
#pragma message(VAR_NAME_VALUE(SERIAL_BAUD))

View File

@@ -42,3 +42,4 @@ void parseBytes(const char* str, char separator, byte* bytes, int maxBytes, int
int log(const char *str, ...);
void printFloatValueToStr(float value, char *valstr);
void ReadUniqueID( unsigned int * pdwUniqueID );
int inet_aton(const char* aIPAddrString, IPAddress& aResult);

View File

@@ -9,7 +9,7 @@
; http://docs.platformio.org/page/projectconf.html
[platformio]
src_dir = lighthub
env_default = due-5500
env_default = esp32
;monitor_speed = 115200
; megaatmega2560
; megaatmega2560-net
@@ -21,11 +21,12 @@ env_default = due-5500
; controllino
; stm32
; esp32-evb
; nrf52840_dk
;build_dir = /tmp/pioenvs
;libdeps_dir = /tmp/piolibdeps
[env:nrf52840_dk]
platform = nordinrf52
platform = nordicnrf52
board = nrf52840_dk
;upload_protocol = mbed
;upload_port = /dev/cu.SLAB_USBtoUART
@@ -46,6 +47,9 @@ lib_ignore =
ESPDMX
DueFlashStorage
PrintEx
DHT sensor library
DHT sensor library for ESPx
Adafruit Unified Sensor
; Adafruit_Sensor
lib_deps =
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
@@ -58,55 +62,19 @@ lib_deps =
https://github.com/knolleary/pubsubclient.git
; https://github.com/anklimov/Artnet.git
; FastLED
Adafruit Unified Sensor
; Adafruit Unified Sensor
; DHT sensor library for ESPx
DHT sensor library
; DHT sensor library
Streaming
https://github.com/anklimov/NRFFlashStorage
; https://github.com/livello/PrintEx#is-select-redecl
[env:esp32-evb]
platform = espressif32
framework = arduino
board = esp32-evb
upload_protocol = esptool
upload_speed = 115200
build_flags = !bash check_custom_build_flags_esp32.sh
lib_ignore =
DmxSimple
DMXSerial
DmxDue
DueFlashStorage
SD
SdFat
WifiManager
Ethernet
Ethernet2
httpClient
NRFFlashStorage
lib_deps =
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
https://github.com/anklimov/DS2482_OneWire
Ethernet3
ESP8266HTTPClient
https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino
https://github.com/anklimov/ModbusMaster
https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/Artnet.git
FastLED
Adafruit Unified Sensor
DHT sensor library for ESPx
DHT sensor library
Streaming
; https://github.com/livello/PrintEx#is-select-redecl
[env:esp32]
platform = espressif32
framework = arduino
board = pico32
;board = pico32
board = esp32-evb
upload_speed = 115200
build_flags = !bash check_custom_build_flags_esp32.sh
lib_ignore =
@@ -116,29 +84,38 @@ lib_ignore =
DueFlashStorage
SD
SdFat
WifiManager
Ethernet
Ethernet2
Ethernet3
HTTPClient
httpClient
NRFFlashStorage
lib_deps =
EEPROM
https://github.com/anklimov/ModbusMaster
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
https://github.com/anklimov/DS2482_OneWire
Ethernet3
ESP8266HTTPClient
https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino
https://github.com/anklimov/ModbusMaster
https://github.com/knolleary/pubsubclient.git
DS2482_OneWire
OneWire
DallasTemperature
ModbusMaster
Artnet
https://github.com/anklimov/Artnet.git
FastLED
Adafruit Unified Sensor
DHT sensor library for ESPx
DHT sensor library
Wire
;WifiManager
;HTTPClient
;HttpClient
lib_deps =
https://github.com/ebenolson/WIFIMANAGER-ESP32.git
https://github.com/zhouhan0126/WebServer-esp32.git
https://github.com/arduino-libraries/ArduinoHttpClient.git
https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino
https://github.com/knolleary/pubsubclient.git
Streaming
https://github.com/livello/PrintEx#is-select-redecl
https://github.com/anklimov/NRFFlashStorage
[env:due]
platform = atmelsam
framework = arduino