diff --git a/src/display.cpp b/src/display.cpp index 6ec11071..ec187da4 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -11,11 +11,11 @@ HAS_DISPLAY u8x8(MY_OLED_RST, MY_OLED_SCL, MY_OLED_SDA); const char lora_datarate[] = {"1211100908077BFSNA"}; #elif defined(CFG_us915) const char lora_datarate[] = {"100908078CNA121110090807"}; -#if defined(CFG_as923) +#elif defined(CFG_as923) const char lora_datarate[] = {"1211100908077BFSNA"}; -#if defined(CFG_au921) +#elif defined(CFG_au921) const char lora_datarate[] = {"1211100908078CNA1211109C8C7C"}; -#if defined(CFG_in866) +#elif defined(CFG_in866) const char lora_datarate[] = {"121110090807FSNA"}; #endif diff --git a/src/lorawan.cpp b/src/lorawan.cpp index 9cc871e2..acb40438 100644 --- a/src/lorawan.cpp +++ b/src/lorawan.cpp @@ -112,7 +112,7 @@ void get_hard_deveui(uint8_t *pdeveui) { uint8_t i2c_ret; // Init this just in case, no more to 100KHz - Wire.begin(SDA, SCL, 100000); + Wire.begin(MY_OLED_SDA, MY_OLED_SCL, 100000); Wire.beginTransmission(MCP_24AA02E64_I2C_ADDRESS); Wire.write(MCP_24AA02E64_MAC_ADDRESS); i2c_ret = Wire.endTransmission(); @@ -249,7 +249,8 @@ void onEvent(ev_t ev) { break; case EV_TXSTART: - strcpy_P(buff, PSTR("TX START")); + if (!(LMIC.opmode & OP_JOINING)) + strcpy_P(buff, PSTR("TX START")); break; /* @@ -341,7 +342,7 @@ void lora_send(osjob_t *job) { LMIC_setTxData2(SendBuffer.MessagePort, SendBuffer.Message, SendBuffer.MessageSize, (cfg.countermode & 0x02)); ESP_LOGI(TAG, "%d bytes sent to LoRa", SendBuffer.MessageSize); - //sprintf(display_line7, "PACKET QUEUED"); + // sprintf(display_line7, "PACKET QUEUED"); } } // reschedule job every 0,5 - 1 sec. including a bit of random to prevent diff --git a/src/main.cpp b/src/main.cpp index 14c03811..9f7dbde3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -166,7 +166,21 @@ void setup() { ESP_LOGI(TAG, "Starting LMIC..."); os_init(); // initialize lmic run-time environment on core 1 LMIC_reset(); // initialize lmic MAC + LMIC_setLinkCheckMode(0); LMIC_setClockError(MAX_CLOCK_ERROR * CLOCK_ERROR_PROCENTAGE / 100); + +#ifdef CFG_US915 + // Set the data rate to Spreading Factor 7. This is the fastest supported + // rate for 125 kHz channels, and it minimizes air time and battery power. Set + // the transmission power to 14 dBi (25 mW). + LMIC_setDrTxpow(DR_SF7, 14); + // in the US, with TTN, it saves join time if we start on subband 1 (channels + // 8-15). This will get overridden after the join by parameters from the + // network. If working with other networks or in other regions, this will need + // to be changed. + LMIC_selectSubBand(1); +#endif + LMIC_startJoining(); // start joining #endif