Merge branch 'meshtastic:master' into master

This commit is contained in:
Jm Casler 2022-01-23 00:29:54 -08:00 committed by GitHub
commit a561713a48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 81 additions and 10 deletions

16
Dockerfile Normal file
View File

@ -0,0 +1,16 @@
FROM ubuntu
MAINTAINER Kevin Hester <kevinh@geeksville.com>
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install wget python3 g++ zip python3-venv git vim
RUN wget https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py -O get-platformio.py; chmod +x get-platformio.py
RUN python3 get-platformio.py
RUN git clone https://github.com/meshtastic/Meshtastic-device.git
RUN cd Meshtastic-device; git submodule update --init --recursive
# only build the simulator
RUN sed -i 's/^BOARDS_ESP32.*/BOARDS_ESP32=""/' Meshtastic-device/bin/build-all.sh
RUN sed -i 's/^BOARDS_NRF52.*/BOARDS_NRF52=""/' Meshtastic-device/bin/build-all.sh
RUN sed -i 's/echo "Building SPIFFS.*/exit/' Meshtastic-device/bin/build-all.sh
RUN . ~/.platformio/penv/bin/activate; cd Meshtastic-device; ./bin/build-all.sh
CMD ["/Meshtastic-device/release/latest/bins/universal/meshtasticd_linux_amd64"]

17
docker.txt Normal file
View File

@ -0,0 +1,17 @@
To build:
docker build -t meshtastic/device .
To run:
docker run --rm -p 4403:4403 meshtastic/device
or, to get a shell on the docker image:
docker run -it meshtastic/device bash
To use python cli against it:
meshtastic --info --host localhost
To stop:
# run this to get id
docker ps
# tip: you can just use the first few characters of the id in the next command
docker kill <id>

View File

@ -127,6 +127,7 @@ lib_deps =
h2zero/NimBLE-Arduino@1.3.4 h2zero/NimBLE-Arduino@1.3.4
tobozo/ESP32-targz@^1.1.4 tobozo/ESP32-targz@^1.1.4
arduino-libraries/NTPClient#531eff39d9fbc831f3d03f706a161739203fbe2a arduino-libraries/NTPClient#531eff39d9fbc831f3d03f706a161739203fbe2a
adafruit/Adafruit BME280 Library@^2.2.2
# Hmm - this doesn't work yet # Hmm - this doesn't work yet
# board_build.ldscript = linker/esp32.extram.bss.ld # board_build.ldscript = linker/esp32.extram.bss.ld

2
proto

@ -1 +1 @@
Subproject commit 62cb78fcbe2563f48b190b67cb6fc19fc463064d Subproject commit 60cf0545612bde3daf53f319db1b72d053f870d3

View File

