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:
parent
500b59809f
commit
96aaaadca8
1 changed files with 21 additions and 0 deletions
|
@ -24,6 +24,7 @@
|
||||||
#include <bluetooth/conn.h>
|
#include <bluetooth/conn.h>
|
||||||
#include <bluetooth/log.h>
|
#include <bluetooth/log.h>
|
||||||
|
|
||||||
|
#include "gap_internal.h"
|
||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
#include "rpc.h"
|
#include "rpc.h"
|
||||||
|
|
||||||
|
@ -51,6 +52,7 @@ static int recv_cb(int channel, int request, int len, void *p_data)
|
||||||
|
|
||||||
switch (request) {
|
switch (request) {
|
||||||
case IPC_MSG_TYPE_MESSAGE:
|
case IPC_MSG_TYPE_MESSAGE:
|
||||||
|
rpc_deserialize(p_data, len);
|
||||||
break;
|
break;
|
||||||
case IPC_MSG_TYPE_FREE:
|
case IPC_MSG_TYPE_FREE:
|
||||||
/* TODO: Try to send another message immediately */
|
/* 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;
|
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)
|
int bt_enable(bt_ready_cb_t cb)
|
||||||
{
|
{
|
||||||
struct device *gpio;
|
struct device *gpio;
|
||||||
|
@ -145,6 +164,8 @@ int bt_enable(bt_ready_cb_t cb)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bt_ready_cb = cb;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue