Thread communication
Between thread communication.
Zephyr solution with message queue objects is used for between thread communication. Communication interface is defined in thread_com.h
and thread_com.c
files.
Two queues are defined in .c file:
setting_que - handling setting message communication (received messages via BLE and LoRa from user, defining new settings or sending in command messages)
message_que - handling response messages from firmware to user (returning values and requested messages)
Each buffer is equipped with put and get function. Each queue is defined to contain max of 2 messages, defined by a message struct
providing receiving thread with message id, its actual length and byte array message. Max message length is determined by
#define MAX_MES_LENGTH_BYTES 255
Message id-s are defined in definitions.h
file.
Put message
When new message is send by a thread, depending on used queue functions
are used. Put function takes id, message and its length and copy them into message_struct, provided message is not to long. If message buffer is full of non-opened messages, function purges the oldest message from the buffer.
Get message
Provided there is unread message, function copies its content and id to provided buffers and return message length. Message is deleted from queue.
Function is non/blocking and returns 0 if there is no message or negative error code on error. New message can be retrieved from the buffer by using get functions
Last updated