ur dad support

This commit is contained in:
2025-02-08 21:23:45 -05:00
parent 3bc36b2ba8
commit db170b5511

View File

@@ -12,6 +12,15 @@
// Singleton instance of the radio driver // Singleton instance of the radio driver
RH_RF95 rf95(RFM95_CS, RFM95_INT); RH_RF95 rf95(RFM95_CS, RFM95_INT);
int16_t packetnum = 0;
int16_t max_message_with_packet_num = RH_RF95_MAX_MESSAGE_LEN - 7;
int incomingByte = 0;
// Serial imput
const byte numChars = RH_RF95_MAX_MESSAGE_LEN;
char receivedChars[numChars];
char name[30];
void setup() { void setup() {
pinMode(LED_BUILTIN, OUTPUT); pinMode(LED_BUILTIN, OUTPUT);
pinMode(RFM95_RST, OUTPUT); pinMode(RFM95_RST, OUTPUT);
@@ -48,18 +57,29 @@ void setup() {
// If you are using RFM95/96/97/98 modules which uses the PA_BOOST transmitter pin, then // If you are using RFM95/96/97/98 modules which uses the PA_BOOST transmitter pin, then
// you can set transmitter powers from 5 to 23 dBm: // you can set transmitter powers from 5 to 23 dBm:
rf95.setTxPower(23, false); rf95.setTxPower(23, false);
Serial.println("Please enter your name: ");
int ndx = 0;
while (Serial.available() == 0) {}
while (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
name[ndx] = incomingByte;
ndx++;
}
char send_name[RH_RF95_MAX_MESSAGE_LEN] = "";
strcat(send_name, name);
strcat(send_name, " has joined the chat!");
Serial.print("Welcome ");
Serial.println(name);
rf95.send((uint8_t *)send_name, RH_RF95_MAX_MESSAGE_LEN);
} }
int16_t packetnum = 0;
int16_t max_message_with_packet_num = RH_RF95_MAX_MESSAGE_LEN - 7;
int incomingByte = 0;
// Serial imput
const byte numChars = RH_RF95_MAX_MESSAGE_LEN;
char receivedChars[numChars];
void loop() { void loop() {
memset(receivedChars, '\0', sizeof(receivedChars)); memset(receivedChars, '\0', sizeof(receivedChars));
int dataReceived = 0; int dataReceived = 0;
int ndx = 0; int ndx = 0;
@@ -75,16 +95,17 @@ void loop() {
if (dataReceived) { if (dataReceived) {
dataReceived = 0; dataReceived = 0;
Serial.print("Trying to send: "); Serial.print(name);
Serial.print(receivedChars); Serial.print(": ");
Serial.println(receivedChars);
char actual_message[RH_RF95_MAX_MESSAGE_LEN];
strcat(actual_message, name);
strcat(actual_message, ": ");
strcat(actual_message, receivedChars);
// Transmit code // Transmit code
// Serial.println("Transmitting..."); // Send a message to rf95_server rf95.send((uint8_t *)actual_message, RH_RF95_MAX_MESSAGE_LEN);
// Serial.print("Sending "); Serial.println(receivedChars);
// Serial.println("Sending..."); delay(10);
rf95.send((uint8_t *)receivedChars, RH_RF95_MAX_MESSAGE_LEN);
// Serial.println("Waiting for packet to complete..."); delay(10); // Serial.println("Waiting for packet to complete..."); delay(10);
rf95.waitPacketSent(); rf95.waitPacketSent();
@@ -98,7 +119,6 @@ void loop() {
if (rf95.recv(buf, &len)) { if (rf95.recv(buf, &len)) {
digitalWrite(LED_BUILTIN, HIGH); digitalWrite(LED_BUILTIN, HIGH);
// RH_RF95::printBuffer("Received: ", buf, len); // RH_RF95::printBuffer("Received: ", buf, len);
Serial.print("Got: ");
Serial.println((char*)buf); Serial.println((char*)buf);
// Serial.print("RSSI: "); // Serial.print("RSSI: ");
// Serial.println(rf95.lastRssi(), DEC); // Serial.println(rf95.lastRssi(), DEC);