mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-26 22:33:24 +00:00
Clean up, fix reboot, minimize changes
This commit is contained in:
parent
c3e3569c14
commit
a144d5d6cc
src
27
src/main.cpp
27
src/main.cpp
@ -67,8 +67,11 @@ NRF52Bluetooth *nrf52Bluetooth;
|
||||
#include "platform/portduino/SimRadio.h"
|
||||
#endif
|
||||
|
||||
#if defined(HAS_RADIO) && defined(ARCH_PORTDUINO)
|
||||
#ifdef ARCH_RASPBERRY_PI
|
||||
#include "platform/portduino/PiHal.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
#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()
|
||||
{
|
||||
uint8_t dmac[6];
|
||||
|
||||
getMacAddr(dmac);
|
||||
|
||||
// Meshtastic_ab3c or Shortname_abcd
|
||||
static char name[20];
|
||||
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);
|
||||
#else // HW_SPI1_DEVICE
|
||||
LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings);
|
||||
|
@ -56,6 +56,7 @@ extern graphics::Screen *screen;
|
||||
|
||||
// Return a human readable string of the form "Meshtastic_ab13"
|
||||
const char *getDeviceName();
|
||||
void getPiMacAddr(uint8_t *dmac);
|
||||
|
||||
extern uint32_t timeLastPowered;
|
||||
|
||||
|
@ -421,7 +421,11 @@ void NodeDB::init()
|
||||
*/
|
||||
void NodeDB::pickNewNodeNum()
|
||||
{
|
||||
#ifdef ARCH_RASPBERRY_PI
|
||||
getPiMacAddr(ourMacAddr); // Make sure ourMacAddr is set
|
||||
#else
|
||||
getMacAddr(ourMacAddr); // Make sure ourMacAddr is set
|
||||
#endif
|
||||
|
||||
// Pick an initial nodenum based on the macaddr
|
||||
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);
|
||||
nodeNum = candidate;
|
||||
}
|
||||
LOG_WARN("Using nodenum 0x%x \n", 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
|
||||
{
|
||||
LOG_DEBUG("Here to enable pin %d!\n", interruptNum);
|
||||
if (interruptNum == RADIOLIB_NC) {
|
||||
return;
|
||||
}
|
||||
@ -87,18 +86,15 @@ class PiHal : public RadioLibHal
|
||||
} else {
|
||||
gpioSetAlertFunc(interruptNum, (gpioISRFunc_t)interruptCb);
|
||||
}
|
||||
LOG_DEBUG("Pin enabled %d!\n", interruptNum);
|
||||
}
|
||||
|
||||
void detachInterrupt(uint32_t interruptNum) override
|
||||
{
|
||||
LOG_DEBUG("Here for pin %d!\n", interruptNum);
|
||||
if (interruptNum == RADIOLIB_NC) {
|
||||
return;
|
||||
}
|
||||
|
||||
gpioSetAlertFunc(interruptNum, NULL);
|
||||
LOG_DEBUG("Finished\n");
|
||||
}
|
||||
|
||||
void delay(unsigned long ms) override { gpioDelay(ms * 1000); }
|
||||
|
@ -7,13 +7,15 @@
|
||||
|
||||
#include <Utility.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef ARCH_RASPBERRY_PI
|
||||
#include "pigpio.h"
|
||||
|
||||
#else
|
||||
#include <linux/gpio/LinuxGPIOPin.h>
|
||||
#endif
|
||||
// FIXME - move setBluetoothEnable into a HALPlatform class
|
||||
|
||||
// FIXME - move setBluetoothEnable into a HALPlatform class
|
||||
void setBluetoothEnable(bool on)
|
||||
{
|
||||
// not needed
|
||||
@ -93,30 +95,9 @@ void portduinoSetup()
|
||||
|
||||
#ifdef ARCH_RASPBERRY_PI
|
||||
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
|
||||
|
||||
auto loraReset = new LinuxGPIOPin(LORA_RESET, GPIOD_CHIP_LABEL, LORA_RESET_LABEL, "loraReset");
|
||||
loraReset->setSilent();
|
||||
gpioBind(loraReset);
|
||||
|
||||
} else
|
||||
|
||||
#elif defined(PORTDUINO_LINUX_HARDWARE)
|
||||
#ifdef defined(PORTDUINO_LINUX_HARDWARE)
|
||||
SPI.begin(); // We need to create SPI
|
||||
bool usePineLora = !spiChip->isSimulated();
|
||||
if (usePineLora) {
|
||||
@ -157,8 +138,6 @@ void portduinoSetup()
|
||||
gpioBind(new SimGPIOPin(SX126X_RESET, "fakeLoraReset"));
|
||||
gpioBind(new SimGPIOPin(LORA_DIO1, "fakeLoraIrq"));
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
// gpioBind((new SimGPIOPin(LORA_RESET, "LORA_RESET")));
|
||||
// gpioBind((new SimGPIOPin(RF95_NSS, "RF95_NSS"))->setSilent());
|
||||
}
|
@ -14,6 +14,8 @@ void powerCommandsCheck()
|
||||
NVIC_SystemReset();
|
||||
#elif defined(ARCH_RP2040)
|
||||
rp2040.reboot();
|
||||
#elif defined(ARCH_RASPBERRY_PI)
|
||||
exit(EXIT_SUCCESS);
|
||||
#else
|
||||
rebootAtMsec = -1;
|
||||
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