-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support AU915 RP1 frequencies (#1939)
* test * Polish * Set data rate in OTAA AU915 program. * Renamed AU915RP1 to AU915. * Changed data rate in ABP AU915 Arduino program. * used DR5 for OTAA program + minor reformatting. * Add the missing files Co-authored-by: Ophelie Le Mentec <17216799+ouphi@users.noreply.github.com>
- Loading branch information
Showing
9 changed files
with
673 additions
and
4 deletions.
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
Arduino/AU915RP1/TransmissionTestABPLoRa/TransmissionTestABPLoRa.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
|
||
#include <LoRaWan.h> | ||
|
||
//set to true to send confirmed data up messages | ||
bool confirmed=true; | ||
//application information, should be similar to what was provisiionned in the device twins | ||
char * deviceId ="46AAC86800430028"; | ||
char * devAddr ="0228B1B1"; | ||
char * appSKey ="2B7E151628AED2A6ABF7158809CF4F3C"; | ||
char * nwkSKey ="3B7E151628AED2A6ABF7158809CF4F3C"; | ||
|
||
/* | ||
iot hub ABP desired properties for deviceid: 46AAC86800430028 | ||
"desired": { | ||
"AppSKey": "2B7E151628AED2A6ABF7158809CF4F3C", | ||
"NwkSKey": "3B7E151628AED2A6ABF7158809CF4F3C", | ||
"DevAddr": "0228B1B1", | ||
"GatewayID" :"", | ||
"SensorDecoder" :"DecoderValueSensor", | ||
*/ | ||
|
||
//set initial datarate and physical information for the device | ||
_data_rate_t dr=DR5; | ||
_physical_type_t physicalType=AU915; | ||
|
||
//internal variables | ||
char data[10]; | ||
char buffer[256]; | ||
int i=0; | ||
int lastCall=0; | ||
|
||
|
||
void setup(void) | ||
{ | ||
SerialUSB.begin(115200); | ||
while(!SerialUSB); | ||
lora.init(); | ||
|
||
lora.setId(devAddr, deviceId, NULL); | ||
lora.setKey(nwkSKey, appSKey, NULL); | ||
|
||
lora.setDeciveMode(LWABP); | ||
lora.setDataRate(dr, physicalType); | ||
|
||
lora.setAdaptiveDataRate(false); | ||
lora.setDutyCycle(false); | ||
lora.setJoinDutyCycle(false); | ||
|
||
// Disable Channels not used from the active channel list | ||
for (int i = 8 ; i < 71; i++) { | ||
lora.setChannelOFF(i); | ||
} | ||
|
||
lora.setPower(5); | ||
} | ||
|
||
void loop(void) | ||
{ | ||
if((millis()-lastCall)>5000){ | ||
lastCall=millis(); | ||
bool result = false; | ||
String packetString = ""; | ||
packetString=String(i); | ||
SerialUSB.println(packetString); | ||
packetString.toCharArray(data, 10); | ||
|
||
if(confirmed) | ||
result = lora.transferPacketWithConfirmed(data, 10); | ||
else | ||
result = lora.transferPacket(data, 10); | ||
i++; | ||
|
||
if(result) | ||
{ | ||
short length; | ||
short rssi; | ||
|
||
memset(buffer, 0, sizeof(buffer)); | ||
length = lora.receivePacket(buffer, sizeof(buffer), &rssi); | ||
|
||
if(length) | ||
{ | ||
SerialUSB.print("Length is: "); | ||
SerialUSB.println(length); | ||
SerialUSB.print("RSSI is: "); | ||
SerialUSB.println(rssi); | ||
SerialUSB.print("Data is: "); | ||
for(unsigned char i = 0; i < length; i ++) | ||
{ | ||
SerialUSB.print( char(buffer[i])); | ||
|
||
} | ||
SerialUSB.println(); | ||
} | ||
} | ||
} | ||
} |
101 changes: 101 additions & 0 deletions
101
Arduino/AU915RP1/TransmissionTestOTAALoRa/TransmissionTestOTAALoRa.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
|
||
#include <LoRaWan.h> | ||
//set to true to send confirmed data up messages | ||
bool confirmed=true; | ||
//application information, should be similar to what was provisiionned in the device twins | ||
char * deviceId ="47AAC86800430028"; | ||
char * appKey="8AFE71A145B253E49C3031AD068277A1"; | ||
char* appEui ="BE7A0000000014E2"; | ||
|
||
/* | ||
iot hub OTAA desired properties for deviceid: 47AAC86800430028 | ||
"desired": { | ||
"AppEUI": "BE7A0000000014E2", | ||
"AppKey": "8AFE71A145B253E49C3031AD068277A1", | ||
"GatewayID" :"", | ||
"SensorDecoder" :"DecoderValueSensor" | ||
}, | ||
*/ | ||
|
||
//set initial datarate and physical information for the device | ||
_data_rate_t dr=DR5; | ||
_physical_type_t physicalType=AU915; | ||
|
||
//internal variables | ||
char data[10]; | ||
char buffer[256]; | ||
int i=0; | ||
int lastCall=0; | ||
|
||
|
||
void setup(void) | ||
{ | ||
SerialUSB.begin(115200); | ||
while(!SerialUSB); | ||
lora.init(); | ||
lora.setId(NULL,deviceId , appEui); | ||
lora.setKey(NULL, NULL, appKey); | ||
|
||
lora.setDeciveMode(LWOTAA); | ||
lora.setDataRate(dr, physicalType); | ||
|
||
|
||
// Disable Channels not used from the active channel list | ||
for (int i = 8 ; i < 72; i++){ | ||
lora.setChannelOFF(i); | ||
} | ||
|
||
|
||
lora.setAdaptiveDataRate(false); | ||
|
||
lora.setDutyCycle(false); | ||
lora.setJoinDutyCycle(false); | ||
|
||
|
||
lora.setPower(5); | ||
lora.setDataRate(dr, physicalType); | ||
|
||
while(!lora.setOTAAJoin(JOIN,20000)); | ||
} | ||
|
||
void loop(void) | ||
{ | ||
if((millis()-lastCall)>5000){ | ||
lastCall=millis(); | ||
bool result = false; | ||
String packetString = ""; | ||
packetString=String(i); | ||
SerialUSB.println(packetString); | ||
packetString.toCharArray(data, 10); | ||
|
||
if(confirmed) | ||
result = lora.transferPacketWithConfirmed(data, 10); | ||
else | ||
result = lora.transferPacket(data, 10); | ||
i++; | ||
|
||
if(result) | ||
{ | ||
short length; | ||
short rssi; | ||
|
||
memset(buffer, 0, sizeof(buffer)); | ||
length = lora.receivePacket(buffer, sizeof(buffer), &rssi); | ||
|
||
if(length) | ||
{ | ||
SerialUSB.print("Length is: "); | ||
SerialUSB.println(length); | ||
SerialUSB.print("RSSI is: "); | ||
SerialUSB.println(rssi); | ||
SerialUSB.print("Data is: "); | ||
for(unsigned char i = 0; i < length; i ++) | ||
{ | ||
SerialUSB.print( char(buffer[i])); | ||
|
||
} | ||
SerialUSB.println(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
LoRaEngine/modules/LoRaWanNetworkSrvModule/LoraTools/Regions/RegionAU915RP1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace LoRaTools.Regions | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using LoRaTools.Utils; | ||
using LoRaWan; | ||
using static LoRaWan.DataRateIndex; | ||
using static LoRaWan.Metric; | ||
|
||
public class RegionAU915RP1 : Region | ||
{ | ||
private static readonly Hertz[] DownstreamChannelFrequencies = | ||
{ | ||
Mega(923.3), | ||
Mega(923.9), | ||
Mega(924.5), | ||
Mega(925.1), | ||
Mega(925.7), | ||
Mega(926.3), | ||
Mega(926.9), | ||
Mega(927.5) | ||
}; | ||
|
||
private static readonly ImmutableDictionary<DataRateIndex, (DataRate DataRate, uint MaxPayloadSize)> DrToConfigurationByDrIndex = | ||
new Dictionary<DataRateIndex, (DataRate DataRate, uint MaxPayloadSize)> | ||
{ | ||
[DR0] = (LoRaDataRate.SF12BW125, 59), | ||
[DR1] = (LoRaDataRate.SF11BW125, 59), | ||
[DR2] = (LoRaDataRate.SF10BW125, 59), | ||
[DR3] = (LoRaDataRate.SF9BW125, 123), | ||
[DR4] = (LoRaDataRate.SF8BW125, 230), | ||
[DR5] = (LoRaDataRate.SF7BW125, 230), | ||
[DR6] = (LoRaDataRate.SF8BW500, 230), | ||
[DR8] = (LoRaDataRate.SF12BW500, 41), | ||
[DR9] = (LoRaDataRate.SF11BW500, 117), | ||
[DR10] = (LoRaDataRate.SF10BW500, 230), | ||
[DR11] = (LoRaDataRate.SF9BW500, 230), | ||
[DR12] = (LoRaDataRate.SF8BW500, 230), | ||
[DR13] = (LoRaDataRate.SF7BW500, 230), | ||
}.ToImmutableDictionary(); | ||
|
||
public override IReadOnlyDictionary<DataRateIndex, (DataRate DataRate, uint MaxPayloadSize)> DRtoConfiguration => DrToConfigurationByDrIndex; | ||
|
||
private static readonly ImmutableDictionary<uint, double> MaxEirpByTxPower = | ||
new Dictionary<uint, double> | ||
{ | ||
[0] = 30, | ||
[1] = 29, | ||
[2] = 28, | ||
[3] = 27, | ||
[4] = 26, | ||
[5] = 25, | ||
[6] = 24, | ||
[7] = 23, | ||
[8] = 22, | ||
[9] = 21, | ||
[10] = 20, | ||
}.ToImmutableDictionary(); | ||
|
||
public override IReadOnlyDictionary<uint, double> TXPowertoMaxEIRP => MaxEirpByTxPower; | ||
|
||
private static readonly ImmutableArray<IReadOnlyList<DataRateIndex>> RX1DROffsetTableInternal = | ||
new IReadOnlyList<DataRateIndex>[] | ||
{ | ||
new[] { DR8, DR8, DR8, DR8, DR8, DR8 }.ToImmutableArray(), | ||
new[] { DR9, DR8, DR8, DR8, DR8, DR8 }.ToImmutableArray(), | ||
new[] { DR10, DR9, DR8, DR8, DR8, DR8 }.ToImmutableArray(), | ||
new[] { DR11, DR10, DR9, DR8, DR8, DR8 }.ToImmutableArray(), | ||
new[] { DR12, DR11, DR10, DR9, DR8, DR8 }.ToImmutableArray(), | ||
new[] { DR13, DR12, DR11, DR10, DR9, DR8 }.ToImmutableArray(), | ||
new[] { DR13, DR13, DR12, DR11, DR10, DR9 }.ToImmutableArray(), | ||
}.ToImmutableArray(); | ||
|
||
public override IReadOnlyList<IReadOnlyList<DataRateIndex>> RX1DROffsetTable => RX1DROffsetTableInternal; | ||
|
||
public RegionAU915RP1() | ||
: base(LoRaRegionType.US915) | ||
{ | ||
var upstreamValidDataranges = new HashSet<DataRate> | ||
{ | ||
LoRaDataRate.SF12BW125, // 0 | ||
LoRaDataRate.SF11BW125, // 1 | ||
LoRaDataRate.SF10BW125, // 2 | ||
LoRaDataRate.SF9BW125, // 3 | ||
LoRaDataRate.SF8BW125, // 4 | ||
LoRaDataRate.SF7BW125, // 5 | ||
LoRaDataRate.SF8BW500, // 6 | ||
}; | ||
|
||
var downstreamValidDataranges = new HashSet<DataRate> | ||
{ | ||
LoRaDataRate.SF12BW500, // 8 | ||
LoRaDataRate.SF11BW500, // 9 | ||
LoRaDataRate.SF10BW500, // 10 | ||
LoRaDataRate.SF9BW500, // 11 | ||
LoRaDataRate.SF8BW500, // 12 | ||
LoRaDataRate.SF7BW500 // 13 | ||
}; | ||
|
||
MaxADRDataRate = DR3; | ||
RegionLimits = new RegionLimits((Min: Mega(915.2), Max: Mega(927.8)), upstreamValidDataranges, downstreamValidDataranges, DR0, DR8); | ||
} | ||
|
||
/// <summary> | ||
/// Logic to get the correct downstream transmission frequency for region AU915. | ||
/// </summary> | ||
/// <param name="upstreamFrequency">Frequency on which the message was transmitted.</param> | ||
/// <param name="upstreamDataRate">Data rate at which the message was transmitted.</param> | ||
/// <param name="deviceJoinInfo">Join info for the device, if applicable.</param> | ||
public override bool TryGetDownstreamChannelFrequency(Hertz upstreamFrequency, DataRateIndex upstreamDataRate, DeviceJoinInfo deviceJoinInfo, out Hertz downstreamFrequency) | ||
{ | ||
if (!IsValidUpstreamFrequency(upstreamFrequency)) | ||
throw new LoRaProcessingException($"Invalid upstream frequency {upstreamFrequency}", LoRaProcessingErrorCode.InvalidFrequency); | ||
|
||
if (!IsValidUpstreamDataRate(upstreamDataRate)) | ||
throw new LoRaProcessingException($"Invalid upstream data rate {upstreamDataRate}", LoRaProcessingErrorCode.InvalidDataRate); | ||
|
||
int upstreamChannelNumber; | ||
upstreamChannelNumber = upstreamDataRate == DR6 ? 64 + (int)Math.Round((upstreamFrequency.InMega - 915.9) / 1.6, 0, MidpointRounding.AwayFromZero) | ||
: (int)Math.Round((upstreamFrequency.InMega - 915.2) / 0.2, 0, MidpointRounding.AwayFromZero); | ||
downstreamFrequency = DownstreamChannelFrequencies[upstreamChannelNumber % 8]; | ||
return true; | ||
} | ||
|
||
/// <summary> | ||
/// Returns the default RX2 receive window parameters - frequency and data rate. | ||
/// </summary> | ||
/// <param name="deviceJoinInfo">Join info for the device, if applicable.</param> | ||
public override ReceiveWindow GetDefaultRX2ReceiveWindow(DeviceJoinInfo deviceJoinInfo = null) => new ReceiveWindow(DR8, Mega(923.3)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.