gatewayTransportSend

This commit is contained in:
Dmitry Borisenko
2022-12-01 02:10:06 +01:00
parent 2c61580157
commit cb50965c3b
293 changed files with 67232 additions and 3 deletions

View File

@@ -0,0 +1,144 @@
/*
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2019 Sensnology AB
* Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* Arduino core for ESP32: https://github.com/espressif/arduino-esp32
*
* MySensors ESP32 implementation, Copyright (C) 2017-2018 Olivier Mauti <olivier@mysensors.org>
*
*/
#include "MyHwESP32.h"
bool hwInit(void)
{
#if !defined(MY_DISABLED_SERIAL)
MY_SERIALDEVICE.begin(MY_BAUD_RATE, SERIAL_8N1);
#if defined(MY_GATEWAY_SERIAL)
while (!MY_SERIALDEVICE) {}
#endif
#endif
return EEPROM.begin(MY_EEPROM_SIZE);
}
void hwReadConfigBlock(void *buf, void *addr, size_t length)
{
uint8_t *dst = static_cast<uint8_t *>(buf);
int offs = reinterpret_cast<int>(addr);
while (length-- > 0) {
*dst++ = EEPROM.read(offs++);
}
}
void hwWriteConfigBlock(void *buf, void *addr, size_t length)
{
uint8_t *src = static_cast<uint8_t *>(buf);
int offs = reinterpret_cast<int>(addr);
while (length-- > 0) {
EEPROM.write(offs++, *src++);
}
EEPROM.commit();
}
uint8_t hwReadConfig(const int addr)
{
uint8_t value;
hwReadConfigBlock(&value, reinterpret_cast<void *>(addr), 1);
return value;
}
void hwWriteConfig(const int addr, uint8_t value)
{
if (hwReadConfig(addr) != value) {
hwWriteConfigBlock(&value, reinterpret_cast<void *>(addr), 1);
}
}
bool hwUniqueID(unique_id_t *uniqueID)
{
uint64_t val = ESP.getEfuseMac();
(void)memcpy((void *)uniqueID, (void *)&val, 8);
(void)memset((void *)(uniqueID + 8), MY_HWID_PADDING_BYTE, 8); // padding
return true;
}
ssize_t hwGetentropy(void *__buffer, size_t __length)
{
// cut length if > 256
if (__length > 256) {
__length = 256;
}
uint8_t *dst = (uint8_t *)__buffer;
// get random numbers
for (size_t i = 0; i < __length; i++) {
dst[i] = (uint8_t)esp_random();
}
return __length;
}
int8_t hwSleep(uint32_t ms)
{
// TODO: Not supported!
(void)ms;
return MY_SLEEP_NOT_POSSIBLE;
}
int8_t hwSleep(const uint8_t interrupt, const uint8_t mode, uint32_t ms)
{
// TODO: Not supported!
(void)interrupt;
(void)mode;
(void)ms;
return MY_SLEEP_NOT_POSSIBLE;
}
int8_t hwSleep(const uint8_t interrupt1, const uint8_t mode1, const uint8_t interrupt2,
const uint8_t mode2,
uint32_t ms)
{
// TODO: Not supported!
(void)interrupt1;
(void)mode1;
(void)interrupt2;
(void)mode2;
(void)ms;
return MY_SLEEP_NOT_POSSIBLE;
}
uint16_t hwCPUVoltage(void)
{
// in mV
return FUNCTION_NOT_SUPPORTED;
}
uint16_t hwCPUFrequency(void)
{
// in 1/10Mhz
return static_cast<uint16_t>(ESP.getCpuFreqMHz() * 10);
}
int8_t hwCPUTemperature(void)
{
// CPU temperature in °C
return static_cast<int8_t>((temperatureRead() - MY_ESP32_TEMPERATURE_OFFSET) /
MY_ESP32_TEMPERATURE_GAIN);
}
uint16_t hwFreeMem(void)
{
return static_cast<uint16_t>(ESP.getFreeHeap());
}

View File

