Arduboy Messenger

Thank you. I will try…

pinsLoraHIGH(); 
    Lora.resetModule();
    while ( !digitalRead(pinAUXin)); // ожидание готовности add 19052023

but there is also some feature associated with the delay when switching from one mode to another…apparently it is necessary to add a delay in some important places or to execute an empty for loop instead of a delay…

For which module are those commands? The datasheet specifies only these commands:

Note the fixed baudrate setting.

1 Like

I try any methods…this method using AT commands is taken from the Semtech

#define PB5_MASK (1 << 5)
#define PD2_MASK (1 << 2)

void setDefaultConfiguration() {
     //PORTB &= ~(1 << 5); // Reset bit 5
     //PORTB |= (1 << 5); // pull-up bit 5
     //DDRB &= ~(1 << 5); // Set PB5 input
    
     delay(500);
     //PORTB |= (1 << 5); // Turn on the pull-up resistor
   
    
     //set the state of pins M0 M1 to HIGH - MODE3
     pinsLoraHIGH();
     lora.resetModule();
     while ( !digitalRead(pinAUX)); // waiting for readiness add 19052023

     DDRB &= ~PB5_MASK; //open-collector pb5
     //DDRB |= PB5_MASK; //open-drain
     DDRD |= PD2_MASK; //open-drain
     //DDRD &= ~PD2_MASK; //open-collector
    
      // After set configuration comment set M0 and M1 to low
     // and reboot if you directly set HIGH M0 and M1 to program
     //Serial1.write((byte)0x00); //Receiver Address
     //Serial1.write(0x01); //Receiver Address
     //Serial1.write(0x1f); //Receiver channel =0x17=23 (410M+23=433 MHz)
    
     ResponseStructContainer c;
     c = Lora.getConfiguration();
     Configuration configuration = *(Configuration*) c.data;
     Serial1.println(c.status.getResponseDescription()); //if you need the output of the set parameters in Serail
     Serial1.println(c.status.code);
     configuration.ADDL=0x00; //set default address values
     configuration.ADDH=0x01; //set default address values
     configuration.CHAN = 0x1f; //0x00-0x1f+410=441mhz MaxFreq//0x17// freq=23+410=433mhz
     //data transfer will be in fixed transfer mode, in which the master device is
     //transmitting commands and data to the slave device, and the slave device simply listens and transmits data in response.
     //configuration.OPTION.fixedTransmission = FT_FIXED_TRANSMISSION;
     configuration.OPTION.fixedTransmission = FT_TRANSPARENT_TRANSMISSION;
     /*
     configuration.OPTION.fec = FEC_0_OFF;
    
     // transparent transmission mode, in which the slave device independently transfers data to the master device when possible
     //configuration.OPTION.fixedTransmission = FT_TRANSPARENT_TRANSMISSION;
     configuration.OPTION.ioDriveMode = IO_D_MODE_PUSH_PULLS_PULL_UPS;
     configuration.OPTION.transmissionPower = POWER_17;
     configuration.OPTION.wirelessWakeupTime = WAKE_UP_1250;

     configuration.SPED.airDataRate = AIR_DATA_RATE_011_48;
     configuration.SPED.uartBaudRate = UART_BPS_115200;
     configuration.SPED.uartParity = MODE_00_8N1;
     */
     //ResponseStatus rs = Lora.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE); //important, when the power is turned off, the settings remain!!!
     ResponseStatus rs = Lora.setConfiguration(configuration, WRITE_CFG_PWR_DWN_LOSE); //settings are lost when the power is turned off
     Serial1.println(rs.getResponseDescription());
     Serial1.println(rs.code);
     //printParameters(configuration);
     c.close();
     delay(500);

     // while ( !digitalRead(pinAUX)); //wait for Lora to be ready after accepting the settings
     lora.resetModule();
     while ( !digitalRead(pinAUX)); // waiting for readiness add 19052023
     //restore the state of pins M0 M1 to MODE0
     pinsLoraLOW();
     //Lora.resetModule(); //reset lore
}

void pinsLoraHIGH() {
   //delay(500);
PORTB |= (1 << 7); // set pin 11 to HIGH (pin 11 corresponds to PB7)//M0
PORTB |= (1 << 6); // set pin 10 to HIGH (pin 10 corresponds to PB6)//M1
// while ( !digitalRead(pinAUX));
}

