uint8_t token[8];
} __attribute__((packed));
+#define HAL_EV_MESH_NETWORK_PROXY_ADDED 0xDF
+struct hal_ev_mesh_network_proxy_added {
+ uint8_t status;
+ uint8_t uuid[16];
+ uint8_t token[8];
+} __attribute__((packed));
+
+
#endif //_BT_HAL_MSG_H_
INFO("MESH: Proxy added: %s (%s)\n", interface, path);
if (!strcmp(interface, BT_HAL_MESH_NETWORK_INTERFACE)) {
+ struct hal_ev_mesh_network_proxy_added ev;
INFO("Mesh: Network Proxy added");
+
/* Save Global proxy */
net_proxy = proxy;
if (net_proxy)
INFO("Mesh: Net Proxy [%p]", net_proxy);
+
+ memset(&ev, 0, sizeof(ev));
+ ev.status = BT_STATUS_SUCCESS;
+
+ /* Send event cb */
+ if (mesh_event_cb)
+ mesh_event_cb(HAL_EV_MESH_NETWORK_PROXY_ADDED,
+ (void*)&ev, sizeof(ev));
+
return;
}
(bt_uuid_t*)&ev->uuid);
}
+static void __bt_hal_mesh_network_proxy_added(void *buf, uint16_t len)
+{
+ struct hal_ev_mesh_network_proxy_added *ev = buf;
+ if (bt_hal_mesh_cbacks->network_proxy_added_cb)
+ bt_hal_mesh_cbacks->network_proxy_added_cb(ev->status);
+}
+
static void __bt_hal_handle_network_scan_result(void *buf, uint16_t len)
{
struct hal_ev_mesh_scan_result *ev = buf;
return;
switch (message) {
+ case HAL_EV_MESH_NETWORK_PROXY_ADDED:
+ DBG("Mesh Event: HAL_EV_MESH_NETWORK_PROXY_ADDED");
+ __bt_hal_mesh_network_proxy_added(buf, len);
+ break;
case HAL_EV_MESH_NETWORK_ATTACHED:
DBG("Mesh Event: HAL_EV_MESH_NETWORK_ATTACHED");
__bt_hal_mesh_network_attached(buf, len);
} bt_mesh_key_op_e;
/** Callback Signatures */
+typedef void (*btmesh_network_proxy_added_callback)(bt_status_t status);
+
typedef void (*btmesh_network_attached_callback)(bt_status_t status,
bt_mesh_token_t *token, bt_uuid_t *uuid);
typedef struct {
/** set to sizeof(btmesh_callbacks_t) */
size_t size;
+ btmesh_network_proxy_added_callback network_proxy_added_cb;
btmesh_network_attached_callback network_attached_cb;
btmesh_network_destroyed_callback network_destroyed_cb;
btmesh_network_scan_status_callback scan_status_cb;
EVENT(OAL_EVENT_GATTC_EXECUTE_WRITE) /* gattc execute write */\
EVENT(OAL_EVENT_GATTS_REQUEST_ACQUIRE_WRITE) /* gattc acquire write */\
EVENT(OAL_EVENT_GATTS_REQUEST_ACQUIRE_NOTIFY) /* gattc acquire notify */\
+ EVENT(OAL_EVENT_MESH_NETWORK_PROXY_ADDED) /* mesh network proxy_added */\
EVENT(OAL_EVENT_MESH_NETWORK_ATTACHED) /* mesh network attached */\
EVENT(OAL_EVENT_MESH_NETWORK_DESTROYED) /* mesh network destroyed */\
EVENT(OAL_EVENT_MESH_SCAN_STARTED) /* mesh network scan start status */\
typedef struct {
oal_status_t status;
+} event_mesh_network_proxy_added_t;
+
+typedef struct {
+ oal_status_t status;
uint8_t token[8];
oal_uuid_t uuid;
} event_mesh_network_attached_t;
} while (0)
/* Forward declaration: Callbacks from HAL */
+static void mesh_network_proxy_added_callback(bt_status_t status);
static void mesh_network_attached_callback(bt_status_t status,
bt_mesh_token_t *token, bt_uuid_t *uuid);
static void mesh_network_destroyed_callback(bt_status_t status,
static btmesh_callbacks_t sBluetoothMeshCallbacks = {
.size = sizeof(sBluetoothMeshCallbacks),
+ .network_proxy_added_cb = mesh_network_proxy_added_callback,
.network_attached_cb = mesh_network_attached_callback,
.network_destroyed_cb = mesh_network_destroyed_callback,
.scan_status_cb = mesh_network_scan_status_callback,
};
/* Mesh HAL event handlers */
+static void mesh_network_proxy_added_callback(bt_status_t status)
+{
+ event_mesh_network_proxy_added_t *event = g_new0(event_mesh_network_proxy_added_t, 1);
+
+ event->status = convert_to_oal_status(status);
+ BT_INFO("Mesh Event: Network Proxy Added, status: [%s]",
+ status2string(status));
+
+ send_event_bda_trace(OAL_EVENT_MESH_NETWORK_PROXY_ADDED,
+ event, sizeof(event_mesh_network_proxy_added_t), NULL);
+}
+
static void mesh_network_attached_callback(bt_status_t status,
bt_mesh_token_t *token, bt_uuid_t *uuid)
{
if (adapter_le_cb)
adapter_le_cb(event_type, event_data);
break;
+ case OAL_EVENT_MESH_NETWORK_PROXY_ADDED:
case OAL_EVENT_MESH_NETWORK_ATTACHED:
case OAL_EVENT_MESH_NETWORK_DESTROYED:
case OAL_EVENT_MESH_SCAN_STARTED:
_bt_mesh_msg_handler(event);
}
+static void __handle_mesh_network_proxy_added_event(
+ event_mesh_network_proxy_added_t *event)
+{
+ int result = BLUETOOTH_ERROR_NONE;
+
+ if (event->status != OAL_STATUS_SUCCESS)
+ result = BLUETOOTH_ERROR_INTERNAL;
+
+ /* Handle DBUS Context return */
+ BT_INFO("Mesh: Handle DBUS Context return");
+ __bt_mesh_handle_pending_request_info(result,
+ BT_MESH_INIT,
+ NULL, 0);
+}
+
static void __handle_mesh_network_attached_event(
event_mesh_network_attached_t *event)
{
BT_INFO("Mesh: Provisioning started event");
switch (event_type) {
+ case OAL_EVENT_MESH_NETWORK_PROXY_ADDED:
+ __handle_mesh_network_proxy_added_event(
+ (event_mesh_network_proxy_added_t*)event_data);
+ BT_PERMANENT_LOG("Mesh: Network proxy added!!");
+ break;
case OAL_EVENT_MESH_NETWORK_ATTACHED:
__handle_mesh_network_attached_event(
(event_mesh_network_attached_t*)event_data);
BLUETOOTH_ERROR_ALREADY_INITIALIZED != ret)
BT_ERR("Mesh: Mesh enable failed: %d", ret);
- /* Handle DBUS Context return */
- BT_INFO("Mesh: Handle DBUS Context return");
- __bt_mesh_handle_pending_request_info(ret,
- BT_MESH_INIT,
- NULL, 0);
-
/* Reset launch timer ID */
BT_INFO("Mesh: Timer ID after expiry [%u]", launch_timer);
launch_timer = 0;