@@ -0,0 +1,107 @@
/*
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2019 Sensnology AB
* Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* Arduino core for ESP32: https://github.com/espressif/arduino-esp32
*
* MySensors ESP32 implementation, Copyright (C) 2017-2018 Olivier Mauti <olivier@mysensors.org>
*
* Radio wiring ESP32(Node32s): RF24, RFM69, RFM95:
*
* | IO | RF24 | RFM69 | RFM95 |
* |------|------|-------|-------|
* | MOSI | 23 | 23 | 23 |
* | MISO | 19 | 19 | 19 |
* | SCK | 18 | 18 | 18 |
* | CSN | 5 | 5 | 5 |
* | CE | 17 | - | - |
* | RST | - | 17 | 17 |
* | IRQ | 16* | 16 | 16 |
* * = optional
*
*/
#ifndef MyHwESP32_h
#define MyHwESP32_h
#include <WiFi.h>
#include "EEPROM.h"
#include <SPI.h>
#ifdef __cplusplus
#include <Arduino.h>
#endif
#define CRYPTO_LITTLE_ENDIAN
#ifndef MY_SERIALDEVICE
#define MY_SERIALDEVICE Serial
#endif
#ifndef MY_DEBUGDEVICE
#define MY_DEBUGDEVICE MY_SERIALDEVICE
#endif
#ifndef MY_ESP32_TEMPERATURE_OFFSET
#define MY_ESP32_TEMPERATURE_OFFSET (0.0f)
#endif
#ifndef MY_ESP32_TEMPERATURE_GAIN
#define MY_ESP32_TEMPERATURE_GAIN (1.0f)
#endif
#define MY_EEPROM_SIZE 1024
#define hwDigitalWrite(__pin, __value) digitalWrite(__pin, __value)
#define hwDigitalRead(__pin) digitalRead(__pin)
#define hwPinMode(__pin, __value) pinMode(__pin, __value)
#define hwWatchdogReset()
#define hwReboot() ESP.restart()
#define hwMillis() millis()
#define hwMicros() micros()
#define hwRandomNumberInit() randomSeed(esp_random())
#define hwGetSleepRemaining() (0ul)
bool hwInit(void);
void hwReadConfigBlock(void *buf, void *addr, size_t length);
void hwWriteConfigBlock(void *buf, void *addr, size_t length);
void hwWriteConfig(const int addr, uint8_t value);
uint8_t hwReadConfig(const int addr);
ssize_t hwGetentropy(void *__buffer, size_t __length);
#define MY_HW_HAS_GETENTROPY
// SOFTSPI
#ifdef MY_SOFTSPI
#error Soft SPI is not available on this architecture!
#endif
#define hwSPI SPI //!< hwSPI
/**
* Restore interrupt state.
* Helper function for MY_CRITICAL_SECTION.
*/
static __inline__ void __psRestore(const uint32_t *__s)
{
XTOS_RESTORE_INTLEVEL(*__s);
}
#ifndef DOXYGEN
#define MY_CRITICAL_SECTION for ( uint32_t __psSaved __attribute__((__cleanup__(__psRestore))) = XTOS_DISABLE_ALL_INTERRUPTS, __ToDo = 1; __ToDo ; __ToDo = 0 )
#endif /* DOXYGEN */
#endif

View File

@@ -0,0 +1,57 @@
/*
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2019 Sensnology AB
* Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
*/
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_task_wdt.h"
#include "Arduino.h"
TaskHandle_t loopTaskHandle = NULL;
#if CONFIG_AUTOSTART_ARDUINO
#if CONFIG_FREERTOS_UNICORE
#define ARDUINO_RUNNING_CORE 0
#else
#define ARDUINO_RUNNING_CORE 1
#endif
bool loopTaskWDTEnabled;
void loopTask(void *pvParameters)
{
_begin(); // Startup MySensors library
for(;;) {
if(loopTaskWDTEnabled) {
esp_task_wdt_reset();
}
_process(); // Process incoming data
loop();
}
}
extern "C" void app_main()
{
loopTaskWDTEnabled = false;
initArduino();
xTaskCreatePinnedToCore(loopTask, "loopTask", 8192, NULL, 1, &loopTaskHandle, ARDUINO_RUNNING_CORE);
}
#endif