void pinsLoraLOW() {
   //delay(500);
PORTB &= ~(1 << 7); // set pin 11 to LOW (pin 11 corresponds to PB7)//M0
PORTB &= ~(1 << 6); // set pin 10 to LOW (pin 10 corresponds to PB6)//M1
}

in any case, no method works as desired…and at the expense of sending the same command 3 times, I also tried it didn’t work…
I will try to raise the vcc power supply on the module to the battery voltage if this does not work, I will supply the module with 5v as written in the manual

I wrote a test code to save the settings until the power is turned off:

void setup()
{
Serial.begin(9600);
Serial1.begin(9600);

pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);

delay(2000);

Serial1.write(0xC2); //C2 without save after disconeccted C0 with saving
Serial1.write(0xff); //Receiver Adress ADDH
Serial1.write(0xff); //Receiver Adress ADDL
Serial1.write(0x18); //parameters speed rx/tx 9600 0.3 bod airspeed
Serial1.write(0x1f); //Receiver channel =0x17=23 (410M+23=433 MHz)
Serial1.write(0x44); //transparent transmistion 20dbm
}

void loop()
{
delay(2000);

Serial1.write(0xC1); // We pass 3 bytes so that the module returns the current parameters
Serial1.write(0xC1);
Serial1.write(0xC1);

while(Serial1.available()) // Get the parameters and output them to the port monitor
{
int inByte = Serial1.read();
Serial.print(inByte, HEX);
Serial.print(" ");
}
Serial.println(); 
}

and it worked!)
…now need to understand why the parameters are not written through the EBYTE library … think need to try to decomment 6 bytes of parameters to pass to lora

1 Like

Note: We have to transfer 6 bytes of information about the settings to the module, as it is written in the official manual in the table. We add up the binary data of one byte consisting of several parameters, writing all zeros and ones sequentially and converting them to hex, then I will pass Serial1.write(0xC0) to the function sequentially; and so on in the sequence described in the offmanual in the parameter table. Only 6bytes.

slightly changed the code using the Adruboy library and made the output of the accepted Lora parameters on the screen…

#include <Arduboy2.h>
#include <avr/power.h>

Arduboy2 arduboy;

void setup()
{
   arduboy.begin();

   Serial.begin(9600);
   power_usart1_enable(); //activate uart1
   Serial1.begin(9600);

   //pinMode(10, OUTPUT);
   //pinMode(11, OUTPUT);
   DDRB &= ~(1 << 5); // Set PB5 input LoraAUX
   digitalWrite(10, HIGH);
   digitalWrite(11, HIGH);

   delay(2000);

   // Send commands to configure the LoRa module
   Serial1.write(0xC2); //HEAD: C2 without save after disconected C0 with saving
   Serial1.write(0x0); //Receiver Address ADDH
   Serial1.write(0x1); //Receiver Address ADDL
   Serial1.write(0x18); //parameters speed rx/tx 9600 0.6 bod airspeed
   Serial1.write(0x17); //Receiver channel =0x17=23 (410M+23=433MHz) 1f-441mhz
   Serial1.write(0x44); //transparent transmission 20dbm
}

void loop()
{
   delay(2000); // Give the module time to return the parameters
   // Get the parameters of the LoRa module and display them on the Arduboy screen
   arduboy.clear(); // Clear Arduboy Screen
   arduboy.setCursor(0, 0);
   arduboy.println("Lora config: ");

   uint8_t loraData[6] = {0}; // Create an array to store parameters

   Serial1.write(0xC1); // Pass 3 bytes for the module to return the current parameters
   Serial1.write(0xC1);
   Serial1.write(0xC1);

  

   if (Serial1.available() >= 6) { // Check if enough bytes are available
     for (int i = 0; i < 6; i++) { // Read bytes into array
       loraData[i] = Serial1.read();
       Serial.print(loraData[i], HEX);
       serial print(" ");
     }
     Serial.println();
   }
  
   for (int i = 0; i < 6; i++) { // Display parameter values on the screen
     arduboy.println(loraData[i], HEX);
   }

   arduboy.display(); // Display information on the screen
}

Now all ok!

