Skip to content

Commit 96610a6

Browse files
kjbraceyAntti Kauppila
authored andcommitted
LoRa: Improved region macro handling
1 parent 1a86bb3 commit 96610a6

File tree

1 file changed

+43
-21
lines changed

1 file changed

+43
-21
lines changed

features/lorawan/lorastack/phy/loraphy_target.h

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,48 +18,70 @@
1818
#ifndef LORAPHY_TARGET
1919
#define LORAPHY_TARGET
2020

21-
#define EU868 0
22-
#define AS923 1
23-
#define AU915 2
24-
#define CN470 3
25-
#define CN779 4
26-
#define EU433 5
27-
#define IN865 6
28-
#define KR920 7
29-
#define US915 8
30-
#define US915_HYBRID 9
31-
3221
#ifdef MBED_CONF_LORA_PHY
33-
#if MBED_CONF_LORA_PHY == EU868
22+
23+
#define LORA_REGION_EU868 0x10
24+
#define LORA_REGION_AS923 0x11
25+
#define LORA_REGION_AU915 0x12
26+
#define LORA_REGION_CN470 0x13
27+
#define LORA_REGION_CN779 0x14
28+
#define LORA_REGION_EU433 0x15
29+
#define LORA_REGION_IN865 0x16
30+
#define LORA_REGION_KR920 0x17
31+
#define LORA_REGION_US915 0x18
32+
#define LORA_REGION_US915_HYBRID 0x19
33+
34+
//DO NOT USE integer values in mbed_app.json!
35+
//These are defined for backward compatibility and
36+
//Will be DEPRECATED in the future
37+
#define LORA_REGION_0 0x10
38+
#define LORA_REGION_1 0x11
39+
#define LORA_REGION_2 0x12
40+
#define LORA_REGION_3 0x13
41+
#define LORA_REGION_4 0x14
42+
#define LORA_REGION_5 0x15
43+
#define LORA_REGION_6 0x16
44+
#define LORA_REGION_7 0x17
45+
#define LORA_REGION_8 0x18
46+
#define LORA_REGION_9 0x19
47+
48+
//Since 0 would be equal to any undefined value we need to handle this in a other way
49+
#define mbed_lora_concat_(x) LORA_REGION_##x
50+
#define mbed_lora_concat(x) mbed_lora_concat_(x)
51+
#define LORA_REGION mbed_lora_concat(MBED_CONF_LORA_PHY)
52+
53+
#if LORA_REGION == LORA_REGION_EU868
3454
#include "lorawan/lorastack/phy/LoRaPHYEU868.h"
3555
#define LoRaPHY_region LoRaPHYEU868
36-
#elif MBED_CONF_LORA_PHY == AS923
56+
#elif LORA_REGION == LORA_REGION_AS923
3757
#include "lorawan/lorastack/phy/LoRaPHYAS923.h"
3858
#define LoRaPHY_region LoRaPHYAS923
39-
#elif MBED_CONF_LORA_PHY == AU915
59+
#elif LORA_REGION == LORA_REGION_AU915
4060
#include "lorawan/lorastack/phy/LoRaPHYAU915.h"
4161
#define LoRaPHY_region LoRaPHYAU915;
42-
#elif MBED_CONF_LORA_PHY == CN470
62+
#elif LORA_REGION == LORA_REGION_CN470
4363
#include "lorawan/lorastack/phy/LoRaPHYCN470.h"
4464
#define LoRaPHY_region LoRaPHYCN470
45-
#elif MBED_CONF_LORA_PHY == CN779
65+
#elif LORA_REGION == LORA_REGION_CN779
4666
#include "lorawan/lorastack/phy/LoRaPHYCN779.h"
4767
#define LoRaPHY_region LoRaPHYCN779
48-
#elif MBED_CONF_LORA_PHY == EU433
68+
#elif LORA_REGION == LORA_REGION_EU433
4969
#include "lorawan/lorastack/phy/LoRaPHYEU433.h"
5070
#define LoRaPHY_region LoRaPHYEU433
51-
#elif MBED_CONF_LORA_PHY == IN865
71+
#elif LORA_REGION == LORA_REGION_IN865
5272
#include "lorawan/lorastack/phy/LoRaPHYIN865.h"
5373
#define LoRaPHY_region LoRaPHYIN865
54-
#elif MBED_CONF_LORA_PHY == KR920
74+
#elif LORA_REGION == LORA_REGION_KR920
5575
#include "lorawan/lorastack/phy/LoRaPHYKR920.h"
5676
#define LoRaPHY_region LoRaPHYKR920
57-
#elif MBED_CONF_LORA_PHY == US915
77+
#elif LORA_REGION == LORA_REGION_US915
5878
#include "lorawan/lorastack/phy/LoRaPHYUS915.h"
5979
#define LoRaPHY_region LoRaPHYUS915
60-
#elif MBED_CONF_LORA_PHY == US915_HYBRID
80+
#elif LORA_REGION == LORA_REGION_US915_HYBRID
6181
#include "lorawan/lorastack/phy/LoRaPHYUS915Hybrid.h"
6282
#define LoRaPHY_region LoRaPHYUS915Hybrid
83+
#else
84+
#error "Invalid region configuration, update mbed_app.json with correct MBED_CONF_LORA_PHY value"
6385
#endif //MBED_CONF_LORA_PHY == VALUE
6486
#else
6587
#error "Must set LoRa PHY layer parameters."

0 commit comments

Comments
 (0)