diff --git a/include/esp32-lora.h b/include/esp32-lora.h index 81ee6de..9fc0b8f 100644 --- a/include/esp32-lora.h +++ b/include/esp32-lora.h @@ -77,7 +77,7 @@ #define EV_DIO0 (1 << 0) -#define ERR_LOR_ID_MISMATCH (00) +#define ERR_LOR_VERSION_MISMATCH (01) enum freq { F433, F866, F915 diff --git a/main/esp32-lora.c b/main/esp32-lora.c index 353dd2e..a52d7c6 100644 --- a/main/esp32-lora.c +++ b/main/esp32-lora.c @@ -463,7 +463,13 @@ uint8_t lora32_init(lora32_cfg_t *lora) { uint8_t version = lora32_read_reg(lora, REG_VERSION); ESP_LOGD(TAG, "lora32_get_id() == 0x%2X", version); - assert(version == 0x12); + + // if ID does not match, something is likely wrong on the SPI bus + if(version != 0x12) { + ESP_LOGD(TAG, "REG_VERSION returned incorrectly. Expected 0x12 got 0x%02X", version); + + return ERR_LOR_VERSION_MISMATCH; + } // TODO: confirm this is happening. Before/after power measurements? lora32_sleep(lora);