mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-07 20:19:25 +00:00
Compare commits
6 Commits
2d4d36c605
...
93bc61c855
Author | SHA1 | Date | |
---|---|---|---|
![]() |
93bc61c855 | ||
![]() |
0fc5c9b0d7 | ||
![]() |
b0c924f185 | ||
![]() |
8801bc5ce9 | ||
![]() |
cf476eb87c | ||
![]() |
ba2f25293b |
4
CODE_OF_CONDUCT.md
Normal file
4
CODE_OF_CONDUCT.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
The Meshtastic Firmware project is subject to the code of conduct for the parent project, which can be found here:
|
||||||
|
https://meshtastic.org/docs/legal/conduct/
|
@ -1 +1 @@
|
|||||||
Subproject commit 807236815d61cc0ebd89472c2a2aa76758bc92ac
|
Subproject commit 015202aead5f6807d63537c58f4cb6525f19e56f
|
@ -207,6 +207,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
#ifndef GPS_BAUDRATE
|
#ifndef GPS_BAUDRATE
|
||||||
#define GPS_BAUDRATE 9600
|
#define GPS_BAUDRATE 9600
|
||||||
|
#define GPS_BAUDRATE_FIXED 0
|
||||||
|
#else
|
||||||
|
#define GPS_BAUDRATE_FIXED 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Step #2: follow with defines common to the architecture;
|
/* Step #2: follow with defines common to the architecture;
|
||||||
|
@ -413,30 +413,42 @@ int GPS::getACK(uint8_t *buffer, uint16_t size, uint8_t requestedClass, uint8_t
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setup the GPS based on the model detected.
|
||||||
|
* We detect the GPS by cycling through a set of baud rates, first common then rare.
|
||||||
|
* For each baud rate, we run GPS::Probe to send commands and match the responses
|
||||||
|
* to known GPS responses.
|
||||||
|
* @retval Whether setup reached the end of its potential to configure the GPS.
|
||||||
|
*/
|
||||||
bool GPS::setup()
|
bool GPS::setup()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!didSerialInit) {
|
if (!didSerialInit) {
|
||||||
int msglen = 0;
|
int msglen = 0;
|
||||||
if (tx_gpio && gnssModel == GNSS_MODEL_UNKNOWN) {
|
if (tx_gpio && gnssModel == GNSS_MODEL_UNKNOWN) {
|
||||||
|
if (probeTries < 2) {
|
||||||
// if GPS_BAUDRATE is specified in variant (i.e. not 9600), skip to the specified rate.
|
LOG_DEBUG("Probing for GPS at %d", serialSpeeds[speedSelect]);
|
||||||
if (speedSelect == 0 && probeTries == 2 && GPS_BAUDRATE != serialSpeeds[speedSelect]) {
|
gnssModel = probe(serialSpeeds[speedSelect]);
|
||||||
speedSelect = std::find(serialSpeeds, std::end(serialSpeeds), GPS_BAUDRATE) - serialSpeeds;
|
if (gnssModel == GNSS_MODEL_UNKNOWN) {
|
||||||
|
if (++speedSelect == sizeof(serialSpeeds) / sizeof(int)) {
|
||||||
|
speedSelect = 0;
|
||||||
|
++probeTries;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// Rare Serial Speeds
|
||||||
LOG_DEBUG("Probing for GPS at %d", serialSpeeds[speedSelect]);
|
if (probeTries == 2) {
|
||||||
gnssModel = probe(serialSpeeds[speedSelect]);
|
LOG_DEBUG("Probing for GPS at %d", rareSerialSpeeds[speedSelect]);
|
||||||
if (gnssModel == GNSS_MODEL_UNKNOWN) {
|
gnssModel = probe(rareSerialSpeeds[speedSelect]);
|
||||||
if (++speedSelect == sizeof(serialSpeeds) / sizeof(int)) {
|
if (gnssModel == GNSS_MODEL_UNKNOWN) {
|
||||||
speedSelect = 0;
|
if (++speedSelect == sizeof(rareSerialSpeeds) / sizeof(int)) {
|
||||||
if (--probeTries == 0) {
|
|
||||||
LOG_WARN("Giving up on GPS probe and setting to %d", GPS_BAUDRATE);
|
LOG_WARN("Giving up on GPS probe and setting to %d", GPS_BAUDRATE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
gnssModel = GNSS_MODEL_UNKNOWN;
|
gnssModel = GNSS_MODEL_UNKNOWN;
|
||||||
}
|
}
|
||||||
@ -675,7 +687,8 @@ bool GPS::setup()
|
|||||||
SEND_UBX_PACKET(0x06, 0x8A, _message_VALSET_DISABLE_SBAS_BBR, "disable SBAS M10 GPS BBR", 300);
|
SEND_UBX_PACKET(0x06, 0x8A, _message_VALSET_DISABLE_SBAS_BBR, "disable SBAS M10 GPS BBR", 300);
|
||||||
delay(750); // will cause a receiver restart so wait a bit
|
delay(750); // will cause a receiver restart so wait a bit
|
||||||
|
|
||||||
// Done with initialization, Now enable wanted NMEA messages in BBR layer so they will survive a periodic sleep.
|
// Done with initialization, Now enable wanted NMEA messages in BBR layer so they will survive a periodic
|
||||||
|
// sleep.
|
||||||
SEND_UBX_PACKET(0x06, 0x8A, _message_VALSET_ENABLE_NMEA_BBR, "enable messages for M10 GPS BBR", 300);
|
SEND_UBX_PACKET(0x06, 0x8A, _message_VALSET_ENABLE_NMEA_BBR, "enable messages for M10 GPS BBR", 300);
|
||||||
delay(750);
|
delay(750);
|
||||||
// Next enable wanted NMEA messages in RAM layer
|
// Next enable wanted NMEA messages in RAM layer
|
||||||
@ -937,10 +950,10 @@ void GPS::down()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (softsleepSupported) {
|
if (softsleepSupported) {
|
||||||
// How long does gps_update_interval need to be, for GPS_HARDSLEEP to become more efficient than GPS_SOFTSLEEP?
|
// How long does gps_update_interval need to be, for GPS_HARDSLEEP to become more efficient than
|
||||||
// Heuristic equation. A compromise manually fitted to power observations from U-blox NEO-6M and M10050
|
// GPS_SOFTSLEEP? Heuristic equation. A compromise manually fitted to power observations from U-blox NEO-6M
|
||||||
// https://www.desmos.com/calculator/6gvjghoumr
|
// and M10050 https://www.desmos.com/calculator/6gvjghoumr This is not particularly accurate, but probably an
|
||||||
// This is not particularly accurate, but probably an impromevement over a single, fixed threshold
|
// improvement over a single, fixed threshold
|
||||||
uint32_t hardsleepThreshold = (2750 * pow(predictedSearchDuration / 1000, 1.22));
|
uint32_t hardsleepThreshold = (2750 * pow(predictedSearchDuration / 1000, 1.22));
|
||||||
LOG_DEBUG("gps_update_interval >= %us needed to justify hardsleep", hardsleepThreshold / 1000);
|
LOG_DEBUG("gps_update_interval >= %us needed to justify hardsleep", hardsleepThreshold / 1000);
|
||||||
|
|
||||||
@ -1293,10 +1306,12 @@ GPS *GPS::createGps()
|
|||||||
|
|
||||||
if (!GPS_EN_ACTIVE) { // Need to invert the pin before hardware
|
if (!GPS_EN_ACTIVE) { // Need to invert the pin before hardware
|
||||||
new GpioNotTransformer(
|
new GpioNotTransformer(
|
||||||
virtPin, p); // We just leave this created object on the heap so it can stay watching virtPin and driving en_gpio
|
virtPin,
|
||||||
|
p); // We just leave this created object on the heap so it can stay watching virtPin and driving en_gpio
|
||||||
} else {
|
} else {
|
||||||
new GpioUnaryTransformer(
|
new GpioUnaryTransformer(
|
||||||
virtPin, p); // We just leave this created object on the heap so it can stay watching virtPin and driving en_gpio
|
virtPin,
|
||||||
|
p); // We just leave this created object on the heap so it can stay watching virtPin and driving en_gpio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1404,8 +1419,8 @@ bool GPS::factoryReset()
|
|||||||
_serial_gps->write("$PMTK104*37\r\n");
|
_serial_gps->write("$PMTK104*37\r\n");
|
||||||
// No PMTK_ACK for this command.
|
// No PMTK_ACK for this command.
|
||||||
delay(100);
|
delay(100);
|
||||||
// send the UBLOX Factory Reset Command regardless of detect state, something is very wrong, just assume it's UBLOX.
|
// send the UBLOX Factory Reset Command regardless of detect state, something is very wrong, just assume it's
|
||||||
// Factory Reset
|
// UBLOX. Factory Reset
|
||||||
byte _message_reset[] = {0xB5, 0x62, 0x06, 0x09, 0x0D, 0x00, 0xFF, 0xFB, 0x00, 0x00, 0x00,
|
byte _message_reset[] = {0xB5, 0x62, 0x06, 0x09, 0x0D, 0x00, 0xFF, 0xFB, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x17, 0x2B, 0x7E};
|
0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x17, 0x2B, 0x7E};
|
||||||
_serial_gps->write(_message_reset, sizeof(_message_reset));
|
_serial_gps->write(_message_reset, sizeof(_message_reset));
|
||||||
@ -1444,8 +1459,8 @@ bool GPS::lookForTime()
|
|||||||
auto d = reader.date;
|
auto d = reader.date;
|
||||||
if (ti.isValid() && d.isValid()) { // Note: we don't check for updated, because we'll only be called if needed
|
if (ti.isValid() && d.isValid()) { // Note: we don't check for updated, because we'll only be called if needed
|
||||||
/* Convert to unix time
|
/* Convert to unix time
|
||||||
The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970
|
The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1,
|
||||||
(midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z).
|
1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z).
|
||||||
*/
|
*/
|
||||||
struct tm t;
|
struct tm t;
|
||||||
t.tm_sec = ti.second() + round(ti.age() / 1000);
|
t.tm_sec = ti.second() + round(ti.age() / 1000);
|
||||||
@ -1678,7 +1693,9 @@ bool GPS::whileActive()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef GPS_DEBUG
|
#ifdef GPS_DEBUG
|
||||||
LOG_DEBUG(debugmsg.c_str());
|
if (debugmsg != "") {
|
||||||
|
LOG_DEBUG(debugmsg.c_str());
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return isValid;
|
return isValid;
|
||||||
}
|
}
|
||||||
|
@ -76,13 +76,21 @@ class GPS : private concurrency::OSThread
|
|||||||
uint8_t fixType = 0; // fix type from GPGSA
|
uint8_t fixType = 0; // fix type from GPGSA
|
||||||
#endif
|
#endif
|
||||||
private:
|
private:
|
||||||
const int serialSpeeds[6] = {9600, 115200, 38400, 4800, 57600, GPS_BAUDRATE};
|
#if GPS_BAUDRATE_FIXED
|
||||||
|
// if GPS_BAUDRATE is specified in variant, only try that.
|
||||||
|
const int serialSpeeds[1] = {GPS_BAUDRATE};
|
||||||
|
const int rareSerialSpeeds[1] = {GPS_BAUDRATE};
|
||||||
|
#else
|
||||||
|
const int serialSpeeds[3] = {9600, 115200, 38400};
|
||||||
|
const int rareSerialSpeeds[3] = {4800, 57600, GPS_BAUDRATE};
|
||||||
|
#endif
|
||||||
|
|
||||||
uint32_t lastWakeStartMsec = 0, lastSleepStartMsec = 0, lastFixStartMsec = 0;
|
uint32_t lastWakeStartMsec = 0, lastSleepStartMsec = 0, lastFixStartMsec = 0;
|
||||||
uint32_t rx_gpio = 0;
|
uint32_t rx_gpio = 0;
|
||||||
uint32_t tx_gpio = 0;
|
uint32_t tx_gpio = 0;
|
||||||
|
|
||||||
int speedSelect = 0;
|
int speedSelect = 0;
|
||||||
int probeTries = 2;
|
int probeTries = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hasValidLocation - indicates that the position variables contain a complete
|
* hasValidLocation - indicates that the position variables contain a complete
|
||||||
|
@ -59,7 +59,7 @@ int32_t ScanAndSelectInput::runOnce()
|
|||||||
// If: "no messages added" alert screen currently shown
|
// If: "no messages added" alert screen currently shown
|
||||||
if (alertingNoMessage) {
|
if (alertingNoMessage) {
|
||||||
// Dismiss the alert screen several seconds after it appears
|
// Dismiss the alert screen several seconds after it appears
|
||||||
if (now > alertingSinceMs + durationAlertMs) {
|
if (!Throttle::isWithinTimespanMs(alertingSinceMs, durationAlertMs)) {
|
||||||
alertingNoMessage = false;
|
alertingNoMessage = false;
|
||||||
screen->endAlert();
|
screen->endAlert();
|
||||||
}
|
}
|
||||||
@ -74,9 +74,9 @@ int32_t ScanAndSelectInput::runOnce()
|
|||||||
|
|
||||||
// Existing press
|
// Existing press
|
||||||
else {
|
else {
|
||||||
// Duration enough for long press
|
// Longer than shortpress window
|
||||||
// Long press not yet fired (prevent repeat firing while held)
|
// Long press not yet fired (prevent repeat firing while held)
|
||||||
if (!longPressFired && Throttle::isWithinTimespanMs(downSinceMs, durationLongMs)) {
|
if (!longPressFired && !Throttle::isWithinTimespanMs(downSinceMs, durationLongMs)) {
|
||||||
longPressFired = true;
|
longPressFired = true;
|
||||||
longPress();
|
longPress();
|
||||||
}
|
}
|
||||||
@ -91,7 +91,9 @@ int32_t ScanAndSelectInput::runOnce()
|
|||||||
// Button newly released
|
// Button newly released
|
||||||
// Long press event didn't already fire
|
// Long press event didn't already fire
|
||||||
if (held && !longPressFired) {
|
if (held && !longPressFired) {
|
||||||
// Duration enough for short press
|
// Duration within shortpress window
|
||||||
|
// - longer than durationShortPress (debounce)
|
||||||
|
// - shorter than durationLongPress
|
||||||
if (!Throttle::isWithinTimespanMs(downSinceMs, durationShortMs)) {
|
if (!Throttle::isWithinTimespanMs(downSinceMs, durationShortMs)) {
|
||||||
shortPress();
|
shortPress();
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,10 @@
|
|||||||
#include <pb_decode.h>
|
#include <pb_decode.h>
|
||||||
#include <pb_encode.h>
|
#include <pb_encode.h>
|
||||||
|
|
||||||
|
#if ARCH_PORTDUINO
|
||||||
|
#include "PortduinoGlue.h"
|
||||||
|
#include "meshUtils.h"
|
||||||
|
#endif
|
||||||
void LockingArduinoHal::spiBeginTransaction()
|
void LockingArduinoHal::spiBeginTransaction()
|
||||||
{
|
{
|
||||||
spiLock->lock();
|
spiLock->lock();
|
||||||
@ -393,6 +397,11 @@ void RadioLibInterface::handleReceiveInterrupt()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int state = iface->readData((uint8_t *)&radioBuffer, length);
|
int state = iface->readData((uint8_t *)&radioBuffer, length);
|
||||||
|
#if ARCH_PORTDUINO
|
||||||
|
if (settingsMap[logoutputlevel] == level_trace) {
|
||||||
|
printBytes("Raw incoming packet: ", (uint8_t *)&radioBuffer, length);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (state != RADIOLIB_ERR_NONE) {
|
if (state != RADIOLIB_ERR_NONE) {
|
||||||
LOG_ERROR("ignoring received packet due to error=%d", state);
|
LOG_ERROR("ignoring received packet due to error=%d", state);
|
||||||
rxBad++;
|
rxBad++;
|
||||||
|
@ -408,7 +408,7 @@ typedef enum _meshtastic_LogRecord_Level {
|
|||||||
} meshtastic_LogRecord_Level;
|
} meshtastic_LogRecord_Level;
|
||||||
|
|
||||||
/* Struct definitions */
|
/* Struct definitions */
|
||||||
/* a gps position */
|
/* A GPS Position */
|
||||||
typedef struct _meshtastic_Position {
|
typedef struct _meshtastic_Position {
|
||||||
/* The new preferred location encoding, multiply by 1e-7 to get degrees
|
/* The new preferred location encoding, multiply by 1e-7 to get degrees
|
||||||
in floating point */
|
in floating point */
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include "FSCommon.h"
|
#include "FSCommon.h"
|
||||||
#include "mesh-pb-constants.h"
|
#include "mesh-pb-constants.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <pb_decode.h>
|
#include <pb_decode.h>
|
||||||
#include <pb_encode.h>
|
#include <pb_encode.h>
|
||||||
|
|
||||||
@ -14,8 +13,6 @@ size_t pb_encode_to_bytes(uint8_t *destbuf, size_t destbufsize, const pb_msgdesc
|
|||||||
pb_ostream_t stream = pb_ostream_from_buffer(destbuf, destbufsize);
|
pb_ostream_t stream = pb_ostream_from_buffer(destbuf, destbufsize);
|
||||||
if (!pb_encode(&stream, fields, src_struct)) {
|
if (!pb_encode(&stream, fields, src_struct)) {
|
||||||
LOG_ERROR("Panic: can't encode protobuf reason='%s'", PB_GET_ERROR(&stream));
|
LOG_ERROR("Panic: can't encode protobuf reason='%s'", PB_GET_ERROR(&stream));
|
||||||
assert(
|
|
||||||
0); // If this assert fails it probably means you made a field too large for the max limits specified in mesh.options
|
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return stream.bytes_written;
|
return stream.bytes_written;
|
||||||
@ -71,4 +68,4 @@ bool is_in_helper(uint32_t n, const uint32_t *array, pb_size_t count)
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -61,15 +61,13 @@ char *strnstr(const char *s, const char *find, size_t slen)
|
|||||||
void printBytes(const char *label, const uint8_t *p, size_t numbytes)
|
void printBytes(const char *label, const uint8_t *p, size_t numbytes)
|
||||||
{
|
{
|
||||||
int labelSize = strlen(label);
|
int labelSize = strlen(label);
|
||||||
if (labelSize < 100 && numbytes < 64) {
|
char *messageBuffer = new char[labelSize + (numbytes * 3) + 2];
|
||||||
char *messageBuffer = new char[labelSize + (numbytes * 3) + 2];
|
strncpy(messageBuffer, label, labelSize);
|
||||||
strncpy(messageBuffer, label, labelSize);
|
for (size_t i = 0; i < numbytes; i++)
|
||||||
for (size_t i = 0; i < numbytes; i++)
|
snprintf(messageBuffer + labelSize + i * 3, 4, " %02x", p[i]);
|
||||||
snprintf(messageBuffer + labelSize + i * 3, 4, " %02x", p[i]);
|
strcpy(messageBuffer + labelSize + numbytes * 3, "\n");
|
||||||
strcpy(messageBuffer + labelSize + numbytes * 3, "\n");
|
LOG_DEBUG(messageBuffer);
|
||||||
LOG_DEBUG(messageBuffer);
|
delete[] messageBuffer;
|
||||||
delete[] messageBuffer;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool memfll(const uint8_t *mem, uint8_t find, size_t numbytes)
|
bool memfll(const uint8_t *mem, uint8_t find, size_t numbytes)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[VERSION]
|
[VERSION]
|
||||||
major = 2
|
major = 2
|
||||||
minor = 5
|
minor = 5
|
||||||
build = 10
|
build = 11
|
||||||
|
Loading…
Reference in New Issue
Block a user