Wireless interface using LoRa technology
Dependencies: AlohaTransceiver RingBuffer SX1276Lib_inAir SerialInterfaceProtocol mbed L3PDU
Diff: main.cpp
- Revision:
- 8:e30610bf6f79
- Parent:
- 4:9151697dfa70
- Child:
- 9:86d95e095bb0
--- a/main.cpp Wed Jul 27 03:43:13 2016 +0000 +++ b/main.cpp Wed Jul 27 04:38:00 2016 +0000 @@ -140,10 +140,10 @@ { if (isSet) { - uint32_t Bandwidth = (payload[4]) | - (payload[3] << 8) | - (payload[2] << 16) | - (payload[1] << 24); + uint32_t Bandwidth = (payload[5]) | + (payload[4] << 8) | + (payload[3] << 16) | + (payload[2] << 24); settings->Bandwidth = Bandwidth; return 0; @@ -161,14 +161,14 @@ } - case 0x02: // Daterate + case 0x02: // Datarate, AKA Spreading Factor { if (isSet) { - uint32_t Datarate = (payload[4]) | - (payload[3] << 8) | - (payload[2] << 16) | - (payload[1] << 24); + uint32_t Datarate = (payload[5]) | + (payload[4] << 8) | + (payload[3] << 16) | + (payload[2] << 24); settings->Datarate = Datarate; return 0; @@ -189,7 +189,7 @@ { if (isSet) { - uint8_t Coderate = payload[1]; + uint8_t Coderate = payload[2]; settings->Coderate = Coderate; return 0; @@ -203,10 +203,178 @@ } } + case 0x04: //Preamble Length + { + if (isSet) + { + uint16_t PreambleLen = payload[3] | (payload[2] << 8); + settings->PreambleLen = PreambleLen; + return 0; + } + else + { + response[1] = (uint8_t) (settings->PreambleLen); + response[0] = (uint8_t)(settings->PreambleLen >> 8); + *response_length = 2; + + return 0; + } + } + + case 0x05: //Symbol Timeout + { + if (isSet) + { + uint16_t SymbolTimeout = payload[3] | (payload[2] << 8); + settings->SymbolTimeout = SymbolTimeout; + return 0; + } + else + { + response[1] = (uint8_t) (settings->SymbolTimeout); + response[0] = (uint8_t) (settings->SymbolTimeout >> 8); + *response_length = 2; + + return 0; + } + } + + case 0x06: //FixLen + { + if (isSet) + { + bool FixLen = payload[2]; + settings->FixLen = FixLen; + return 0; + } + else + { + response[0] = (bool) (settings->SymbolTimeout); + *response_length = 1; + + return 0; + } + } + + case 0x07: //PayloadLen + { + if (isSet) + { + uint8_t PayloadLen = payload[2]; + settings->PayloadLen = PayloadLen; + return 0; + } + else + { + response[0] = (uint8_t) (settings->PayloadLen); + + return 0; + } + } + + case 0x08: //CrcOn + { + if (isSet) { + bool CrcOn = payload[2]; + settings->CrcOn = CrcOn; + return 0; + } + else + { + response[0] = (bool) (settings->CrcOn); + + return 0; + } + } + + case 0x09: //FreqHopOn + { + if (isSet) { + bool FreqHopOn = payload[2]; + settings->FreqHopOn = FreqHopOn; + return 0; + } + else + { + response[0] = (bool) (settings->FreqHopOn); + + return 0; + } + } + + case 0x0A: //HopPeriod + { + if (isSet) { + uint8_t HopPeriod = payload[2]; + settings->HopPeriod = HopPeriod; + return 0; + } + else + { + response[0] = (uint8_t) (settings->HopPeriod); + return 0; + } + } + + case 0x0B: //IqInverted + { + if (isSet) { + bool IqInverted = payload[2]; + settings->IqInverted = IqInverted; + return 0; + } + else + { + response[0] = (bool) (settings->IqInverted); + return 0; + } + } + + case 0x0C: //RxContinuous + { + if(isSet) + { + bool RxContinuous = payload[2]; + settings->RxContinuous = RxContinuous; + return 0; + } + else + { + response[0] = (bool) (settings->RxContinuous); + return 0; + } + } + + case 0x0D: //TxTimeout + { + if (isSet) + { + uint32_t TxTimeout = (payload[5]) | + (payload[4] << 8) | + (payload[3] << 16) | + (payload[2] << 24); + settings->TxTimeout = TxTimeout; + return 0; + } + else + { + response[3] = (uint8_t) (settings->TxTimeout); + response[2] = (uint8_t) (settings->TxTimeout >> 8); + response[1] = (uint8_t) (settings->TxTimeout >> 16); + response[0] = (uint8_t) (settings->TxTimeout >> 24); + *response_length = 4; + + return 0; + } + } + + default: { break; } + + //case }