Wisblock-API new thread for BG77 Serial1 communications

Hi,
I need help with an application that takes along time in the evetn handler. And was wondering if it was a good idea to add another thread to handle Serial1 communications with a RAK5860 BG77 module.

I have setup an interrupt from an RFID reader, which works. It fires and calls the app_event_handler and in there I then read the card number with g_task_event_type = NFC_TRIGGER.

However, during the normal timed g_task_event_type & STATUS I may be busy reading the GPS and using the cellular, which can take a few minutes.

During this time, no interrupts are triggered from the RFID reader. Which is undesirable. So would it be better to put the BG77 comms on another thread like the Bluetooth or lora comms? So that app_event_handler is free to handle the RFID stuff quickly?

I also have an OLED display on the I2C along with the RFID card reader, so it makes sense to keep both of these under the app_event_handler.

How would I go about setting up another thread much like the lora_data_handler or ble?
Thanks.

Welcome to the forum @RichardBH

Yes, it should be possible to put the BG77 communication into a separate task.

I guess you are using RAK4631?

Here is a code snippet that creates an empty task from WisBlock-API bool init_app(void) call:

/** BG77 task handle */
TaskHandle_t bg77_task_handle;
/** Task declaration */
void bg77_task(void *pvParameters);

bool init_app(void)
{
// usual stuff here
	if (!xTaskCreate(epd_task, "BG77", 4096, NULL, TASK_PRIO_LOW, &bg77_task_handle))
#endif
	{
		Serial.println("Failed to start BG77 task");
	}
}

/**
 * @brief Task to communicate with BG77
 *
 * @param pvParameters unused
 */
void bg77_task(void *pvParameters)
{
	Serial.println("BG77 Task started");

	// Task runs forever in a while loop
	while (1)
	{
		// Do your BG77 stuff here
		// ...
	}
}

Thank you so much! That works great.
A couple of typos later…

/** BG77 task handle */
TaskHandle_t bg77_task_handle;
/** Task declaration */
void bg77_task(void *pvParameters);

bool init_app(void)
{
// usual stuff here
	if (!xTaskCreate(bg77_task, "BG77", 4096, NULL, TASK_PRIO_LOW, &bg77_task_handle))
#endif
	{
		Serial.println("Failed to start BG77 task");
	}
}

/**
 * @brief Task to communicate with BG77
 *
 * @param pvParameters unused
 */
void bg77_task(void *pvParameters)
{
	Serial.println("BG77 Task started");

	// Task runs forever in a while loop
	while (1)
	{
		// Do your BG77 stuff here
		// ...
	}
}