@ -95,7 +95,9 @@ typedef enum _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType {
RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20 = 1, RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20 = 1,
RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT12 = 2, RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT12 = 2,
RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21 = 3, RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21 = 3,
RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22 = 4 RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22 = 4,
RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME280 = 5,
RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME680 = 6
} RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType; } RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType;
/* Struct definitions */ /* Struct definitions */
@ -220,8 +222,8 @@ typedef struct _RadioConfig {
#define _InputEventChar_ARRAYSIZE ((InputEventChar)(InputEventChar_KEY_BACK+1)) #define _InputEventChar_ARRAYSIZE ((InputEventChar)(InputEventChar_KEY_BACK+1))
#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11 #define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11
#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MAX RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22 #define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MAX RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME680
#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_ARRAYSIZE ((RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType)(RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22+1)) #define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_ARRAYSIZE ((RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType)(RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME680+1))
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -11,10 +11,13 @@
#include <OLEDDisplay.h> #include <OLEDDisplay.h>
#include <OLEDDisplayUi.h> #include <OLEDDisplayUi.h>
#include <OneWire.h> #include <OneWire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#define DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000 #define DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000
#define DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000 #define DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000
#define DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000 #define DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000
#define BME280_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000
#define FAILED_STATE_SENSOR_READ_MULTIPLIER 10 #define FAILED_STATE_SENSOR_READ_MULTIPLIER 10
#define DISPLAY_RECEIVEID_MEASUREMENTS_ON_SCREEN true #define DISPLAY_RECEIVEID_MEASUREMENTS_ON_SCREEN true
@ -50,11 +53,12 @@ int32_t EnvironmentalMeasurementPlugin::runOnce()
radioConfig.preferences.environmental_measurement_plugin_recovery_interval = 60; radioConfig.preferences.environmental_measurement_plugin_recovery_interval = 60;
radioConfig.preferences.environmental_measurement_plugin_display_farenheit = false; radioConfig.preferences.environmental_measurement_plugin_display_farenheit = false;
radioConfig.preferences.environmental_measurement_plugin_sensor_pin = 13; radioConfig.preferences.environmental_measurement_plugin_sensor_pin = 13;
radioConfig.preferences.environmental_measurement_plugin_sensor_type = radioConfig.preferences.environmental_measurement_plugin_sensor_type =
RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType:: RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType::
RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20; RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME280;
*/ */
if (!(radioConfig.preferences.environmental_measurement_plugin_measurement_enabled || if (!(radioConfig.preferences.environmental_measurement_plugin_measurement_enabled ||
radioConfig.preferences.environmental_measurement_plugin_screen_enabled)) { radioConfig.preferences.environmental_measurement_plugin_screen_enabled)) {
// If this plugin is not enabled, and the user doesn't want the display screen don't waste any OSThread time on it // If this plugin is not enabled, and the user doesn't want the display screen don't waste any OSThread time on it
@ -96,6 +100,17 @@ int32_t EnvironmentalMeasurementPlugin::runOnce()
DEBUG_MSG("EnvironmentalMeasurement: Opened DHT21/DHT22 on pin: %d\n", DEBUG_MSG("EnvironmentalMeasurement: Opened DHT21/DHT22 on pin: %d\n",
radioConfig.preferences.environmental_measurement_plugin_sensor_pin); radioConfig.preferences.environmental_measurement_plugin_sensor_pin);
return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME280:
unsigned bmeStatus;
// Default i2c address for BME280
bmeStatus = bme.begin(0x76);
if (!bmeStatus) {
DEBUG_MSG("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
// TODO more verbose diagnostics
} else {
DEBUG_MSG("EnvironmentalMeasurement: Opened BME280 on default i2c bus");
}
return (BME280_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
default: default:
DEBUG_MSG("EnvironmentalMeasurement: Invalid sensor type selected; Disabling plugin"); DEBUG_MSG("EnvironmentalMeasurement: Invalid sensor type selected; Disabling plugin");
return (INT32_MAX); return (INT32_MAX);
@ -146,6 +161,8 @@ int32_t EnvironmentalMeasurementPlugin::runOnce()
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21: case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21:
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22: case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22:
return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME280:
return (BME280_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
default: default:
return (DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); return (DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
} }
@ -223,10 +240,10 @@ void EnvironmentalMeasurementPlugin::drawFrame(OLEDDisplay *display, OLEDDisplay
last_temp = String(CelsiusToFarenheit(lastMeasurement.temperature), 0) + "°F"; last_temp = String(CelsiusToFarenheit(lastMeasurement.temperature), 0) + "°F";
; ;
} }
display->drawString(x, y += fontHeight(FONT_MEDIUM) - 2, "From: " + lastSender + "(" + String(agoSecs) + "s)");
display->drawString(x, y += fontHeight(FONT_MEDIUM), display->drawString(x, y += fontHeight(FONT_SMALL) - 2,"Temp/Hum: " + last_temp + " / " + String(lastMeasurement.relative_humidity, 0) + "%");
lastSender + ": " + last_temp + "/" + String(lastMeasurement.relative_humidity, 0) + "%(" + if (lastMeasurement.barometric_pressure != 0)
String(agoSecs) + "s)"); display->drawString(x, y += fontHeight(FONT_SMALL),"Press: " + String(lastMeasurement.barometric_pressure, 0) + "hPA");
} }
bool EnvironmentalMeasurementPlugin::handleReceivedProtobuf(const MeshPacket &mp, EnvironmentalMeasurement *p) bool EnvironmentalMeasurementPlugin::handleReceivedProtobuf(const MeshPacket &mp, EnvironmentalMeasurement *p)
@ -242,6 +259,7 @@ bool EnvironmentalMeasurementPlugin::handleReceivedProtobuf(const MeshPacket &mp
DEBUG_MSG("EnvironmentalMeasurement: Received data from %s\n", sender); DEBUG_MSG("EnvironmentalMeasurement: Received data from %s\n", sender);
DEBUG_MSG("EnvironmentalMeasurement->relative_humidity: %f\n", p->relative_humidity); DEBUG_MSG("EnvironmentalMeasurement->relative_humidity: %f\n", p->relative_humidity);
DEBUG_MSG("EnvironmentalMeasurement->temperature: %f\n", p->temperature); DEBUG_MSG("EnvironmentalMeasurement->temperature: %f\n", p->temperature);
DEBUG_MSG("EnvironmentalMeasurement->barometric_pressure: %f\n", p->barometric_pressure);
lastMeasurementPacket = packetPool.allocCopy(mp); lastMeasurementPacket = packetPool.allocCopy(mp);
@ -289,6 +307,12 @@ bool EnvironmentalMeasurementPlugin::sendOurEnvironmentalMeasurement(NodeNum des
m.relative_humidity = this->dht->readHumidity(); m.relative_humidity = this->dht->readHumidity();
m.temperature = this->dht->readTemperature(); m.temperature = this->dht->readTemperature();
break; break;
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME280:
m.temperature = bme.readTemperature();
m.relative_humidity = bme.readHumidity();
// TODO Work out standard units for pressure. This is in hPa from the Adafruit example
m.barometric_pressure = bme.readPressure() / 100.0F;
break;
default: default:
DEBUG_MSG("EnvironmentalMeasurement: Invalid sensor type selected; Disabling plugin"); DEBUG_MSG("EnvironmentalMeasurement: Invalid sensor type selected; Disabling plugin");
return false; return false;
@ -296,6 +320,7 @@ bool EnvironmentalMeasurementPlugin::sendOurEnvironmentalMeasurement(NodeNum des
DEBUG_MSG("EnvironmentalMeasurement->relative_humidity: %f\n", m.relative_humidity); DEBUG_MSG("EnvironmentalMeasurement->relative_humidity: %f\n", m.relative_humidity);
DEBUG_MSG("EnvironmentalMeasurement->temperature: %f\n", m.temperature); DEBUG_MSG("EnvironmentalMeasurement->temperature: %f\n", m.temperature);
DEBUG_MSG("EnvironmentalMeasurement->barometric_pressure: %f\n", m.barometric_pressure);
sensor_read_error_count = 0; sensor_read_error_count = 0;
@ -303,6 +328,8 @@ bool EnvironmentalMeasurementPlugin::sendOurEnvironmentalMeasurement(NodeNum des
p->to = dest; p->to = dest;
p->decoded.want_response = wantReplies; p->decoded.want_response = wantReplies;
lastMeasurementPacket = packetPool.allocCopy(*p);
DEBUG_MSG("EnvironmentalMeasurement: Sending packet to mesh");
service.sendToMesh(p); service.sendToMesh(p);
return true; return true;
} }

View File

@ -6,6 +6,8 @@
#include <OLEDDisplay.h> #include <OLEDDisplay.h>
#include <OLEDDisplayUi.h> #include <OLEDDisplayUi.h>
#include <OneWire.h> #include <OneWire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
class EnvironmentalMeasurementPlugin : private concurrency::OSThread, public ProtobufPlugin<EnvironmentalMeasurement> class EnvironmentalMeasurementPlugin : private concurrency::OSThread, public ProtobufPlugin<EnvironmentalMeasurement>
{ {
@ -36,6 +38,7 @@ class EnvironmentalMeasurementPlugin : private concurrency::OSThread, public Pro
DHT *dht; DHT *dht;
OneWire *oneWire; OneWire *oneWire;
DS18B20 *ds18b20; DS18B20 *ds18b20;
Adafruit_BME280 bme;
const MeshPacket *lastMeasurementPacket; const MeshPacket *lastMeasurementPacket;
uint32_t sensor_read_error_count = 0; uint32_t sensor_read_error_count = 0;
}; };

View File

@ -24,6 +24,7 @@
#define RF95_NSS 18 #define RF95_NSS 18
// supported modules list // supported modules list
#define USE_RF95 // RFM95/SX127x
#define USE_SX1262 #define USE_SX1262
#define USE_SX1268 #define USE_SX1268
#define USE_LLCC68 #define USE_LLCC68
@ -36,6 +37,10 @@
#define SX126X_RXEN 14 #define SX126X_RXEN 14
#define SX126X_TXEN 13 #define SX126X_TXEN 13
// RX/TX for RFM95/SX127x
#define RF95_RXEN 14
#define RF95_TXEN 13
#ifdef EBYTE_E22 #ifdef EBYTE_E22
// Internally the TTGO module hooks the SX126x-DIO2 in to control the TX/RX switch // Internally the TTGO module hooks the SX126x-DIO2 in to control the TX/RX switch
// (which is the default for the sx1262interface code) // (which is the default for the sx1262interface code)