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