From bcfc3462fc4bcc692464e0c224dc972a2a183bd7 Mon Sep 17 00:00:00 2001 From: guindel Date: Sat, 8 Feb 2025 21:56:11 -0500 Subject: [PATCH] satan wins --- .../Feather9x_TX_RX_serial.ino | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/Feather9x_TX_RX_serial/Feather9x_TX_RX_serial.ino b/Feather9x_TX_RX_serial/Feather9x_TX_RX_serial.ino index 46fa218..20d82bd 100644 --- a/Feather9x_TX_RX_serial/Feather9x_TX_RX_serial.ino +++ b/Feather9x_TX_RX_serial/Feather9x_TX_RX_serial.ino @@ -57,33 +57,36 @@ void setup() { // 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: 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: - chatName[ndx] = incomingByte; - ndx++; - } - char send_name[RH_RF95_MAX_MESSAGE_LEN] = ""; - strcpy(send_name, chatName); - strcat(send_name, " has joined the chat!"); - - Serial.print("Welcome "); - Serial.println(chatName); - rf95.send((uint8_t *)send_name, RH_RF95_MAX_MESSAGE_LEN); } void loop() { + + int ndx = 0; + if (chatName[0] == '\0'){ + + while (Serial.available() > 0) { + // read the incoming byte: + incomingByte = Serial.read(); + // say what you got: + chatName[ndx] = incomingByte; + ndx++; + } + if (chatName[0] != '\0'){ + char send_name[RH_RF95_MAX_MESSAGE_LEN] = ""; + strcpy(send_name, chatName); + strcat(send_name, " has joined the chat!"); + + Serial.print("Welcome "); + Serial.println(chatName); + rf95.send((uint8_t *)send_name, RH_RF95_MAX_MESSAGE_LEN); + } + } memset(receivedChars, '\0', sizeof(receivedChars)); int dataReceived = 0; - int ndx = 0; - while (Serial.available() > 0) { + while (Serial.available() > 0 && chatName[0] != '\0') { dataReceived = 1; // read the incoming byte: