Merge pull request #594 from geeksville/dev

Dev
1.2-legacy
Kevin Hester 2020-12-26 13:53:48 +08:00 zatwierdzone przez GitHub
commit 36d28d2da6
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
10 zmienionych plików z 72 dodań i 24 usunięć

Wyświetl plik

@ -34,8 +34,8 @@ For app cleanup:
* DONE move user info into regular data packets (use new app framework) * DONE move user info into regular data packets (use new app framework)
* DONE test that positions, text messages and user info still work * DONE test that positions, text messages and user info still work
* DONE test that position, text messages and user info work properly with new android app and old device code * DONE test that position, text messages and user info work properly with new android app and old device code
* do UDP tunnel * DONE do UDP tunnel
* fix the RTC drift bug * DONE fix the RTC drift bug
* move python ping functionality into device, reply with rxsnr info * move python ping functionality into device, reply with rxsnr info
* use channels for gpio security https://github.com/meshtastic/Meshtastic-device/issues/104 * use channels for gpio security https://github.com/meshtastic/Meshtastic-device/issues/104
* MeshPackets for sending should be reference counted so that API clients would have the option of checking sent status (would allow removing the nasty 30 sec timer in gpio watch sending) * MeshPackets for sending should be reference counted so that API clients would have the option of checking sent status (would allow removing the nasty 30 sec timer in gpio watch sending)

Wyświetl plik

@ -2,8 +2,24 @@
#include <Arduino.h> #include <Arduino.h>
/// Error codes for critical error /** Error codes for critical errors
enum CriticalErrorCode { NoError, ErrTxWatchdog, ErrSleepEnterWait, ErrNoRadio, ErrUnspecified, UBloxInitFailed }; *
* The device might report these fault codes on the screen. If you encounter a fault code, please
* post on the meshtastic.discourse.group and we'll try to help.
*/
enum CriticalErrorCode {
NoError = 0,
ErrTxWatchdog = 1,
ErrSleepEnterWait = 2,
// No Lora radio hardware could be found
ErrNoRadio = 3,
ErrUnspecified = 4,
ErrUBloxInitFailed = 5,
// This board was expected to have a power management chip and it is missing or broken
ErrNoAXP192 = 6
};
/// Record an error that should be reported via analytics /// Record an error that should be reported via analytics
void recordCriticalError(CriticalErrorCode code, uint32_t address = 0); void recordCriticalError(CriticalErrorCode code, uint32_t address = 0);

Wyświetl plik

@ -43,7 +43,7 @@ bool UBloxGPS::setupGPS()
DEBUG_MSG("Connected to UBLOX GPS successfully\n"); DEBUG_MSG("Connected to UBLOX GPS successfully\n");
if (!setUBXMode()) if (!setUBXMode())
recordCriticalError(UBloxInitFailed); // Don't halt the boot if saving the config fails, but do report the bug recordCriticalError(ErrUBloxInitFailed); // Don't halt the boot if saving the config fails, but do report the bug
return true; return true;
} else { } else {

Wyświetl plik

@ -26,7 +26,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "MeshService.h" #include "MeshService.h"
#include "NodeDB.h" #include "NodeDB.h"
#include "Screen.h" #include "Screen.h"
#include "configs.h"
#include "configuration.h" #include "configuration.h"
#include "graphics/images.h" #include "graphics/images.h"
#include "main.h" #include "main.h"
@ -35,12 +34,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "plugins/TextMessagePlugin.h" #include "plugins/TextMessagePlugin.h"
#include "target_specific.h" #include "target_specific.h"
#include "utils.h" #include "utils.h"
#include "fonts.h"
using namespace meshtastic; /** @todo remove */ using namespace meshtastic; /** @todo remove */
namespace graphics namespace graphics
{ {
// This means the *visible* area (sh1106 can address 132, but shows 128 for example)
#define IDLE_FRAMERATE 1 // in fps
#define COMPASS_DIAM 44
// DEBUG
#define NUM_EXTRA_FRAMES 3 // text message and debug frame
// if defined a pixel will blink to show redraws
// #define SHOW_REDRAWS
// A text message frame + debug frame + all the node infos // A text message frame + debug frame + all the node infos
static FrameCallback normalFrames[MAX_NUM_NODES + NUM_EXTRA_FRAMES]; static FrameCallback normalFrames[MAX_NUM_NODES + NUM_EXTRA_FRAMES];
static uint32_t targetFramerate = IDLE_FRAMERATE; static uint32_t targetFramerate = IDLE_FRAMERATE;
@ -152,6 +161,23 @@ static void drawFrameBluetooth(OLEDDisplay *display, OLEDDisplayUiState *state,
display->drawString(64 + x, 48 + y, buf); display->drawString(64 + x, 48 + y, buf);
} }
/// Draw the last text message we received
static void drawCriticalFaultFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
{
displayedNodeNum = 0; // Not currently showing a node pane
display->setTextAlignment(TEXT_ALIGN_LEFT);
display->setFont(FONT_MEDIUM);
char tempBuf[24];
snprintf(tempBuf, sizeof(tempBuf), "Critical fault #%d", myNodeInfo.error_code);
display->drawString(0 + x, 0 + y, tempBuf);
display->setTextAlignment(TEXT_ALIGN_LEFT);
display->setFont(FONT_SMALL);
display->drawString(0 + x, FONT_HEIGHT_MEDIUM + y, "For help, please post on\nmeshtastic.discourse.group");
}
/// Draw the last text message we received /// Draw the last text message we received
static void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) static void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
{ {
@ -849,7 +875,11 @@ void Screen::setFrames()
size_t numframes = 0; size_t numframes = 0;
// If we have a text message - show it first // If we have a critical fault, show it first
if (myNodeInfo.error_code)
normalFrames[numframes++] = drawCriticalFaultFrame;
// If we have a text message - show it next
if (devicestate.has_rx_text_message) if (devicestate.has_rx_text_message)
normalFrames[numframes++] = drawTextMessageFrame; normalFrames[numframes++] = drawTextMessageFrame;

Wyświetl plik

@ -3,7 +3,6 @@
#ifdef ST7735_CS #ifdef ST7735_CS
#include "SPILock.h" #include "SPILock.h"
#include "TFTDisplay.h" #include "TFTDisplay.h"
#include "graphics/configs.h"
#include <SPI.h> #include <SPI.h>
#include <TFT_eSPI.h> // Graphics and font library for ST7735 driver chip #include <TFT_eSPI.h> // Graphics and font library for ST7735 driver chip

Wyświetl plik

@ -1,12 +0,0 @@
#pragma once
#include "fonts.h"
// This means the *visible* area (sh1106 can address 132, but shows 128 for example)
#define IDLE_FRAMERATE 1 // in fps
#define COMPASS_DIAM 44
// DEBUG
#define NUM_EXTRA_FRAMES 2 // text message and debug frame
// if defined a pixel will blink to show redraws
// #define SHOW_REDRAWS

Wyświetl plik

@ -92,6 +92,7 @@ void scanI2Cdevice(void)
DEBUG_MSG("Unknow error at address 0x%x\n", addr); DEBUG_MSG("Unknow error at address 0x%x\n", addr);
} }
} }
if (nDevices == 0) if (nDevices == 0)
DEBUG_MSG("No I2C devices found\n"); DEBUG_MSG("No I2C devices found\n");
else else
@ -362,6 +363,10 @@ void setup()
nrf52Setup(); nrf52Setup();
#endif #endif
// We do this as early as possible because this loads preferences from flash
// but we need to do this after main cpu iniot (esp32setup), because we need the random seed set
nodeDB.init();
// Currently only the tbeam has a PMU // Currently only the tbeam has a PMU
power = new Power(); power = new Power();
power->setStatusHandler(powerStatus); power->setStatusHandler(powerStatus);
@ -420,6 +425,12 @@ void setup()
service.init(); service.init();
// Do this after service.init (because that clears error_code)
#ifdef AXP192_SLAVE_ADDRESS
if(!axp192_found)
recordCriticalError(ErrNoAXP192); // Record a hardware fault for missing hardware
#endif
// Don't call screen setup until after nodedb is setup (because we need // Don't call screen setup until after nodedb is setup (because we need
// the current region name) // the current region name)
#if defined(ST7735_CS) || defined(HAS_EINK) #if defined(ST7735_CS) || defined(HAS_EINK)

