1. Home
  2. Docs
  3. Code Overview
  4. User-defined Messages

User-defined Messages

User-defined messages are pre-defined Hexabitz messages that you create for your own applications. It’s like defining a button callback with your own code inside.

In this article, we will show you how to define your own message through these steps:

1. Define message codes in project.h

#define CODE_USER_MESSAGE_01         70

#define CODE_USER_MESSAGE_02         71

Note: you should define the message code in sender and receiver modules and wherever you will use the user message. The available codes for user messages are 70 to 99.

2. Define user message parser in main.c.

This should be after UserTask( ). It is similar to module messaging parser available in each module source file.

/* --- User message parser. */
BOS_Status User_MessagingParser(uint16_t code, uint8_t port, uint8_t src, uint8_t dst, uint8_t shift)

{
 BOS_Status result = BOS_ERR_UnknownMessage;

  switch (code)
  {
    case CODE_USER_MESSAGE_01 :
    IND_blink(100);
    break;

    case CODE_USER_MESSAGE_02 :
    IND_blink(200);
    break;

    default:
    break;
  }

  return result;
}

3. Send your user-defined message from another module (or hardware)

SendMessageToModule(ModuleID, CODE_USER_MESSAGE_01, 0);

How can we help?