Skip to content

Instantly share code, notes, and snippets.

@lupyuen
Last active May 7, 2020 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lupyuen/5da47d633315039e76262434a4faae46 to your computer and use it in GitHub Desktop.
Save lupyuen/5da47d633315039e76262434a4faae46 to your computer and use it in GitHub Desktop.
NimBLE Porting Layer: Additional Notes

NimBLE Porting Layer: Additional Notes

This article is linked from https://lupyuen.github.io/pinetime-rust-mynewt/articles/dfu

ble_npl_eventq_get

struct ble_npl_event *
ble_npl_eventq_get(
struct ble_npl_eventq *evq,
ble_npl_time_t tmo)

Pull a single Event from an Event Queue

This function is implemented in the NimBLE Porting Layer for Mynewt like this...

static inline struct ble_npl_event *
ble_npl_eventq_get(struct ble_npl_eventq *evq, ble_npl_time_t tmo)
{
    struct os_event *ev;

    if (tmo == BLE_NPL_TIME_FOREVER) {
        ev = os_eventq_get(&evq->evq);
    } else {
        ev = os_eventq_poll((struct os_eventq **)&evq, 1, tmo);
    }

    return (struct ble_npl_event *)ev;
}

See os_eventq_get and os_eventq_poll

ble_npl_event_init

void
ble_npl_event_init(
struct ble_npl_event *ev,
ble_npl_event_fn *fn,
void *arg)

Create an Event and initialise it

This function is implemented in the NimBLE Porting Layer for Mynewt like this...

static inline void
ble_npl_event_init(struct ble_npl_event *ev, ble_npl_event_fn *fn,
                   void *arg)
{
    memset(ev, 0, sizeof(*ev));
    ev->ev.ev_queued = 0;
    ev->ev.ev_cb = (os_event_fn *)fn;
    ev->ev.ev_arg = arg;
}

See ev_queued, ev_cb and ev_arg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment