4 #include "radio_plugins/RADIO_INDEX"
35 INFO(
"Radio plugins loaded: %s\n", list().c_str());
36 if (select(Settings::getString(
"radio"))) {
45 bool Radio::select(
const String &name) {
46 for (
int n = 0; n <
len; n++) {
47 if (strcmp(store[n].name, name.c_str()) == 0) {
49 INFO(
"Radio %s selected.\n", name);
53 ERROR(
"No such radio: '%s'.\n", name.c_str());
60 String
Radio::list(String separator) {
62 for (
int n = 0; n <
len; n++) {
74 for (
int n = 0; n <
len; n++) {
76 return String(store[n]
.name);
85 INFO(
"Initializing radio.\n");
86 pin_rx = Settings::getInt(
"pin_rx");
87 pin_tx = Settings::getInt(
"pin_tx");
95 DEBUG(
"Configuring radio for receiving.\n");
97 ERROR(
"ERROR: pin_rx needs to be set receive.\n");
108 DEBUG(
"Configuring radio for transmission.\n");
110 ERROR(
"ERROR: pin_tx needs to be set for transmit.\n");
114 PIN_WRITE(pin_tx, !Settings::isSet(
"tx_active_high"));
122 DEBUG(
"Radio entering standby mode.\n");
164 int spi_port_int = -1;
165 if (spi_port ==
"HSPI") {
167 }
else if (spi_port ==
"FSPI") {
171 else if (spi_port ==
"VSPI") {
176 ERROR(
"SPI port '%s' unknown, trying default SPI.\n", spi_port.c_str());
178 if (spi_port_int != -1 && pin_miso != -1 && pin_mosi != -1 && pin_sck != -1) {
179 INFO(
"Radio %s: SPI port %s, SCK %i, MISO %i, MOSI %i, CS %i, RESET %i, RX %i, TX %i\n", name().c_str(), spi_port.c_str(), pin_sck, pin_miso, pin_mosi, pin_cs, pin_reset, pin_rx, pin_tx);
180 spi =
new SPIClass(spi_port_int);
181 spi->begin(pin_sck, pin_miso, pin_mosi, pin_cs);
182 radioLibModule =
new Module(pin_cs, -1, pin_reset, -1, *spi);
184 INFO(
"Radio %s: default SPI, SCK %i, MISO %i, MOSI %i, CS %i, RESET %i, RX %i, TX %i\n", name().c_str(), SCK, MISO, MOSI, pin_cs, pin_reset, pin_rx, pin_tx);
185 radioLibModule =
new Module(pin_cs, -1, pin_reset, -1);
187 INFO(
"%s: Frequency: %.2f Mhz, bandwidth %.1f kHz, bitrate %.3f kbps\n", name().c_str(), frequency, bandwidth, bitrate);
196 DEBUG(
"%s: %s returned 0 (OK)\n", name().c_str(), action);
199 ERROR(
"%s ERROR: %s returned -2 (CHIP NOT FOUND)\n", name().c_str(), action);
202 ERROR(
"%s ERROR: %s returned %i\n%s\n", name().c_str(), action, result,
203 "(See https://github.com/jgromes/RadioLib/blob/master/src/TypeDef.h for Meaning of RadioLib error codes.)");
214 String threshold_type;
217 INFO(
"%s: Threshold type %s, level %i\n", name().c_str(), threshold_type.c_str(), threshold_level);
218 if (threshold_type ==
"fixed") {
220 }
else if (threshold_type ==
"average") {