Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define a standard API for radio transceivers' drivers #916

Closed
rousselk opened this issue Mar 25, 2014 · 3 comments
Closed

Define a standard API for radio transceivers' drivers #916

rousselk opened this issue Mar 25, 2014 · 3 comments
Labels
Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Type: question The issue poses a question regarding usage of RIOT

Comments

@rousselk
Copy link
Contributor

It seems to me that having a standard API (i.e. an interface, or more precisely--since we're using C language--a struct of function pointers) that all drivers for radio transceivers have to comply to, would be a welcome addition.

It would considerably ease the task of developing MAC/RDC protocols, that actually need to control directly radio transceivers for acceptable efficiency.

It should also simplify the interface with the 'transceiver' module, which currently uses message passing for control. The message passing method is elegant and flexible, but is quite RAM-hungry; on low-end devices (like MSP430, which only have some Kbytes of RAM) this could quickly become an issue, if we want to develop heavyweight applications (e.g. with many threads and especially their stack space) along with advanced radio communication (with MAC, routing and so on).

Most of these drivers already have a very similar set of "public" functions, so the adaptation shouldn't be long nor hard.

@miri64
Copy link
Member

miri64 commented Mar 25, 2014

see #752

@rousselk
Copy link
Contributor Author

Actually, I thought about something much simpler, and specific to radio drivers. Something like:

#include <stdbool.h>

...

typedef void (* receive_callback_t)(void *buf, unsigned len);

typedef enum {
    TX_OK,
    TX_COLLISION,
    TX_NOACK,
    TX_ERROR,
} tx_status_t;

typedef struct {
    void (* on)(void);
    void (* off)(void);
    tx_status_t (* send)(void *buf, unsigned len);
    void (* set_receive)(receive_callback_t recv_func);
    void (* set_channel)(unsigned chan);
    unsigned (* get_channel)(void);
    void (* set_address)(uint16_t addr);
    uint16_t (* get_address)(void);
    void (* set_long_address)(uint64_t addr);
    uint64_t (* get_long_address)(void);
    void (* set_pan_id)(uint16_t pan);
    uint16_t (* get_pan_id)(void);
    bool (* channel_clear)(void);
} ieee802154_radio_driver_t;

Maybe should I actually go on and propose a PR with an API proposal?...

@rousselk
Copy link
Contributor Author

Done, my proposition is in #925.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Type: question The issue poses a question regarding usage of RIOT
Projects
None yet
Development

No branches or pull requests

2 participants