remove assert(REG_VERSION) in favor of returning error so application recovery is possible

This commit is contained in:
Morgan 'ARR\!' Allen 2021-11-17 19:28:46 -08:00
parent 7141d87680
commit dc78e9b137
2 changed files with 8 additions and 2 deletions

View file

@ -77,7 +77,7 @@
#define EV_DIO0 (1 << 0) #define EV_DIO0 (1 << 0)
#define ERR_LOR_ID_MISMATCH (00) #define ERR_LOR_VERSION_MISMATCH (01)
enum freq { enum freq {
F433, F866, F915 F433, F866, F915

View file

@ -463,7 +463,13 @@ uint8_t lora32_init(lora32_cfg_t *lora) {
uint8_t version = lora32_read_reg(lora, REG_VERSION); uint8_t version = lora32_read_reg(lora, REG_VERSION);
ESP_LOGD(TAG, "lora32_get_id() == 0x%2X", 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? // TODO: confirm this is happening. Before/after power measurements?
lora32_sleep(lora); lora32_sleep(lora);