From b9754f8f003f7f4bdbcae4373cec09d311e78c1f Mon Sep 17 00:00:00 2001 From: root Date: Sat, 7 Dec 2024 14:40:39 +0100 Subject: [PATCH] 1PMG3 fixes --- src/ShellyPlus1PM/shelly_init.cpp | 4 ++-- src/shelly_main.cpp | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ShellyPlus1PM/shelly_init.cpp b/src/ShellyPlus1PM/shelly_init.cpp index 77a5ce6e..462c55af 100644 --- a/src/ShellyPlus1PM/shelly_init.cpp +++ b/src/ShellyPlus1PM/shelly_init.cpp @@ -102,12 +102,12 @@ void CreatePeripherals(std::vector> *inputs, LOG(LL_ERROR, ("PM init failed: %s", s.c_str())); } #else - //init for BL0942 on Gen3 here TODO + // init for BL0942 on Gen3 here TODO #endif sys_temp->reset(new TempSensorSDNT1608X103F3950(ADC_GPIO, 3.3f, 10000.0f)); int pin_out = ADDON_OUT_GPIO; - int pin_in = ADDON:IN_GPIO; + int pin_in = ADDON_IN_GPIO; if (DetectAddon(pin_in, pin_out)) { s_onewire.reset(new Onewire(pin_in, pin_out)); diff --git a/src/shelly_main.cpp b/src/shelly_main.cpp index 79534c57..968190fd 100644 --- a/src/shelly_main.cpp +++ b/src/shelly_main.cpp @@ -132,6 +132,9 @@ void RestoreUART() { } bool DetectAddon(int pin_in, int pin_out) { + if (pin_in == -1 || pin_out == -1) { + return false; + } // case 1: input with pull up mgos_gpio_setup_input(pin_in, MGOS_GPIO_PULL_UP); // check if pulled by something external, not check output to input yet