Skip to content

MOWA2/Broki

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Broki

Broki logo

Broki is a C library, mainly targeting embedded devices, that implements a data broker to exchange data internally.

After creating streams, user can implement stream producers, that will send data into it and be received by stream subscribers. Identified by an id, a stream has a maximum payload size that is set at creation, but the user is free to send inferior payload length into it. This can be used to send serialized data, for example with protobuf, that defines a maximum payload size per messages, but depends on data that has been serialized.

Installation

Simply compile C source files that are contained in the src/ folder, and add it to you include path.

Configuration

For now, Broki only supports static memory allocation. You can tailor it to your needs by defining these defines:

  • BROKI_MAX_STREAMS: Maximum number of streams that can be created
  • BROKI_MAX_SUBSCRIBERS: Maximum number of subscribers for a single stream

Usage

#include "broki.h"

/* Initialize broki */
if( broki_init() != BROKI_OK ){
    /* Handle error */
}

/* Example: Simple C struct */
typedef struct example_struct{
    uint8_t dummy_byte;
}example_struct;

/* Create a stream with id 0 to exchange a C struct */
if( broki_create_stream(0, sizeof(example_struct)) != BROKI_OK ){
    /* Handle error */
}

/* Subscribe to the newly created stream */
if( broki_subscribe_stream(0, subscriber_cb) != BROKI_OK ){
    /* Handle error */
}

/* Send data into the newly created stream ("producer") */
example_struct example_data = { .dummy_byte = 0x55 };
if( broki_send_in_stream(0, &example_data, sizeof(example_struct)) != BROKI_OK ){
    /* Handle error */
}

/* "Subscribers" callbacks will be called (subscriber_cb here) */

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Using it in projects

As per the permissive license, you can use this library freely, without any counterparts, even in commercial projects. But to promote this library, feel free to share that you use it !

About

Internal data broker, mainly targeting embedded devices

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages