first commit
This commit is contained in:
74
examples/sx126x/stm32wlx_client/stm32wlx_client.ino
Normal file
74
examples/sx126x/stm32wlx_client/stm32wlx_client.ino
Normal file
@@ -0,0 +1,74 @@
|
||||
// stm32wlx_client.ino
|
||||
// -*- mode: C++ -*-
|
||||
// Example sketch showing how to create a simple messageing client
|
||||
// with the STM32WLx class. STM32WLx class does not provide for addressing or
|
||||
// reliability, so you should only use on its own RH_SX126X if you do not need the higher
|
||||
// level messaging abilities.
|
||||
// It is designed to work with the other example stm32wlx_server
|
||||
// (dont forget to make sure the madulation schemes and frequencies are the same).
|
||||
// In order to use the Arduino IDE to program the Wio-E5, you must
|
||||
// install the stm32duino package using these instructions:
|
||||
// https://community.st.com/t5/stm32-mcus/stm32-arduino-stm32duino-tutorial/ta-p/49649
|
||||
// Tested with Wio-E5 mini. In Arduino, select:
|
||||
// Tools -> Board -> STM32 MCU based boards -> LoRa boards
|
||||
// Tools -> Board part number -> LoRa-E5 mini
|
||||
// Tools -> U(S)ART support -> Enabled (generic Serial)
|
||||
|
||||
#include <SPI.h>
|
||||
#include <RH_STM32WLx.h>
|
||||
|
||||
// Single instance of the driver. The defaults will work for Seed WiO-E5 mini board, and other boards
|
||||
// equipped with Seeed LoRa-E5 modules, such as NUCLEO_WL55JC1
|
||||
RH_STM32WLx driver;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
while (!Serial) ; // Wait for serial port to be available
|
||||
|
||||
if (!driver.init())
|
||||
Serial.println("init failed");
|
||||
// Defaults after init are 915.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on
|
||||
// You can change the frequency:
|
||||
// driver.setFrequency(868.0);
|
||||
|
||||
// You can change the modulation parameters with eg
|
||||
// driver.setModemConfig(RH_SX126x::LoRa_Bw125Cr45Sf2048);
|
||||
|
||||
// You can change the power level in dBm
|
||||
// driver.setTxPower(14);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Serial.println("Sending to stm32wlx_server");
|
||||
// Send a message to stm32wlx_server
|
||||
uint8_t data[] = "Hello World!";
|
||||
driver.send(data, sizeof(data));
|
||||
|
||||
driver.waitPacketSent();
|
||||
// Now wait for a reply
|
||||
uint8_t buf[RH_SX126x_MAX_MESSAGE_LEN];
|
||||
uint8_t len = sizeof(buf);
|
||||
|
||||
if (driver.waitAvailableTimeout(3000))
|
||||
{
|
||||
// Should be a reply message for us now
|
||||
if (driver.recv(buf, &len))
|
||||
{
|
||||
Serial.print("got reply: ");
|
||||
Serial.println((char*)buf);
|
||||
// Serial.print("RSSI: ");
|
||||
// Serial.println(driver.lastRssi(), DEC);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("recv failed");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("No reply, is stm32wlx_server running?");
|
||||
}
|
||||
delay(400);
|
||||
}
|
46
examples/sx126x/stm32wlx_continuous/stm32wlx_continuous.ino
Normal file
46
examples/sx126x/stm32wlx_continuous/stm32wlx_continuous.ino
Normal file
@@ -0,0 +1,46 @@
|
||||
// stm32wlx_continuous.ino
|
||||
// -*- mode: C++ -*-
|
||||
// Example sketch showing how to start a continuous carrier wave transmission
|
||||
// for measuring power output. CAUTION: it may be illegal for you to transmit continuously
|
||||
// without a dummy load.
|
||||
//
|
||||
// In order to use the Arduino IDE to program the Wio-E5, you must
|
||||
// install the stm32duino package using these instructions:
|
||||
// https://community.st.com/t5/stm32-mcus/stm32-arduino-stm32duino-tutorial/ta-p/49649
|
||||
// Tested with Wio-E5 mini. In Arduino, select:
|
||||
// Tools -> Board -> STM32 MCU based boards -> LoRa boards
|
||||
// Tools -> Board part number -> LoRa-E5 mini
|
||||
// Tools -> U(S)ART support -> Enabled (generic Serial)
|
||||
// Caution: it is probably possible to damage your chip by setting high power levels
|
||||
// without a suitable RF termination.
|
||||
|
||||
#include <SPI.h>
|
||||
#include <RH_STM32WLx.h>
|
||||
|
||||
// Single instance of the driver. The defaults will work for Seed WiO-E5 mini board, and other boards
|
||||
// equipped with Seeed LoRa-E5 modules, such as NUCLEO_WL55JC1
|
||||
RH_STM32WLx driver;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
while (!Serial) ; // Wait for serial port to be available
|
||||
|
||||
if (!driver.init())
|
||||
Serial.println("init failed");
|
||||
|
||||
// You can change the frequency:
|
||||
driver.setFrequency(868.0); // Specs are at this frequency
|
||||
|
||||
// You can change the power level in dBm(-9 to +22 on the Wio-E5 mini)
|
||||
// Default is 13dBm
|
||||
driver.setTxPower(0);
|
||||
driver.setTxContinuous(); // Send continuous carrier wave at the power and frequency set above
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
74
examples/sx126x/stm32wlx_server/stm32wlx_server.ino
Normal file
74
examples/sx126x/stm32wlx_server/stm32wlx_server.ino
Normal file
@@ -0,0 +1,74 @@
|
||||
// stm32wlx_server.ino
|
||||
// -*- mode: C++ -*-
|
||||
// Example sketch showing how to create a simple messageing server
|
||||
// with the RH_SX126X class. RH_SX126X class does not provide for addressing or
|
||||
// reliability, so you should only use on its own RH_SX126X if you do not need the higher
|
||||
// level messaging abilities.
|
||||
// It is designed to work with the other example stm32wlx_client or rf95_client
|
||||
// (dont forget to make sure the madulation schemes and frequencies are the same).
|
||||
//
|
||||
// In order to use the Arduino IDE to program the Wio-E5, you must
|
||||
// install the stm32duino package using these instructions:
|
||||
// https://community.st.com/t5/stm32-mcus/stm32-arduino-stm32duino-tutorial/ta-p/49649
|
||||
// Tested with Wio-E5 mini. In Arduino, select:
|
||||
// Tools -> Board -> STM32 MCU based boards -> LoRa boards
|
||||
// Tools -> Board part number -> LoRa-E5 mini
|
||||
// Tools -> U(S)ART support -> Enabled (generic Serial)
|
||||
//
|
||||
// Program with eg ST-LINK V2 (a red USB dongle). See the instructions in RH_STM32WLx.h
|
||||
|
||||
#include <RH_STM32WLx.h>
|
||||
|
||||
// Single instance of the driver. The defaults will work for Seed WiO-E5 mini board, and other boards
|
||||
// equipped with Seeed LoRa-E5 modules, such as NUCLEO_WL55JC1
|
||||
RH_STM32WLx driver;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
while (!Serial) ; // Wait for serial port to be available
|
||||
|
||||
if (!driver.init())
|
||||
Serial.println("init failed");
|
||||
|
||||
// Defaults after init are 915.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on
|
||||
// You can change the frequency:
|
||||
//driver.setFrequency(868.0);
|
||||
|
||||
// You can change the modulation parameters with eg
|
||||
//driver.setModemConfig(RH_SX126x::LoRa_Bw125Cr45Sf2048);
|
||||
|
||||
// You can change the power level in dBm (-9 to +22 on the Wio-E5 mini)
|
||||
// Default is 13dBm
|
||||
//driver.setTxPower(0);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (driver.available())
|
||||
{
|
||||
// Should be a message for us now
|
||||
uint8_t buf[RH_SX126x_MAX_MESSAGE_LEN];
|
||||
uint8_t len = sizeof(buf);
|
||||
if (driver.recv(buf, &len))
|
||||
{
|
||||
// RH_SX126X::printBuffer("request: ", buf, len);
|
||||
Serial.print("got request: ");
|
||||
Serial.println((char*)buf);
|
||||
Serial.print("RSSI: ");
|
||||
Serial.println(driver.lastRssi(), DEC);
|
||||
|
||||
// Send a reply
|
||||
uint8_t data[] = "And hello back to you";
|
||||
driver.send(data, sizeof(data));
|
||||
driver.waitPacketSent();
|
||||
Serial.println("Sent a reply");
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("recv failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
74
examples/sx126x/sx1262_client/sx1262_client.ino
Normal file
74
examples/sx126x/sx1262_client/sx1262_client.ino
Normal file
@@ -0,0 +1,74 @@
|
||||
// sx1262_client.ino
|
||||
// -*- mode: C++ -*-
|
||||
// Example sketch showing how to create a simple messageing client
|
||||
// with the RH_SX126x class and a basic SX1262 module connected to an Arduino compatible processor
|
||||
// It is designed to work with the examples sx1262_server and sx1262_server.
|
||||
// Tested with G-Nice LoRa1262-915 and Teensy 3.1
|
||||
// also Heltec Cube Cell HTCC-AB01
|
||||
|
||||
#include <RH_SX126x.h>
|
||||
|
||||
RH_SX126x driver(SS, 7, 8, 9); // NSS, DIO1, BUSY, NRESET
|
||||
|
||||
// For Heltec Cube Cell, using CubeCell board 1.5.0 or greater
|
||||
//RH_SX126x driver(RADIO_NSS, RADIO_DIO_1, RADIO_BUSY, RADIO_RESET);
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
// May need this on some platforms but definitely not on CubeCell:
|
||||
//while (!Serial) ; // Wait for serial port to be available
|
||||
|
||||
if (!driver.init())
|
||||
Serial.println("init failed");
|
||||
|
||||
// Defaults after init are 915.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on (LoRa_Bw125Cr45Sf128)
|
||||
// You can change the frequency:
|
||||
//driver.setFrequency(868.0);
|
||||
|
||||
// You can change the modulation parameters with eg
|
||||
//driver.setModemConfig(RH_SX126x::LoRa_Bw125Cr45Sf2048);
|
||||
|
||||
// You can change the power level in dBm
|
||||
// Default is 13dBm
|
||||
//driver.setTxPower(0);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Serial.println("Sending to sx126x_server");
|
||||
// Send a message to stm32wlx_server
|
||||
uint8_t data[] = "Hello World!";
|
||||
|
||||
driver.send(data, sizeof(data));
|
||||
|
||||
driver.waitPacketSent(3000);
|
||||
|
||||
|
||||
// Now wait for a reply
|
||||
uint8_t buf[RH_SX126x_MAX_MESSAGE_LEN];
|
||||
uint8_t len = sizeof(buf);
|
||||
|
||||
if (driver.waitAvailableTimeout(3000))
|
||||
{
|
||||
// Should be a reply message for us now
|
||||
if (driver.recv(buf, &len))
|
||||
{
|
||||
|
||||
Serial.print("got reply: ");
|
||||
Serial.println((char*)buf);
|
||||
// Serial.print("RSSI: ");
|
||||
// Serial.println(driver.lastRssi(), DEC);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("recv failed");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("No reply, is sx126x_server running?");
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
}
|
65
examples/sx126x/sx1262_server/sx1262_server.ino
Normal file
65
examples/sx126x/sx1262_server/sx1262_server.ino
Normal file
@@ -0,0 +1,65 @@
|
||||
// sx1262_server.ino
|
||||
// -*- mode: C++ -*-
|
||||
// Example sketch showing how to create a simple messageing server
|
||||
// with the RH_SX126x class and a basic SX1262 module connected to an Arduino compatible processor
|
||||
// It is designed to work with the examples stm32wlx_client and sx1262_client.
|
||||
// Tested with G-Nice LoRa1262-915 and Teensy 3.1
|
||||
// also Heltec Cube Cell HTCC-AB01
|
||||
|
||||
#include <RH_SX126x.h>
|
||||
|
||||
RH_SX126x driver(SS, 7, 8, 9); // NSS, DIO1, BUSY, NRESET
|
||||
|
||||
// For Heltec Cube Cell, using CubeCell board 1.5.0 or greater
|
||||
//RH_SX126x driver(RADIO_NSS, RADIO_DIO_1, RADIO_BUSY, RADIO_RESET);
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
// May need this on some platforms but definitely not on CubeCell:
|
||||
//while (!Serial) ; // Wait for serial port to be available
|
||||
|
||||
if (!driver.init())
|
||||
Serial.println("init failed");
|
||||
|
||||
// Defaults after init are 915.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on
|
||||
// You can change the frequency:
|
||||
//driver.setFrequency(868.0);
|
||||
|
||||
// You can change the modulation parameters with eg
|
||||
//driver.setModemConfig(RH_SX126x::LoRa_Bw125Cr45Sf2048);
|
||||
|
||||
// You can change the power level in dBm (-9 to +22 on the Wio-E5 mini)
|
||||
// Default is 13dBm
|
||||
//driver.setTxPower(0);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (driver.available())
|
||||
{
|
||||
// Should be a message for us now
|
||||
uint8_t buf[RH_SX126x_MAX_MESSAGE_LEN];
|
||||
uint8_t len = sizeof(buf);
|
||||
if (driver.recv(buf, &len))
|
||||
{
|
||||
// RH_SX126X::printBuffer("request: ", buf, len);
|
||||
Serial.print("got request: ");
|
||||
Serial.println((char*)buf);
|
||||
Serial.print("RSSI: ");
|
||||
Serial.println(driver.lastRssi(), DEC);
|
||||
|
||||
// Send a reply
|
||||
uint8_t data[] = "And hello back to you";
|
||||
driver.send(data, sizeof(data));
|
||||
driver.waitPacketSent();
|
||||
Serial.println("Sent a reply");
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("recv failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user