mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-15 23:32:34 +00:00
Initial stab at rak6421 autoconf
This commit is contained in:
@@ -10,12 +10,3 @@ Lora:
|
|||||||
DIO2_AS_RF_SWITCH: true
|
DIO2_AS_RF_SWITCH: true
|
||||||
spidev: spidev0.0
|
spidev: spidev0.0
|
||||||
# CS: 8
|
# CS: 8
|
||||||
|
|
||||||
|
|
||||||
### RAK13300in Slot 2 pins
|
|
||||||
# IRQ: 18 #IO6
|
|
||||||
# Reset: 24 # IO4
|
|
||||||
# Busy: 19 # IO5
|
|
||||||
# # Ant_sw: 23 # IO3
|
|
||||||
# spidev: spidev0.1
|
|
||||||
# # CS: 7
|
|
||||||
8
bin/config.d/lora-RAK6421-slot2.yaml
Normal file
8
bin/config.d/lora-RAK6421-slot2.yaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
Lora:
|
||||||
|
### RAK13300in Slot 2 pins
|
||||||
|
IRQ: 18 #IO6
|
||||||
|
Reset: 24 # IO4
|
||||||
|
Busy: 19 # IO5
|
||||||
|
# Ant_sw: 23 # IO3
|
||||||
|
spidev: spidev0.1
|
||||||
|
# CS: 7
|
||||||
@@ -225,7 +225,11 @@ NodeDB::NodeDB()
|
|||||||
memcpy(myNodeInfo.device_id.bytes + sizeof(device_id_start), &device_id_end, sizeof(device_id_end));
|
memcpy(myNodeInfo.device_id.bytes + sizeof(device_id_start), &device_id_end, sizeof(device_id_end));
|
||||||
myNodeInfo.device_id.size = 16;
|
myNodeInfo.device_id.size = 16;
|
||||||
// Uncomment below to print the device id
|
// Uncomment below to print the device id
|
||||||
|
#elif ARCH_PORTDUINO
|
||||||
|
if (portduino_config.has_device_id) {
|
||||||
|
memcpy(myNodeInfo.device_id.bytes, portduino_config.device_id, 16);
|
||||||
|
myNodeInfo.device_id.size = 16;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
// FIXME - implement for other platforms
|
// FIXME - implement for other platforms
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -264,6 +264,51 @@ void portduinoSetup()
|
|||||||
} else {
|
} else {
|
||||||
std::cout << "autoconf: Could not locate Pi HAT+ at /proc/device-tree/hat/product" << std::endl;
|
std::cout << "autoconf: Could not locate Pi HAT+ at /proc/device-tree/hat/product" << std::endl;
|
||||||
}
|
}
|
||||||
|
// attempt to load autoconf data from an EEPROM on 0x50
|
||||||
|
// RAK6421S1:aabbcc123456:5ba85807d92138b7519cfb60460573af
|
||||||
|
// <model string>:mac address :<16 random unique bytes in hexidecimal>
|
||||||
|
try {
|
||||||
|
char *mac_start = nullptr;
|
||||||
|
char *devID_start = nullptr;
|
||||||
|
Wire.begin();
|
||||||
|
Wire.beginTransmission(0x50);
|
||||||
|
Wire.write(0x0);
|
||||||
|
Wire.write(0x0);
|
||||||
|
Wire.endTransmission();
|
||||||
|
Wire.requestFrom((uint8_t)0x50, (uint8_t)75);
|
||||||
|
uint8_t i = 0;
|
||||||
|
delay(100);
|
||||||
|
while (Wire.available() && i < sizeof(autoconf_product)) {
|
||||||
|
autoconf_product[i] = Wire.read();
|
||||||
|
if (autoconf_product[i] == 0xff) {
|
||||||
|
autoconf_product[i] = 0x0;
|
||||||
|
break;
|
||||||
|
} else if (autoconf_product[i] == ':') {
|
||||||
|
autoconf_product[i] = 0x0;
|
||||||
|
if (mac_start == nullptr) {
|
||||||
|
mac_start = autoconf_product + i + 1;
|
||||||
|
} else if (devID_start == nullptr) {
|
||||||
|
devID_start = autoconf_product + i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
std::cout << "autoconf: Found eeprom data " << autoconf_product << std::endl;
|
||||||
|
std::cout << "autoconf: Found mac data " << mac_start << std::endl;
|
||||||
|
std::cout << "autoconf: Found deviceid data " << devID_start << std::endl;
|
||||||
|
if (strlen(mac_start) == 12)
|
||||||
|
settingsStrings[mac_address] = std::string(mac_start);
|
||||||
|
if (strlen(devID_start) == 32) {
|
||||||
|
std::string devID_str(devID_start);
|
||||||
|
for (int j = 0; j < 16; j++) {
|
||||||
|
portduino_config.device_id[j] = std::stoi(devID_str.substr(j*2, 2), nullptr, 16);
|
||||||
|
}
|
||||||
|
portduino_config.has_device_id = true;
|
||||||
|
}
|
||||||
|
} catch (...) {
|
||||||
|
std::cout << "autoconf: Could not locate EEPROM" << std::endl;
|
||||||
|
}
|
||||||
// Load the config file based on the product string
|
// Load the config file based on the product string
|
||||||
if (strlen(autoconf_product) > 0) {
|
if (strlen(autoconf_product) > 0) {
|
||||||
// From configProducts map in PortduinoGlue.h
|
// From configProducts map in PortduinoGlue.h
|
||||||
|
|||||||
@@ -10,11 +10,11 @@
|
|||||||
// Product strings for auto-configuration
|
// Product strings for auto-configuration
|
||||||
// {"PRODUCT_STRING", "CONFIG.YAML"}
|
// {"PRODUCT_STRING", "CONFIG.YAML"}
|
||||||
// YAML paths are relative to `meshtastic/available.d`
|
// YAML paths are relative to `meshtastic/available.d`
|
||||||
inline const std::unordered_map<std::string, std::string> configProducts = {{"MESHTOAD", "lora-usb-meshtoad-e22.yaml"},
|
inline const std::unordered_map<std::string, std::string> configProducts = {
|
||||||
{"MESHSTICK", "lora-meshstick-1262.yaml"},
|
{"MESHTOAD", "lora-usb-meshtoad-e22.yaml"}, {"MESHSTICK", "lora-meshstick-1262.yaml"},
|
||||||
{"MESHADV-PI", "lora-MeshAdv-900M30S.yaml"},
|
{"MESHADV-PI", "lora-MeshAdv-900M30S.yaml"}, {"MeshAdv Mini", "lora-MeshAdv-Mini-900M22S.yaml"},
|
||||||
{"MeshAdv Mini", "lora-MeshAdv-Mini-900M22S.yaml"},
|
{"POWERPI", "lora-MeshAdv-900M30S.yaml"}, {"RAK6421S1", "lora-RAK6421-slot1.yaml"},
|
||||||
{"POWERPI", "lora-MeshAdv-900M30S.yaml"}};
|
{"RAK6421S2", "lora-RAK6421-slot2.yaml"}};
|
||||||
|
|
||||||
enum configNames {
|
enum configNames {
|
||||||
default_gpiochip,
|
default_gpiochip,
|
||||||
@@ -135,4 +135,6 @@ extern struct portduino_config_struct {
|
|||||||
uint32_t rfswitch_dio_pins[5] = {RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC};
|
uint32_t rfswitch_dio_pins[5] = {RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC};
|
||||||
Module::RfSwitchMode_t rfswitch_table[8];
|
Module::RfSwitchMode_t rfswitch_table[8];
|
||||||
bool force_simradio = false;
|
bool force_simradio = false;
|
||||||
|
bool has_device_id = false;
|
||||||
|
uint8_t device_id[16] = {0};
|
||||||
} portduino_config;
|
} portduino_config;
|
||||||
Reference in New Issue
Block a user