void getConfigurationLora() {
  
   pinsLoraHIGH(); //to receive settings information from the lora module, set the pins M0 M1 to HIGH according to the manual
   // Get the parameters of the LoRa module and display them on the Arduboy screen
   arduboy.clear(); // Clear Arduboy Screen
   arduboy.setCursor(1, 0);
   arduboy.print("LoRa config: ");
   arduboy.setCursor(1, 10);

   uint8_t loraData[6] = {0}; // Create an array to store parameters

   delay(1000); // Give the module time to return the parameters
  
   Serial1.write(0xC1); // Pass 3 bytes for the module to return the current parameters
   Serial1.write(0xC1);
   Serial1.write(0xC1);
 
   if (Serial1.available() >= 6) { // Check if enough bytes are available
     for (int i = 0; i < 6; i++) { // Read bytes into array
       loraData[i] = Serial1.read();
       //Serial.print(loraData[i], HEX);
       //Serial.print(" ");
     }
     Serial.println();
   }
  
   for (int i = 0; i < 6; i++) { // Display parameter values on the screen
      arduboy.print(loraData[i], HEX);
   }
   arduboy.setCursor(1, 30);
   arduboy.print("Exit: loong key_B...");
   arduboy.display(); // Display information on the screen
    
   pinsLoraLOW(); //according to the manual, we return pins M0 M1 to LOW
}

void setDefaultConfiguration() {
     //set the state of pins M0 M1 to HIGH - MODE3
     DDRB &= ~(1 << 5); // Set PB5 input
     pinsLoraHIGH();

   // Send commands to configure the LoRa module
   for (int i = 0; i < 6; i++) {
     Serial1.write(0xC2); //HEAD: C2 without save after disconected C0 with saving
     Serial1.write(0x0); //Receiver Address ADDH
     Serial1.write(0x1); //Receiver Address ADDL
     Serial1.write(0x18); //parameters speed rx/tx 9600 0.3k bod airspeed
     Serial1.write(0x17); //Receiver channel =0x17=23 (410M+23=433MHz) 1f-441mhz
     Serial1.write(0x44); //0xC4 - fixed transmistion 20dbm 0x44 - transparent transmistion 20dbm
     delay(50); // add a delay to prevent data loss
   }
      pinsLoraLOW();
}

void getConfigurationLora ()…call in loop…
the EBYTE LoRa E32 library did not want to work with saving and outputting parameters through arduboy, apparently it was developed mainly for esp32 and similar controllers. It has not yet become climb and understand

There is an issue there. If there are not 6 bytes of serial data available right away after writing the command (which is most likely the case) then no data is read at all and you’re printing out random data.

Try replacing the if statement with:

while (Serial1.available() < 6);

ok…well, so far everything is working without failures, as soon as I encounter something indefinite, I will try your method, thanks for the tip …
I am currently writing 4 more important functions:

  1. I am trying to rewrite the ADDH ADDL address generator to be passed to the setDefaultConfiguration() function so that they are correctly passed to the lora module:
void setDefaultConfiguration(unsigned char* ADDH, unsigned char* ADDL) {
   DDRB &= ~(1 << 5); // Set PB5 input
   pinsLoraHIGH();
   // Send commands to configure the LoRa module
   for (int i = 0; i < 6; i++) {
     Serial1.write(0xC2); //HEAD: C2 without save after disconected C0 with saving
     if (i < 2) {
       Serial1.write(ADDH[i]); //Receiver Address ADDH
     } else {
       Serial1.write(ADDL[i-2]); //Receiver Address ADDL
     }
     Serial1.write(0x18); //parameters speed rx/tx 9600 0.3k bod airspeed
     Serial1.write(0x17); //Receiver channel =0x17=23 (410M+23=433MHz) 1f-441mhz
     Serial1.write(0x44); //transparent transmission 20dbm
     delay(50); // add a delay to prevent data loss
   }
   pinsLoraLOW();
}
  1. the address generator itself:
void generateAddress(unsigned char* ADDH, unsigned char* ADDL) {
   randomSeed(micros());
   for (int i = 0; i < 2; i++) {
     ADDH[i] = random(100, 256);
   }
   for (int i = 0; i < 4; i++) {
     ADDL[i] = random(100, 256);
   }
}
  1. then in the enterNickname function, I need to generate these addresses and combine them to send the scan command on request:
char address[13]; //global variable
   unsigned char ADDH[2]; /global variablel
   unsigned char ADDL[4]; //global variable
