mirror of
https://github.com/meshtastic/firmware.git
synced 2025-10-02 13:44:16 +00:00
Clean up, fix reboot, minimize changes
This commit is contained in:
parent
c3e3569c14
commit
a144d5d6cc
27
src/main.cpp
27
src/main.cpp
@ -67,8 +67,11 @@ NRF52Bluetooth *nrf52Bluetooth;
|
|||||||
#include "platform/portduino/SimRadio.h"
|
#include "platform/portduino/SimRadio.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAS_RADIO) && defined(ARCH_PORTDUINO)
|
#ifdef ARCH_RASPBERRY_PI
|
||||||
#include "platform/portduino/PiHal.h"
|
#include "platform/portduino/PiHal.h"
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAS_BUTTON
|
#if HAS_BUTTON
|
||||||
@ -132,12 +135,28 @@ std::pair<uint8_t, TwoWire *> nodeTelemetrySensorsMap[_meshtastic_TelemetrySenso
|
|||||||
|
|
||||||
Router *router = NULL; // Users of router don't care what sort of subclass implements that API
|
Router *router = NULL; // Users of router don't care what sort of subclass implements that API
|
||||||
|
|
||||||
|
#ifdef ARCH_RASPBERRY_PI
|
||||||
|
void getPiMacAddr(uint8_t *dmac)
|
||||||
|
{
|
||||||
|
std::fstream macIdentity;
|
||||||
|
macIdentity.open("/sys/kernel/debug/bluetooth/hci0/identity", std::ios::in);
|
||||||
|
std::string macLine;
|
||||||
|
getline(macIdentity, macLine);
|
||||||
|
macIdentity.close();
|
||||||
|
|
||||||
|
dmac[0] = strtol(macLine.substr(0, 2).c_str(), NULL, 16);
|
||||||
|
dmac[1] = strtol(macLine.substr(3, 2).c_str(), NULL, 16);
|
||||||
|
dmac[2] = strtol(macLine.substr(6, 2).c_str(), NULL, 16);
|
||||||
|
dmac[3] = strtol(macLine.substr(9, 2).c_str(), NULL, 16);
|
||||||
|
dmac[4] = strtol(macLine.substr(12, 2).c_str(), NULL, 16);
|
||||||
|
dmac[5] = strtol(macLine.substr(15, 2).c_str(), NULL, 16);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
const char *getDeviceName()
|
const char *getDeviceName()
|
||||||
{
|
{
|
||||||
uint8_t dmac[6];
|
uint8_t dmac[6];
|
||||||
|
|
||||||
getMacAddr(dmac);
|
|
||||||
|
|
||||||
// Meshtastic_ab3c or Shortname_abcd
|
// Meshtastic_ab3c or Shortname_abcd
|
||||||
static char name[20];
|
static char name[20];
|
||||||
snprintf(name, sizeof(name), "%02x%02x", dmac[4], dmac[5]);
|
snprintf(name, sizeof(name), "%02x%02x", dmac[4], dmac[5]);
|
||||||
@ -679,7 +698,7 @@ void setup()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif HW_SPI1_DEVICE
|
#elif defined(HW_SPI1_DEVICE)
|
||||||
LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI1, spiSettings);
|
LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI1, spiSettings);
|
||||||
#else // HW_SPI1_DEVICE
|
#else // HW_SPI1_DEVICE
|
||||||
LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings);
|
LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings);
|
||||||
|
@ -56,6 +56,7 @@ extern graphics::Screen *screen;
|
|||||||
|
|
||||||
// Return a human readable string of the form "Meshtastic_ab13"
|
// Return a human readable string of the form "Meshtastic_ab13"
|
||||||
const char *getDeviceName();
|
const char *getDeviceName();
|
||||||
|
void getPiMacAddr(uint8_t *dmac);
|
||||||
|
|
||||||
extern uint32_t timeLastPowered;
|
extern uint32_t timeLastPowered;
|
||||||
|
|
||||||
|
@ -421,7 +421,11 @@ void NodeDB::init()
|
|||||||
*/
|
*/
|
||||||
void NodeDB::pickNewNodeNum()
|
void NodeDB::pickNewNodeNum()
|
||||||
{
|
{
|
||||||
|
#ifdef ARCH_RASPBERRY_PI
|
||||||
|
getPiMacAddr(ourMacAddr); // Make sure ourMacAddr is set
|
||||||
|
#else
|
||||||
getMacAddr(ourMacAddr); // Make sure ourMacAddr is set
|
getMacAddr(ourMacAddr); // Make sure ourMacAddr is set
|
||||||
|
#endif
|
||||||
|
|
||||||
// Pick an initial nodenum based on the macaddr
|
// Pick an initial nodenum based on the macaddr
|
||||||
NodeNum nodeNum = (ourMacAddr[2] << 24) | (ourMacAddr[3] << 16) | (ourMacAddr[4] << 8) | ourMacAddr[5];
|
NodeNum nodeNum = (ourMacAddr[2] << 24) | (ourMacAddr[3] << 16) | (ourMacAddr[4] << 8) | ourMacAddr[5];
|
||||||
@ -433,6 +437,7 @@ void NodeDB::pickNewNodeNum()
|
|||||||
LOG_WARN("NOTE! Our desired nodenum 0x%x is invalid or in use, so trying for 0x%x\n", nodeNum, candidate);
|
LOG_WARN("NOTE! Our desired nodenum 0x%x is invalid or in use, so trying for 0x%x\n", nodeNum, candidate);
|
||||||
nodeNum = candidate;
|
nodeNum = candidate;
|
||||||
}
|
}
|
||||||
|
LOG_WARN("Using nodenum 0x%x \n", nodeNum);
|
||||||
|
|
||||||
myNodeInfo.my_node_num = nodeNum;
|
myNodeInfo.my_node_num = nodeNum;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,6 @@ class PiHal : public RadioLibHal
|
|||||||
|
|
||||||
void attachInterrupt(uint32_t interruptNum, void (*interruptCb)(void), uint32_t mode) override
|
void attachInterrupt(uint32_t interruptNum, void (*interruptCb)(void), uint32_t mode) override
|
||||||
{
|
{
|
||||||
LOG_DEBUG("Here to enable pin %d!\n", interruptNum);
|
|
||||||
if (interruptNum == RADIOLIB_NC) {
|
if (interruptNum == RADIOLIB_NC) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -87,18 +86,15 @@ class PiHal : public RadioLibHal
|
|||||||
} else {
|
} else {
|
||||||
gpioSetAlertFunc(interruptNum, (gpioISRFunc_t)interruptCb);
|
gpioSetAlertFunc(interruptNum, (gpioISRFunc_t)interruptCb);
|
||||||
}
|
}
|
||||||
LOG_DEBUG("Pin enabled %d!\n", interruptNum);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void detachInterrupt(uint32_t interruptNum) override
|
void detachInterrupt(uint32_t interruptNum) override
|
||||||
{
|
{
|
||||||
LOG_DEBUG("Here for pin %d!\n", interruptNum);
|
|
||||||
if (interruptNum == RADIOLIB_NC) {
|
if (interruptNum == RADIOLIB_NC) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gpioSetAlertFunc(interruptNum, NULL);
|
gpioSetAlertFunc(interruptNum, NULL);
|
||||||
LOG_DEBUG("Finished\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void delay(unsigned long ms) override { gpioDelay(ms * 1000); }
|
void delay(unsigned long ms) override { gpioDelay(ms * 1000); }
|
||||||
|
@ -7,13 +7,15 @@
|
|||||||
|
|
||||||
#include <Utility.h>
|
#include <Utility.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#ifdef ARCH_RASPBERRY_PI
|
#ifdef ARCH_RASPBERRY_PI
|
||||||
#include "pigpio.h"
|
#include "pigpio.h"
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#include <linux/gpio/LinuxGPIOPin.h>
|
#include <linux/gpio/LinuxGPIOPin.h>
|
||||||
#endif
|
#endif
|
||||||
// FIXME - move setBluetoothEnable into a HALPlatform class
|
|
||||||
|
|
||||||
|
// FIXME - move setBluetoothEnable into a HALPlatform class
|
||||||
void setBluetoothEnable(bool on)
|
void setBluetoothEnable(bool on)
|
||||||
{
|
{
|
||||||
// not needed
|
// not needed
|
||||||
@ -93,30 +95,9 @@ void portduinoSetup()
|
|||||||
|
|
||||||
#ifdef ARCH_RASPBERRY_PI
|
#ifdef ARCH_RASPBERRY_PI
|
||||||
return;
|
return;
|
||||||
/*
|
|
||||||
//printf("using GPIOD Version: %s\n", gpiod_version_string());
|
|
||||||
gpioInitialise();
|
|
||||||
// We need to create SPI
|
|
||||||
SPI.begin();
|
|
||||||
if (!spiChip->isSimulated()) {
|
|
||||||
printf("Connecting to RFM95 board...\n");
|
|
||||||
loraIrq = new LinuxGPIOPin(LORA_DIO0, "gpiochip0", LORA_DIO0_LABEL, "loraIrq");
|
|
||||||
loraIrq->setSilent();
|
|
||||||
gpioBind(loraIrq);
|
|
||||||
|
|
||||||
#if (RF95_NSS != RADIOLIB_NC)
|
|
||||||
auto loraCs = new LinuxGPIOPin(RF95_NSS, GPIOD_CHIP_LABEL, RF95_NSS_LABEL, "loraCs");
|
|
||||||
loraCs->setSilent();
|
|
||||||
gpioBind(loraCs);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto loraReset = new LinuxGPIOPin(LORA_RESET, GPIOD_CHIP_LABEL, LORA_RESET_LABEL, "loraReset");
|
#ifdef defined(PORTDUINO_LINUX_HARDWARE)
|
||||||
loraReset->setSilent();
|
|
||||||
gpioBind(loraReset);
|
|
||||||
|
|
||||||
} else
|
|
||||||
|
|
||||||
#elif defined(PORTDUINO_LINUX_HARDWARE)
|
|
||||||
SPI.begin(); // We need to create SPI
|
SPI.begin(); // We need to create SPI
|
||||||
bool usePineLora = !spiChip->isSimulated();
|
bool usePineLora = !spiChip->isSimulated();
|
||||||
if (usePineLora) {
|
if (usePineLora) {
|
||||||
@ -157,8 +138,6 @@ void portduinoSetup()
|
|||||||
gpioBind(new SimGPIOPin(SX126X_RESET, "fakeLoraReset"));
|
gpioBind(new SimGPIOPin(SX126X_RESET, "fakeLoraReset"));
|
||||||
gpioBind(new SimGPIOPin(LORA_DIO1, "fakeLoraIrq"));
|
gpioBind(new SimGPIOPin(LORA_DIO1, "fakeLoraIrq"));
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
#endif
|
|
||||||
// gpioBind((new SimGPIOPin(LORA_RESET, "LORA_RESET")));
|
// gpioBind((new SimGPIOPin(LORA_RESET, "LORA_RESET")));
|
||||||
// gpioBind((new SimGPIOPin(RF95_NSS, "RF95_NSS"))->setSilent());
|
// gpioBind((new SimGPIOPin(RF95_NSS, "RF95_NSS"))->setSilent());
|
||||||
}
|
}
|
@ -14,6 +14,8 @@ void powerCommandsCheck()
|
|||||||
NVIC_SystemReset();
|
NVIC_SystemReset();
|
||||||
#elif defined(ARCH_RP2040)
|
#elif defined(ARCH_RP2040)
|
||||||
rp2040.reboot();
|
rp2040.reboot();
|
||||||
|
#elif defined(ARCH_RASPBERRY_PI)
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
#else
|
#else
|
||||||
rebootAtMsec = -1;
|
rebootAtMsec = -1;
|
||||||
LOG_WARN("FIXME implement reboot for this platform. Note that some settings require a restart to be applied.\n");
|
LOG_WARN("FIXME implement reboot for this platform. Note that some settings require a restart to be applied.\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user