Bluetooth: nble: Adding NBLE ready callback

Refactored Johan Hedberg's code adding callback to be called when NBLE
is up.

Change-Id: I2a8a2238942c0adae2a5c47cfe94d8f2b1112810
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
Andrei Emeltchenko 2016-01-21 12:08:38 +02:00 committed by Anas Nashif
commit 96aaaadca8

View file

@ -24,6 +24,7 @@
#include <bluetooth/conn.h>
#include <bluetooth/log.h>
#include "gap_internal.h"
#include "uart.h"
#include "rpc.h"
@ -51,6 +52,7 @@ static int recv_cb(int channel, int request, int len, void *p_data)
switch (request) {
case IPC_MSG_TYPE_MESSAGE:
rpc_deserialize(p_data, len);
break;
case IPC_MSG_TYPE_FREE:
/* TODO: Try to send another message immediately */
@ -64,6 +66,23 @@ static int recv_cb(int channel, int request, int len, void *p_data)
return 0;
}
static bt_ready_cb_t bt_ready_cb;
void on_nble_up(void)
{
BT_DBG("");
if (bt_ready_cb) {
bt_ready_cb(0);
}
ble_get_version_req(NULL);
}
void on_ble_get_version_rsp(const struct ble_version_response *rsp)
{
BT_DBG("");
}
int bt_enable(bt_ready_cb_t cb)
{
struct device *gpio;
@ -145,6 +164,8 @@ int bt_enable(bt_ready_cb_t cb)
return -ENODEV;
}
bt_ready_cb = cb;
return 0;
}