generateAddress(&ADDH, &ADDL);
sprintf(address, "%02x%02x%02x%02x", ADDH[0], ADDH[1], ADDL[0], ADDL[1], ADDL[2], ADDL[3]);
  1. then, in the changeMyAddressOnAddressPair function, they need to be parsed, since these will be addresses already received from another subscriber, here you need to think about how to transfer them correctly so that you can then receive and parse them just as correctly:
void changeMyAddressOnAddressPair(String selectedNicknames) {
   incomingADDH = selectedNicknames.charAt(0);
   incomingADDL = selectedNicknames.charAt(1);
   // pass the received incomingADDH and incomingADDL addresses to the function for targeted message passing
   arduboy.clear(); // clear screen
   arduboy.setCursor(0, 0);
   arduboy.print("incomingADDH:"); //+ incomingADDH);
   arduboy.print(incomingADDH);
   arduboy.setCursor(0, 10);
   arduboy.print("incomingADDL:"); // + incomingADDL);
   arduboy.print(incomingADDL);
 
   //arduboy.display(); // display the image on the screen
   //handleButtonsHoldExit(); //exit menu
    // get out of here by pressing button A
   if (arduboy.justPressed(A_BUTTON)) {
         //arduboy.idle();
     sendFixedData("pair is made"); ///DEBUG
  
   } else if (arduboy.justPressed(B_BUTTON)) {
     sendFixedData("pairing rejected"); ///DEBUG
     setDefaultConfiguration();
     delay(500);
       return(1);
   }
   //makePairFunction();
}

and finally the pairing function itself:

void makePairFunction() {
   arduboy.clear(); // clear screen
   arduboy.setCursor(0, 0);
   arduboy.print("pair? Yes-A/No-B");

   // wait for button A or B to be pressed
    if (arduboy.justPressed(A_BUTTON)){
     // if button A is pressed, send "Y" (Yes) to another Arduino
     sendFixedData(nickname); //send your nickname
     sendFixedData(": ");
     sendFixedData("pair is made"); // create a pair
     arduboy.setCursor(0, 20);
     arduboy.print("pair is made");
     }
     //press A to continue communication in the address channel
     while (!arduboy.justPressed(A_BUTTON)) {
         arduboy.idle();
         }
     arduboy.clear();
    
     displayMessage();
     handleButtonsLR();
     drawKeyboard();
     handleButtonsHold_Pair(); //to send messages through the address channel
     handleButtonsHoldExit(); //button B to exit this dialog box to the previous one
     //arduboy.display();
   //} else {
     if (arduboy.justPressed(B_BUTTON)){
     // if button B is pressed, send "N" (No) to another Arduino
     sendFixedData("pairing rejected"); //reject creation of the pair
     handleButtonsHoldExit();
     }
   arduboy.display(); // display the image on the screen
}

the rest of the code is written and works correctly

transmit address function.
here I send the comma separately to avoid confusion:

void sendAddress(unsigned char* address) {
  
   // Send the ADDH part (2 bytes)
   Serial1.write(&address[0], 3);
   Lora.sendMessage(&address[0], 3);

   // Send comma
   unsigned char comma = ',';
   Serial1.write(&comma, 1);
   Lora.sendMessage(&comma);

   // Send part of ADDL (4 bytes)
   Serial1.write(&address[3], 6);
   Lora.sendMessage(&address[3], 6);

   Serial.println("Send address: ");
   Serial.print(address[0], HEX);
   Serial.print(",");
   Serial.println(address[2], HEX);
}

sending data over the address channel:

void sendFixedData(const char* data) {
   setAddrConfiguration();
   int len = strlen(data) + 1;
   byte buffer[len];
   memcpy(buffer, data, len);
   Serial1.write(buffer, len);

   byte addh = incomingADDH;
   byte addl = incomingADDL;
   String lenString = String(len);
  
   Lora.sendFixedMessage(addh, addl, buffer, lenString);
  
   setDefaultConfiguration(); //restore the default values of the addresses and the receive/transmit channel after the end of the transfer
}

a few pictures:


parameters was write correct from function setDefaultConfiguration()

Just to warn you: C++ doesn’t officially support variable length arrays, they’re only supported through a compiler extension.

