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

BLE::init() should be non-blocking #90

Closed
rgrover opened this issue Oct 28, 2015 · 2 comments
Closed

BLE::init() should be non-blocking #90

rgrover opened this issue Oct 28, 2015 · 2 comments

Comments

@rgrover
Copy link
Contributor

rgrover commented Oct 28, 2015

Currently the demo applications call init() and then expect to operate on the BLE instance rightaway. This model may not apply to stacks where initialization requires several rounds of blocking message passing between the host and the controller. BLE::init() should be non-blocking and should result in a completionCallback() when initialization is complete. It should also be possible for the application to determine if initailization is complete. Any use of a BLE instance before its initialization completes should return an error.

@rgrover
Copy link
Contributor Author

rgrover commented Oct 28, 2015

!This may result in a rewrite of all demos! The Nordic stack initializes rightaway, and so existing demos should continue to work against Nordic.

mbed-classic demos would look something like:

main() {
    BLE::Instance().init();
    while (!BLE::Instance().hasInitialized()) {
        /* spin wait */
    }

    /* rest of the initialization ending in the waitForEvent loop */

}

whereas mbedOS demos would look like:

void bleInitComplete(BLE &ble, ble_error_t error)
{
    WsfTrace("bleInitComplete");

    if (error != BLE_ERROR_NONE) {
        WsfTrace("initailization failed with error: %u", error);
        return;
    }

    if (ble.getInstanceID() == BLE::DEFAULT_INSTANCE) {
        /* use the BLE instance */
    }
}

extern "C" void app_start(int argc, char *argv[])
{
    BLE::Instance().init(bleInitComplete);
}

@rainierwolfcastle
Copy link

ARM Internal Ref: IOTSFW-1098

rgrover pushed a commit to ARMmbed/ble-nrf51822 that referenced this issue Oct 30, 2015
=============

* Update init() to match the changes around initializationCompleteCallback.
  Also implemented hasInitialized().
  Refer to ARMmbed/ble#91 and ARMmbed/ble#90.

* Some changes for memory savings. Certain singletons are now allocated
  dynamically; so some memory may not be needed if the application exercises
  limited functionality. Also reduced the size of some global tables for
  memory savings; affected tables/constants: UUID_TABLE_MAX_ENTRIES (down to 4),
  DEVICE_MANAGER_MAX_BONDS (down to 2).
rgrover pushed a commit to ARMmbed/ble-nrf51822 that referenced this issue Oct 30, 2015
=============

* Update init() to match the changes around initializationCompleteCallback.
  Also implemented hasInitialized().
  Refer to ARMmbed/ble#91 and ARMmbed/ble#90.

* Some changes for memory savings. Certain singletons are now allocated
  dynamically; so some memory may not be needed if the application exercises
  limited functionality. Also reduced the size of some global tables for
  memory savings; affected tables/constants: UUID_TABLE_MAX_ENTRIES (down to 4),
  DEVICE_MANAGER_MAX_BONDS (down to 2).
@rgrover rgrover closed this as completed in 5c7f26e Nov 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants