Terminal for sending and receiving data via Semtech SX1276 chip. It uses the FRDM-KL25Z board, with a Modtronix inAir9 SX1276 board, and Modtronix SHD3I shield. The inAir9 module is mounted in iMod port 3 of the SHD3I module. The SHD3I shield is mounted on the FRDM-KL25Z board.
Dependencies: SX127x_modtronix mbed
Fork of chat_sx127x by
Diff: main.cpp
- Revision:
- 4:7a9007dfc0e5
- Parent:
- 3:ab386fa756cc
- Child:
- 5:d6e7fb9446ff
--- a/main.cpp Fri May 02 23:35:43 2014 +0000 +++ b/main.cpp Tue May 20 17:18:47 2014 +0000 @@ -390,8 +390,7 @@ printf("SymbTimeout:0x%03x ", radio.read_u16(REG_LR_MODEMCONFIG2) & 0x3ff); lora.RegPreamble = radio.read_u16(REG_LR_PREAMBLEMSB); - printf("PreambleLength:0x%03x ", lora.RegPreamble); - + printf("PreambleLength:%d ", lora.RegPreamble); if (radio.RegOpMode.bits.Mode == RF_OPMODE_RECEIVER || radio.RegOpMode.bits.Mode == RF_OPMODE_RECEIVER_SINGLE) { d = radio.read_reg(REG_LR_RSSIVALUE); @@ -889,6 +888,7 @@ service_action_e act; if (radio.RegOpMode.bits.LongRangeMode) { + act = lora.service(); switch (act) { @@ -996,8 +996,9 @@ buf[i++] = c; pc.putc(c); } - } else + } else { service_radio(); + } } // ...for() } @@ -1426,12 +1427,21 @@ radio.set_frf_MHz(MHz); } printf("%fMHz\r\n", radio.get_frf_MHz()); - } else if (pcbuf[0] == 'p' && pcbuf[1] == 'r' && pcbuf[2] == 'e' && !radio.RegOpMode.bits.LongRangeMode) { - if (pcbuf[3] >= '0' && pcbuf[3] <= '9') { - sscanf(pcbuf+3, "%d", &i); - radio.write_u16(REG_FSK_PREAMBLEMSB, i); + } else if (pcbuf[0] == 'p' && pcbuf[1] == 'r' && pcbuf[2] == 'e') { + if (radio.RegOpMode.bits.LongRangeMode) { + if (pcbuf[3] >= '0' && pcbuf[3] <= '9') { + sscanf(pcbuf+3, "%d", &i); + radio.write_u16(REG_LR_PREAMBLEMSB, i); + } + lora.RegPreamble = radio.read_u16(REG_LR_PREAMBLEMSB); + printf("lora PreambleLength:%d\r\n", lora.RegPreamble); + } else { + if (pcbuf[3] >= '0' && pcbuf[3] <= '9') { + sscanf(pcbuf+3, "%d", &i); + radio.write_u16(REG_FSK_PREAMBLEMSB, i); + } + printf("FSK TX PreambleSize:%d\r\n", radio.read_u16(REG_FSK_PREAMBLEMSB)); } - printf("FSK TX PreambleSize:%d ", radio.read_u16(REG_FSK_PREAMBLEMSB)); } else if (pcbuf[0] == 'p' && pcbuf[1] == 't' && !radio.RegOpMode.bits.LongRangeMode) { if (pcbuf[2] >= '0' && pcbuf[2] <= '9') { sscanf(pcbuf+2, "%d", &i);