Wyświetl plik

@ -77,7 +77,8 @@ void MeshService::init()
sendOwnerPeriod = new concurrency::Periodic("SendOwner", sendOwnerCb); sendOwnerPeriod = new concurrency::Periodic("SendOwner", sendOwnerCb);
sendOwnerPeriod->setIntervalFromNow(30 * 1000); // Send our initial owner announcement 30 seconds after we start (to give network time to setup) sendOwnerPeriod->setIntervalFromNow(30 * 1000); // Send our initial owner announcement 30 seconds after we start (to give network time to setup)
nodeDB.init(); // moved much earlier in boot (called from setup())
// nodeDB.init();
if (gps) if (gps)
gpsObserver.observe(&gps->newStatus); gpsObserver.observe(&gps->newStatus);

Wyświetl plik

@ -271,6 +271,9 @@ void NodeDB::init()
myNodeInfo.node_num_bits = sizeof(NodeNum) * 8; myNodeInfo.node_num_bits = sizeof(NodeNum) * 8;
myNodeInfo.packet_id_bits = sizeof(PacketId) * 8; myNodeInfo.packet_id_bits = sizeof(PacketId) * 8;
myNodeInfo.error_code = NoError; // For the error code, only show values from this boot (discard value from flash)
myNodeInfo.error_address = 0;
// likewise - we always want the app requirements to come from the running appload // likewise - we always want the app requirements to come from the running appload
myNodeInfo.min_app_version = 20120; // format is Mmmss (where M is 1+the numeric major number. i.e. 20120 means 1.1.20 myNodeInfo.min_app_version = 20120; // format is Mmmss (where M is 1+the numeric major number. i.e. 20120 means 1.1.20

Wyświetl plik

@ -18,10 +18,10 @@ bool BQ25713::setup()
if (!writeReg(0x00, 0x0F0A)) if (!writeReg(0x00, 0x0F0A))
return false; // Config Charge Option 0 return false; // Config Charge Option 0
if (!writeReg(0x02, 0x0224)) if (!writeReg(0x02, 0x0224)) // 512mA, FIXME, this seems to be setting a number of bits marked as reserved, why?
return false; // Config Charge Current return false; // Config Charge Current
if (!writeReg(0x04, 0x1070)) if (!writeReg(0x04, 0x1070)) // about 4.29V
return false; // Config Charge Voltage return false; // Config Charge Voltage
if (!writeReg(0x06, 0x099C)) if (!writeReg(0x06, 0x099C))
@ -32,7 +32,7 @@ bool BQ25713::setup()
// if(!writeReg(0x0A,0x0100)) return false;//Config Input Voltage // if(!writeReg(0x0A,0x0100)) return false;//Config Input Voltage
if (!writeReg(0x0C, 0x1800)) if (!writeReg(0x0C, 0x1800)) // 4.2Vish FIXME, we could lower this?
return false; // Config Minimum System Voltage return false; // Config Minimum System Voltage
if (!writeReg(0x0E, 0x4900)) if (!writeReg(0x0E, 0x4900))