first commit

This commit is contained in:
Lazarewicz Julien
2025-07-22 15:27:00 +02:00
commit 6c6451c92c
205 changed files with 44418 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
// nrf905_client.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messageing client
// with the RH_NRF905 class. RH_NRF905 class does not provide for addressing or
// reliability, so you should only use RH_NRF905 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example nrf905_server.
// Tested on Teensy3.1 with nRF905 module
// Tested on Arduino Due with nRF905 module (Caution: use the SPI headers for connecting)
#include <SPI.h>
#include <RH_NRF905.h>
// Singleton instance of the radio driver
RH_NRF905 nrf905;
void setup()
{
Serial.begin(9600);
while (!Serial)
; // wait for serial port to connect. Needed for Leonardo only
if (!nrf905.init())
Serial.println("init failed");
// Defaults after init are 433.2 MHz (channel 108), -10dBm
}
void loop()
{
Serial.println("Sending to nrf905_server");
// Send a message to nrf905_server
uint8_t data[] = "Hello World!";
nrf905.send(data, sizeof(data));
nrf905.waitPacketSent();
// Now wait for a reply
uint8_t buf[RH_NRF905_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
if (nrf905.waitAvailableTimeout(500))
{
// Should be a reply message for us now
if (nrf905.recv(buf, &len))
{
Serial.print("got reply: ");
Serial.println((char*)buf);
}
else
{
Serial.println("recv failed");
}
}
else
{
Serial.println("No reply, is nrf905_server running?");
}
delay(400);
}

View File

@@ -0,0 +1,60 @@
// nrf905_reliable_datagram_client.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple addressed, reliable messaging client
// with the RHReliableDatagram class, using the RH_NRF905 driver to control a NRF905 radio.
// It is designed to work with the other example nrf905_reliable_datagram_server
// Tested on Teensy3.1 with nRF905 module
// Tested on Arduino Due with nRF905 module (Caution: use the SPI headers for connecting)
#include <RHReliableDatagram.h>
#include <RH_NRF905.h>
#include <SPI.h>
#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2
// Singleton instance of the radio driver
RH_NRF905 driver;
// Class to manage message delivery and receipt, using the driver declared above
RHReliableDatagram manager(driver, CLIENT_ADDRESS);
void setup()
{
Serial.begin(9600);
if (!manager.init())
Serial.println("init failed");
// Defaults after init are 433.2 MHz (channel 108), -10dBm
}
uint8_t data[] = "Hello World!";
// Dont put this on the stack:
uint8_t buf[RH_NRF905_MAX_MESSAGE_LEN];
void loop()
{
Serial.println("Sending to nrf905_reliable_datagram_server");
// Send a message to manager_server
if (manager.sendtoWait(data, sizeof(data), SERVER_ADDRESS))
{
// Now wait for a reply from the server
uint8_t len = sizeof(buf);
uint8_t from;
if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
{
Serial.print("got reply from : 0x");
Serial.print(from, HEX);
Serial.print(": ");
Serial.println((char*)buf);
}
else
{
Serial.println("No reply, is nrf905_reliable_datagram_server running?");
}
}
else
Serial.println("sendtoWait failed");
delay(500);
}

View File

@@ -0,0 +1,54 @@
// nrf905_reliable_datagram_server.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple addressed, reliable messaging server
// with the RHReliableDatagram class, using the RH_NRF905 driver to control a NRF905 radio.
// It is designed to work with the other example nrf905_reliable_datagram_client
// Tested on Teensy3.1 with nRF905 module
// Tested on Arduino Due with nRF905 module (Caution: use the SPI headers for connecting)
#include <RHReliableDatagram.h>
#include <RH_NRF905.h>
#include <SPI.h>
#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2
// Singleton instance of the radio driver
RH_NRF905 driver;
// Class to manage message delivery and receipt, using the driver declared above
RHReliableDatagram manager(driver, SERVER_ADDRESS);
void setup()
{
Serial.begin(9600);
if (!manager.init())
Serial.println("init failed");
// Defaults after init are 433.2 MHz (channel 108), -10dBm
}
uint8_t data[] = "And hello back to you";
// Dont put this on the stack:
uint8_t buf[RH_NRF905_MAX_MESSAGE_LEN];
void loop()
{
if (manager.available())
{
// Wait for a message addressed to us from the client
uint8_t len = sizeof(buf);
uint8_t from;
if (manager.recvfromAck(buf, &len, &from))
{
Serial.print("got request from : 0x");
Serial.print(from, HEX);
Serial.print(": ");
Serial.println((char*)buf);
// Send a reply back to the originator client
if (!manager.sendtoWait(data, sizeof(data), from))
Serial.println("sendtoWait failed");
}
}
}

View File

@@ -0,0 +1,52 @@
// nrf905_server.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messageing server
// with the RH_NRF905 class. RH_NRF905 class does not provide for addressing or
// reliability, so you should only use RH_NRF905 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example nrf905_client
// Tested on Teensy3.1 with nRF905 module
// Tested on Arduino Due with nRF905 module (Caution: use the SPI headers for connecting)
#include <SPI.h>
#include <RH_NRF905.h>
// Singleton instance of the radio driver
RH_NRF905 nrf905;
void setup()
{
Serial.begin(9600);
while (!Serial)
; // wait for serial port to connect. Needed for Leonardo only
if (!nrf905.init())
Serial.println("init failed");
// Defaults after init are 433.2 MHz (channel 108), -10dBm
}
void loop()
{
if (nrf905.available())
{
// Should be a message for us now
uint8_t buf[RH_NRF905_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
if (nrf905.recv(buf, &len))
{
// nrf905.printBuffer("request: ", buf, len);
Serial.print("got request: ");
Serial.println((char*)buf);
// Send a reply
uint8_t data[] = "And hello back to you";
nrf905.send(data, sizeof(data));
nrf905.waitPacketSent();
Serial.println("Sent a reply");
}
else
{
Serial.println("recv failed");
}
}
}