Usually the advice to avoid that would be to use std::vector or (as it’s not available on Arduino) new, but since you’re using String anyway, you might as well just make buffer a String.

void sendFixedData(const char* data)
{
   setAddrConfiguration();
   
   String buffer { data };   
   size_t length { buffer.length() + 1 };
   
   Serial1.write(buffer.c_str(), length);

   byte addh = incomingADDH;
   byte addl = incomingADDL;
   String lengthString { length };
  
   Lora.sendFixedMessage(addh, addl, buffer.c_str(), lengthString);

   // Restore the default values of the addresses and the receive/transmit channel after the end of the transfer
   setDefaultConfiguration();
}

(Note: Untested.)

1 Like

this is the final function sendFixedData(const char* data).
message preprocessing is done in another function where there is a limited char array:

char fullMessage[42];
       strcpy(fullMessage, nickname);
       strcat(fullMessage, ": ");
       strcat(fullMessage, message);
       strcat(fullMessage, "(addrChan)");
       sendFixedData(fullMessage); //transmission over a dedicated channel when using the interlocutor's temporary address
       message[0] = '\0';

strcpy this function copies the character string pointed to by s2 into the memory location where the character string pointed to by s1 is located.

#include <string.h>
char *strcpy (char *s1, const char *s2);

strcat this function copies the character string pointed to by s2 to the end of the character string pointed to by s1. During copying, the character ‘\0’, which ends the string s1, is erased, and the first character of the string s2 is placed in its place.
The resulting string (the product of merging two strings) ends with a ‘\0’ character.

#include <string.h>
char *strcat (char *s1, const char *s2);

(Rex Zeschke)

Then why do you need the second buffer?

Couldn’t you just do this?

void sendFixedData(const char * data)
{
   setAddrConfiguration();
   
   size_t size { strlen(data) + 1 };
   Serial1.write(data, size);

   byte addh = incomingADDH;
   byte addl = incomingADDL;
   String lengthString { size };
  
   Lora.sendFixedMessage(addh, addl, buffer.c_str(), lengthString);

   // Restore the default values of the addresses and the receive/transmit channel after the end of the transfer
   setDefaultConfiguration();
}

Or better yet, let the caller specify the number of bytes to be copied:

void sendFixedData(const char * data, size_t size)
{
   setAddrConfiguration();

   Serial1.write(data, size);

   byte addh = incomingADDH;
   byte addl = incomingADDL;
   String lengthString { size };
  
   Lora.sendFixedMessage(addh, addl, buffer.c_str(), lengthString);

   // Restore the default values of the addresses and the receive/transmit channel after the end of the transfer
   setDefaultConfiguration();
}

Then you can do sendFixedData(fullMessage, strlen(fullMessage) + 1);, or something more efficient…

That’s going to be inefficient because strcat seeks through the entire message to find the null terminator at the end. (See Shlemiel the painter’s algorithm.)

You’d be better off doing:

// Make sure the buffer is actually null terminated before passing it to strcat
char fullMessage[42] = "";

// Use a pointer to make the concatenation more efficient
char * buffer = &fullMessage[0];
buffer = strcat(buffer, nickname);
buffer = strcat(buffer, ": ");
buffer = strcat(buffer, message);
buffer = strcat(buffer, "(addrChan)");

// No need to use strlen to get the size
size_t size { (buffer - &fullMessage[0]) + 1 };

// Formatting and size calculation complete, so send the data...
sendFixedData(fullMessage, size);

Which would cause the buffer pointer to always point to the null terminator ('\0'), thus skipping the seeking process of strcat.

It could be made better still by ensuring that the buffer won’t overflow. Unfortunately the C standard library’s string handling functions are pretty poor at that sort of thing, even with strncpy and strncat.

Something like this would be safer:

char * safe_strcat(char * destination_start, char * destination_end, const char * source)
{
	char * destination { destination_start };

	while(destination != destination_end)
	{
		char character = *source;
		++source;
	
		*destination = character;
		++destination;
		
		if(character == '\0')
			break;
	}
	
	return destination;
}

Then you could do:

// Make sure the buffer is actually null terminated before passing it to strcat
char fullMessage[42] = "";

// Create the end marker
char * end = &fullMessage[42];

