Line data Source code
1 : #include <boost/test/unit_test.hpp>
2 :
3 : #include "ModuleFixture.hpp"
4 :
5 : #include "modules/SX126x/SX1261.h"
6 : #include "modules/SX126x/SX1262.h"
7 : #include "modules/SX126x/SX1268.h"
8 : #include "modules/SX127x/SX1272.h"
9 : #include "modules/SX127x/SX1273.h"
10 : #include "modules/SX127x/SX1276.h"
11 : #include "modules/SX127x/SX1277.h"
12 : #include "modules/SX127x/SX1278.h"
13 : #include "modules/SX127x/SX1279.h"
14 : #include "modules/SX128x/SX1280.h"
15 : #include "modules/SX128x/SX1281.h"
16 : #include "modules/SX128x/SX1282.h"
17 : #include "modules/LR11x0/LR1110.h"
18 : #include "modules/LR11x0/LR1120.h"
19 : #include "modules/LR11x0/LR1121.h"
20 : #include "modules/LR2021/LR2021.h"
21 :
22 : BOOST_FIXTURE_TEST_SUITE(suite_PhyComplete, ModuleFixture)
23 :
24 2 : BOOST_FIXTURE_TEST_CASE(PhyComplete_AllRadios, ModuleFixture) {
25 : struct RadioPhy {
26 : std::string name; // Radio name
27 : PhysicalLayer* phy;
28 : };
29 :
30 1 : hal->spiLogEnabled = false;
31 :
32 : std::vector<RadioPhy> allPhys = {
33 1 : { "SX1261", new SX1261(mod) },
34 1 : { "SX1262", new SX1262(mod) },
35 1 : { "SX1268", new SX1268(mod) },
36 1 : { "SX1272", new SX1272(mod) },
37 1 : { "SX1273", new SX1273(mod) },
38 1 : { "SX1276", new SX1276(mod) },
39 1 : { "SX1277", new SX1277(mod) },
40 1 : { "SX1278", new SX1278(mod) },
41 1 : { "SX1279", new SX1272(mod) },
42 1 : { "SX1280", new SX1280(mod) },
43 1 : { "SX1281", new SX1281(mod) },
44 1 : { "SX1282", new SX1282(mod) },
45 1 : { "LR1110", new LR1110(mod) },
46 1 : { "LR1120", new LR1120(mod) },
47 1 : { "LR1121", new LR1121(mod) },
48 1 : { "LR2021", new LR2021(mod) },
49 35 : };
50 :
51 : int state;
52 1 : uint8_t testBuff[256] = { 0 };
53 17 : for(const auto& radio : allPhys) {
54 16 : BOOST_TEST_MESSAGE("--- Test phyComplete " << radio.name << " ---");
55 :
56 16 : state = radio.phy->transmit(testBuff, 1, 0);
57 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
58 :
59 16 : state = radio.phy->sleep();
60 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
61 :
62 16 : state = radio.phy->standby();
63 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
64 :
65 16 : state = radio.phy->standby(0);
66 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
67 :
68 16 : state = radio.phy->startReceive();
69 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
70 :
71 16 : state = radio.phy->startReceive(0);
72 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
73 :
74 16 : state = radio.phy->receive(testBuff, 1);
75 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
76 :
77 16 : state = radio.phy->startTransmit(testBuff, 1, 0);
78 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
79 :
80 16 : state = radio.phy->finishTransmit();
81 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
82 :
83 16 : state = radio.phy->finishReceive();
84 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
85 :
86 16 : state = radio.phy->readData(testBuff, 1);
87 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
88 :
89 16 : state = radio.phy->transmitDirect();
90 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
91 :
92 16 : state = radio.phy->receiveDirect();
93 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
94 :
95 16 : state = radio.phy->setFrequency(0);
96 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
97 :
98 16 : state = radio.phy->setBitRate(0);
99 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
100 :
101 16 : state = radio.phy->setFrequencyDeviation(0);
102 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
103 :
104 16 : state = radio.phy->setDataShaping(0);
105 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
106 :
107 16 : state = radio.phy->setEncoding(0);
108 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
109 :
110 16 : state = radio.phy->invertIQ(false);
111 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
112 :
113 16 : state = radio.phy->setOutputPower(0);
114 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
115 :
116 16 : state = radio.phy->checkOutputPower(0, nullptr);
117 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
118 :
119 16 : state = radio.phy->setSyncWord(testBuff, 1);
120 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
121 :
122 16 : state = radio.phy->setPreambleLength(0);
123 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
124 :
125 16 : DataRate_t dr = { .lora = { .spreadingFactor = 0, .bandwidth = 0, .codingRate = 0 } };
126 16 : state = radio.phy->setDataRate(dr);
127 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
128 :
129 16 : state = radio.phy->checkDataRate(dr);
130 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
131 :
132 16 : state = radio.phy->getPacketLength();
133 16 : BOOST_TEST(state != 0);
134 :
135 16 : state = radio.phy->getRSSI();
136 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
137 :
138 16 : state = radio.phy->getSNR();
139 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
140 :
141 16 : PacketConfig_t pc = { .lora = { .preambleLength = 0, .implicitHeader = false,
142 : .crcEnabled = false, .ldrOptimize = false } };
143 16 : state = radio.phy->calculateTimeOnAir(RADIOLIB_MODEM_NONE, dr, pc, 0);
144 16 : BOOST_TEST(state != 0);
145 :
146 16 : state = radio.phy->getTimeOnAir(100);
147 16 : BOOST_TEST(state != 0);
148 :
149 16 : state = radio.phy->calculateRxTimeout(100000);
150 16 : BOOST_TEST(state != 0);
151 :
152 16 : state = radio.phy->getIrqFlags();
153 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
154 :
155 16 : state = radio.phy->setIrqFlags(0);
156 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
157 :
158 16 : state = radio.phy->clearIrqFlags(0);
159 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
160 :
161 16 : state = radio.phy->startChannelScan();
162 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
163 :
164 16 : const ChannelScanConfig_t csc = { .rssi = { .limit = 0 } };
165 16 : state = radio.phy->startChannelScan(csc);
166 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
167 :
168 16 : state = radio.phy->getChannelScanResult();
169 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
170 :
171 16 : state = radio.phy->scanChannel();
172 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
173 :
174 16 : state = radio.phy->scanChannel(csc);
175 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
176 :
177 16 : state = radio.phy->randomByte();
178 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
179 :
180 16 : state = radio.phy->setModem(RADIOLIB_MODEM_NONE);
181 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
182 :
183 : ModemType_t modem;
184 16 : state = radio.phy->getModem(&modem);
185 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
186 :
187 16 : RadioModeConfig_t cfg = { .receive = { .timeout = 0, .irqFlags = RADIOLIB_IRQ_RX_DEFAULT_FLAGS,
188 : .irqMask = RADIOLIB_IRQ_RX_DEFAULT_MASK, .len = 0 }};
189 16 : state = radio.phy->stageMode(RADIOLIB_RADIO_MODE_RX, &cfg);
190 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
191 :
192 16 : radio.phy->stagedMode = RADIOLIB_RADIO_MODE_RX;
193 16 : state = radio.phy->launchMode();
194 16 : BOOST_TEST(state != RADIOLIB_ERR_UNSUPPORTED);
195 : }
196 :
197 1 : }
198 :
199 : BOOST_AUTO_TEST_SUITE_END()
|