These instructions are for customizing the following project: https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-lorawan/
Once you've imported it, then grab the sample mbed_app.json
config file for your radio in the config/
folder and move it to mbed_app.json
in the project root.
Edit it as follows:
Update the target_overrides
catch-all ("*"
) section with your device info from TTN:
"target_overrides": {
"*": {
"platform.stdio-convert-newlines": true,
"platform.stdio-baud-rate": 115200,
"platform.default-serial-baud-rate": 115200,
"lora.over-the-air-activation": true,
"lora.duty-cycle-on": true,
"mbed-trace.enable": true,
"lora.phy": "US915",
"lora.fsb-mask": "{ 0xFF00, 0x0000, 0x0000, 0x0000, 0x0002 }",
"lora.device-eui": "{ 0x00, 0x35, 0x07, 0x25, 0x67, 0x09, 0x16, 0x45 }",
"lora.application-eui": "{ 0x70, 0xB3, 0xD5, 0x70, 0xD0, 0x02, 0xE4, 0x23 }",
"lora.application-key": "{ 0x1F, 0x46, 0xBD, 0x2F, 0x86, 0x6D, 0xD6, 0x88, 0xC3, 0x99, 0x6D, 0x1A, 0xAF, 0x86, 0x6E, 0x9E }",
"lora.appskey": "{ 0xCA, 0x9B, 0x50, 0xB1, 0x5C, 0x8E, 0xF9, 0x7B, 0x62, 0x32, 0xB2, 0x6A, 0xB0, 0x09, 0xAD, 0x0A }",
"lora.nwkskey": "{ 0xB9, 0x76, 0x1E, 0x36, 0x3A, 0x5A, 0xA9, 0xE5, 0xB3, 0x33, 0xBE, 0x03, 0x76, 0x8B, 0xCA, 0x8F }",
"lora.device-address": "0x2632488"
},
In particular, note the following lines for configuring the radio for Canada:
"lora.phy": "US915",
"lora.fsb-mask": "{ 0xFF00, 0x0000, 0x0000, 0x0000, 0x0002 }",
The lora.nwkskey
, lora.appskey
and lora.device-address
are only need if you want ABP mode. If you do, you also need to set lora.over-the-air-activation: false
.
Then, depending on your device, add a section directly below the catch-all ("*"
) for the NRF52_DK
for your LoRa radio.
If you're using the SX1262 use the following pins:
"NRF52_DK": {
"lora-spi-mosi": "D11",
"lora-spi-miso": "D12",
"lora-spi-sclk": "D13",
"lora-cs": "D7",
"lora-reset": "A0",
"lora-dio1": "D5",
"lora-busy": "D3",
"lora-freq-sel": "A1",
"lora-dev-sel": "A2",
"lora-xtal-sel": "A3",
"lora-ant-switch": "D8"
},
And if you're using the SX1272 then:
"NRF52_DK": {
"lora-spi-mosi": "D11",
"lora-spi-miso": "D12",
"lora-spi-sclk": "D13",
"lora-cs": "D10",
"lora-reset": "A0",
"lora-dio0": "D2",
"lora-dio1": "D3",
"lora-dio2": "D4",
"lora-dio3": "D5",
"lora-dio4": "A3",
"lora-dio5": "D9",
"lora-rf-switch-ctl1": "NC",
"lora-rf-switch-ctl2": "NC",
"lora-txctl": "NC",
"lora-rxctl": "NC",
"lora-ant-switch": "A4",
"lora-pwr-amp-ctl": "NC",
"lora-tcxo": "NC"
},
Note: I'm not entirely convinced I've got this pin configuration entirely correct. Packets are sent and received by TTN but they arrive irregularly (more than the SX1262) and often only 1 or 2 rather than continuous. I just read https://os.mbed.com/components/SX1276MB1xAS/ and made it up from there.