// Use a pointer to make the concatenation more efficient
char * buffer = &fullMessage[0];
buffer = safe_strcat(buffer, end, nickname);
buffer = safe_strcat(buffer, end, ": ");
buffer = safe_strcat(buffer, end, message);
buffer = safe_strcat(buffer, end, "(addrChan)");

// No need to use strlen to get the size
size_t size { (buffer - &fullMessage[0]) + 1 };

// Formatting and size calculation complete, so send the data...
sendFixedData(fullMessage, size);
1 Like

yes i have looked at your suggestions they really look plausible and i will try your methods for sure but right now i am struggling with one task which causes:
‘Error compiling for board Arduboy FX’.
and this worries me a lot:
I call the address generator in the enterNickname function, which in turn I call in Setup, I enter my nickname there, save it and generate my address on the screen, it is displayed correctly and I see it on the arduboy screen:

void setup() {
...
setDefaultConfiguration(address);
...
}
generateAddress(&ADDH, &ADDL); //pass the address of each of the variables using the '&' operator
  sprintf(address, "%d%d", ADDH, ADDL);
  //setDefaultConfiguration(ADDH, ADDL);

then I need to pass this address to the function:

void setDefaultConfiguration(const char* address) {
     //set the state of pins M0 M1 to HIGH - MODE3
     DDRB &= ~(1 << 5); // Set PB5 input
     pinsLoraHIGH();

     // convert the address string back to two integer values
     int newADDH = strtol(&address[0], NULL, 16);
     int newADDL = strtol(&address[2], NULL, 16);

     // Send commands to configure the LoRa module
     for (int i = 0; i < 6; i++) {
         Serial1.write(0xC2); //HEAD: C2 without save after disconected C0 with saving
         byte bNewADDH = (byte)newADDH;
         byte bNewADDL = (byte)newADDL;
         Serial1.write(bNewADDH); //Receiver Address ADDH
         Serial1.write(bNewADDL); //Receiver Address ADDL
         //Serial1.write(0x00); //Receiver Address ADDH
         //Serial1.write(0x01); //Receiver Address ADDL
         Serial1.write(0x18); //parameters speed rx/tx 9600 0.3k bod airspeed
         Serial1.write(0x17); //Receiver channel =0x17=23 (410M+23=433MHz) 1f-441mhz
         Serial1.write(0x44); //transparent transmission 20dbm
         delay(50); // add a delay to prevent data loss
     }

     pinsLoraLOW();
}

this is the generator itself:

void generateAddress(int* ADDH, int* ADDL) {
   randomSeed(micros());
   *ADDH = random(100, 256);
   *ADDL = random(100, 256);
}

because of what the error … I’m trying to figure it out. I think the generator addresses needs to be changed.

Do you have the actual error message?

I can’t see anything obviously wrong with the code, so I’m guessing it might be a type mismatch or something that only makes sense with the full context, e.g. maybe ADDH and ADDL aren’t defined or something like that.

so faronly this ‘Error compiling for board Arduboy FX…nothing any more

i think what this error come from type data transmit, from one function to another function.
so…i think need do next…need change generator.
immediately in the generator you need to do the conversion to a common address and call this address where necessary with its subsequent parsing in other functions.
I will transfer part of the ADDH ADDL converter data to address directly in the generator function and pass this address as a pointer to other functions where the generator will be called, but after the generator has run, this data must be written to another variable such as addressDefault to avoid conflicts.

ps … it is suspicious that everything else works and does not arouse suspicion … it remains to organize the correct address exchange protocol, provided that a pair is created and organize data exchange within the formed pair

when I comment everything that is connected with address, the error goes away …
/* Sketch uses 24416 bytes (82%) of program storage space. Maximum is 29696 bytes.
Global variables use 2107 bytes (82%) of dynamic memory, leaving 453 bytes for local variables. Maximum is 2560 bytes. */

void setDefaultConfiguration() {
     //set the state of pins M0 M1 to HIGH - MODE3
     DDRB &= ~(1 << 5); // Set PB5 input
     pinsLoraHIGH();

     // convert the address string back to two integer values
    // int newADDH = strtol(&address[0], NULL, 16);
    // int newADDL = strtol(&address[2], NULL, 16);

     // Send commands to configure the LoRa module
     for (int i = 0; i < 6; i++) {
         Serial1.write(0xC2); //HEAD: C2 without save after disconected C0 with saving
        // byte bNewADDH = (byte)newADDH;
        // byte bNewADDL = (byte)newADDL;
        // Serial1.write(bNewADDH); //Receiver Address ADDH
        // Serial1.write(bNewADDL); //Receiver Address ADDL
         Serial1.write(0x00); //Receiver Address ADDH
         Serial1.write(0x01); //Receiver Address ADDL
         Serial1.write(0x18); //parameters speed rx/tx 9600 0.3k bod airspeed
         Serial1.write(0x17); //Receiver channel =0x17=23 (410M+23=433MHz) 1f-441mhz
         Serial1.write(0x44); //transparent transmission 20dbm
         delay(50); // add a delay to prevent data loss
     }
     pinsLoraLOW();
}

The compiler always gives an error message.
(Unless it crashes or gets stuck, which is very unlikely.)

Did you try looking further up in the output?

If you can’t see anything, copy the whole output and paste it here anyway.

Did you also comment out generateAddress?

What happens if you comment out generateAddress but leave in the ADDH & ADDL stuff in setDefaultConfiguration uncommented?

here the error is that we can’t take the “address” data and pass it to Serial1.write()… while spinning in the while (true) loop! you need to somehow add an interrupt to transfer the address data to Serial1 … I tried to transfer the function for setting the initial parameters immediately after entering the nickname and generating the address, but here it’s the same: “Error compiling for board Arduboy FX.”

unsigned char address[6] = {'\0'}; //for updated old generator
char addressStr[6];
void enterNickname() {
   // Set the initial coordinates for the cursor
   int cursor_x = 20;
   int cursor_y = 25;

   arduboy.setCursor(0, 0);
   arduboy.print("Enter Nickname:");
   arduboy.display();

   uint8_t currentLetterIndex = 0;

   while (true) {
     // Generate and store addresses
     generateAddress(address);
     String addressStr = String(address[0], HEX) + String(address[1], HEX);
  
     arduboy.display();
     handleButtonsLR();
     drawKeyboard();

     arduboy.pollButtons();

     arduboy.setCursor(cursor_x, cursor_y);
     arduboy print(nickname);
     arduboy.setTextColor(WHITE);
     arduboy.setCursor(selectedLetterX + 2, selectedLetterY + 2);
     arduboy.print(selectedLetter);

     if (arduboy.justPressed(A_BUTTON)) {
       int length = strlen(nickname);

       if (length < 16) {
         nickname[length] = selectedLetter;
         nickname[length + 1] = '\0';
       }
     }
     memcpy(nickname, nickname, sizeof(nickname));
    
     arduboy.setCursor(0, 40);
     arduboy.print(F("Exit: press key B.."));
     arduboy.display();
     while (!arduboy.pressed(B_BUTTON)) {
       arduboy.idle();
     }
     break;
   }
  
   if (arduboy.justPressed(B_BUTTON)) {
     DDRB &= ~(1 << 5); // Set PB5 input
     pinsLoraHIGH();

     // Send commands to configure the LoRa module
     for (int i = 0; i < 6; i++) {
       Serial1.write(0xC2); //HEAD: C2 without save after disconnected C0 with saving
       Serial1.write((unsigned char)address[0]); //Receiver Address ADDH
       Serial1.write((unsigned char)address[1]); //Receiver Address ADDL
       Serial1.write(0x18); //parameters speed rx/tx 9600 0.3k bod airspeed
       Serial1.write(0x17); //Receiver channel =0x17=23 (410M+23=433MHz) 1f-441mhz
       Serial1.write(0x44); //transparent transmission 20dbm
       delay(50); // add a delay to prevent data loss
     }
     pinsLoraLOW();
      
     // Display the nickname and address on the screen and in the console
     arduboy.clear();
     arduboy.setCursor(0, 0);
     arduboy.print(F("Your Nickname:"));
     arduboy print(nickname);
     arduboy.setCursor(0, 10);
     arduboy.print(F("Your address:"));
      
     arduboy.print(address[0], HEX);
     arduboy.print(F(","));
     arduboy.print(address[1], HEX);

     arduboy.setCursor(0, 30);
     arduboy.print(F("Press key A.."));
     arduboy.display();
      
     while (!arduboy.pressed(B_BUTTON)) {
       arduboy.idle();
     }
     break;
   }
}

need to sort out this misunderstanding…