GVariant *param = NULL;
GArray *dbus_data = NULL;
bluetooth_mesh_scan_result_t *info = NULL;
+ BT_INFO("Mesh: BT_MESH_SCAN_RESULT");
g_variant_get(parameters, "(iv)", &result, ¶m);
dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar));
GVariant *param = NULL;
GArray *dbus_data = NULL;
bluetooth_mesh_authentication_request_t *info = NULL;
+ BT_INFO("Mesh: BT_MESH_AUTHENTICATION_REQ");
g_variant_get(parameters, "(iv)", &result, ¶m);
dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar));
g_variant_unref(param);
info = &g_array_index(dbus_data, bluetooth_mesh_authentication_request_t, 0);
+ BT_INFO("Mesh: Authentication Type [%d]", info->auth_type);
_bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_AUTHENTICATION_REQUEST,
result, info,
GVariant *param = NULL;
GArray *dbus_data = NULL;
bluetooth_mesh_provisioning_result_t *info = NULL;
+ BT_INFO("Mesh: BT_MESH_PROVISIONING_RESULT");
g_variant_get(parameters, "(iv)", &result, ¶m);
dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar));
GVariant *param = NULL;
GArray *dbus_data = NULL;
bluetooth_mesh_node_discover_t *info = NULL;
-
+ BT_INFO("Mesh: Node browsed event");
g_variant_get(parameters, "(iv)", &result, ¶m);
dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar));
info = &g_array_index(dbus_data, bluetooth_mesh_node_discover_t, 0);
+ BT_INFO("Mesh: Send Node Browse event: Net UID [%s], Node UUID [%s]",
+ info->net_uuid, info->dev_uuid);
_bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_NODE_BROWSED,
result, info,
event_info->cb, event_info->user_data);
if (size == 0) {
BT_ERR("Mesh: No Appkeys created for the NetKey in the network");
- result = BLUETOOTH_ERROR_NOT_FOUND;
}
for (i = 0; i < size; i++) {
static struct l_dbus *dbus = NULL;
static struct l_dbus_client *client = NULL;
-static struct l_dbus_proxy *net_proxy;
+static struct l_dbus_proxy *net_proxy = NULL;
static struct l_dbus_message *agent_msg;
static handle_stack_msg mesh_event_cb = NULL;
typedef struct meshcfg_app meshcfg_app;
/* Will contain critical data related to local Mesh Network */
-GSList *mesh_apps;
+static GSList *mesh_apps = NULL;
struct meshcfg_node {
return l_util_from_hexstring(uuid, &sz);
}
case MESH_AGENT_IFACE: {
- memcpy(uuid, is_prov ? (void*) &dbus_path[22] : (void*) &dbus_path[23], 32);
+ memcpy(uuid, is_prov ? (void*) &dbus_path[16] : (void*) &dbus_path[23], 32);
uuid[32] = '\0';
return l_util_from_hexstring(uuid, &sz);
}
static void __mesh_hal_free_elements(gpointer data)
{
meshcfg_el *element = (meshcfg_el*) data;
+ if (!element)
+ return;
g_free(element->path);
if (element->models)
g_slist_free_full(element->models, g_free);
+
+ element->models = NULL;
g_free(element);
}
+static bool __bt_mesh_proxy_check(meshcfg_app *app)
+{
+ /* Check meshd stack Vis up or not */
+ if (!dbus) {
+ ERR("Mesh: DBUS is not UP!, possibly stack not Up!");
+ return false;
+ }
+ /* Check Network Proxy is added or not */
+ if (!net_proxy) {
+ ERR("Mesh: Network proxy is not attached yet!");
+ return false;
+ }
+
+ if (app) {
+ /* Check App management proxyis added or not */
+ if (!app->mgmt_proxy) {
+ ERR("Mesh: Network proxy is not attached yet!");
+ return false;
+ }
+ /* Check App Node Proxy is added or not */
+ if (!app->proxy) {
+ ERR("Mesh: Node proxy is not attached yet!");
+ return false;
+ }
+ }
+ return true;
+}
+
static void __bt_hal_mesh_destroy_app_object(gpointer data)
{
return;
mesh_apps = g_slist_remove(mesh_apps, app);
- g_free(app->path);
- g_free(app->agent_path);
- if (app->elements)
+ if (app->path) {
+ INFO("Mesh: App path [%s] ", app->path);
+ g_free(app->path);
+ }
+ if (app->agent_path) {
+ INFO("Mesh: Agent Path [%s]", app->agent_path);
+ g_free(app->agent_path);
+ }
+
+ if (app->elements) {
+ INFO("Mesh: Total elements present in app [%d]",
+ g_slist_length(app->elements));
g_slist_free_full(app->elements, __mesh_hal_free_elements);
+ }
g_free(app);
}
-static void __mesh_client_connected(struct l_dbus *dbus, void *user_data)
+static void __mesh_client_connected(struct l_dbus *dbus_obj, void *user_data)
{
ERR("MESH: D-Bus client connected\n");
+ dbus = dbus_obj;
+ if (dbus)
+ INFO("Mesh: MeshD connected: dbus [%p]", dbus);
}
-static void __mesh_client_disconnected(struct l_dbus *dbus, void *user_data)
+static void __mesh_client_disconnected(struct l_dbus *dbus_obj, void *user_data)
{
ERR("MESH: D-Bus client disconnected, possibly meshd exited \n");
/* TODO: Send event to app about meshd termination & then remove all mesh apps */
+ INFO("Mesh: Total number of networks present [%d]",
+ g_slist_length(mesh_apps));
+
if (mesh_apps) {
g_slist_free_full(mesh_apps, __bt_hal_mesh_destroy_app_object);
mesh_apps = NULL;
}
+ /* Set DBUS to NULL */
+ if (dbus)
+ INFO("Mesh: dbus [%p]", dbus);
+ if (net_proxy)
+ INFO("Mesh: net proxy [%p]", net_proxy);
+
+ dbus = NULL;
+ net_proxy = NULL;
+ INFO("Mesh: All apps cleaned up after meshd exited");
}
static gint __compare_proxy_path(gconstpointer data, gconstpointer user_data)
INFO("MESH: Proxy added: %s (%s)\n", interface, path);
if (!strcmp(interface, BT_HAL_MESH_NETWORK_INTERFACE)) {
-
+ INFO("Mesh: Network Proxy added");
/* Save Global proxy */
net_proxy = proxy;
+ if (net_proxy)
+ INFO("Mesh: Net Proxy [%p]", net_proxy);
return;
}
if (!strcmp(interface, BT_HAL_MESH_MANAGEMENT_INTERFACE)) {
GSList *l;
meshcfg_app *app;
+ INFO("Mesh: Mgmt Proxy added");
INFO("Mesh: Number of mesh app present in list [%d]",
g_slist_length(mesh_apps));
l = g_slist_find_custom(mesh_apps, path, __compare_proxy_path);
}
if (!strcmp(interface, BT_HAL_MESH_NODE_INTERFACE)) {
-
+ INFO("Mesh: Node Proxy added");
GSList *l;
meshcfg_app *app;
l = g_slist_find_custom(mesh_apps, path, __compare_proxy_path);
if (l) {
app = l->data;
- app->mgmt_proxy = proxy;
+ app->proxy = proxy;
} else {
ERR("Mesh: app not found for Node proxy");
}
}
}
-static void __mesh_dbus_client_ready(struct l_dbus_client *client,
+static void __mesh_dbus_client_ready(struct l_dbus_client *client_obj,
void *user_data)
{
INFO("Mesh: D-Bus client ready: bluetooth-meshd connected \n");
- /* TODO: Book keeping */
+ client = client_obj;
}
static void __mesh_ready_callback(void *user_data)
if (!dbus)
return false;
+ INFO("Mesh: Got dbus [%p]", dbus);
+
if (!l_dbus_set_ready_handler(dbus, __mesh_ready_callback, NULL, NULL))
return false;
struct l_dbus_message *msg, void *user_data)
{
struct l_dbus_message_iter iter_cfg;
+ char *path;
meshcfg_app *app = (meshcfg_app*) user_data;
INFO("Mesh: Attach Node Reply: App path [%s] Agent Path [%s]",
app->path, app->agent_path);
}
if (!l_dbus_message_get_arguments(msg, "oa(ya(qa{sv}))",
- &app->path, &iter_cfg))
+ &path, &iter_cfg))
goto failed;
INFO("Mesh: Attached with path %s\n", app->path);
ev->is_remote_devkey = rmt;
ev->netkey_idx = idx;
ev->data_len = n;
- memcpy(ev->data, buf, n);
+ memcpy(ev->data, data, n);
size += n;
+ INFO("Mesh: Src [0x%2.2x]", src);
+ INFO("Mesh: Is Remote [%s]", rmt ? "YES" : "NO");
+ INFO("Mesh: NetKey Idx [0x%2.2x]", idx);
/* Send DevKeyMessage Received event */
if (mesh_event_cb) {
mesh_event_cb(HAL_EV_MESH_DEVKEY_MESSAGE_EVENT, (void*)buf, size);
uint8_t cnt;
struct hal_ev_mesh_provision_finished ev;
struct hal_ev_mesh_provision_data_request req;
+ char *uuid_string;
meshcfg_app *app = user_data;
+ INFO("Mesh: provisioning data requested app path [%s]",
+ app->path);
+ uuid_string = l_util_hexstring(app->uuid, 16);
+ INFO("Mesh: Network UUID [%s]", uuid_string);
+
memset(&ev, 0, sizeof(ev));
memset(&req, 0, sizeof(req));
memcpy(ev.net_uuid, app->uuid, 16);
memcpy(req.net_uuid, app->uuid, 16);
+ l_free(uuid_string);
if (!l_dbus_message_get_arguments(msg, "y", &cnt)) {
ERR("Mesh: Cannot parse request for prov data");
req.count = cnt;
if (mesh_event_cb)
mesh_event_cb(HAL_EV_MESH_PROVISIONING_DATA_REQUEST,
- (void*)&ev, sizeof(ev));
+ (void*)&req, sizeof(req));
l_dbus_message_ref(msg);
return NULL;
if (!l_dbus_register_interface(dbus, BT_HAL_MESH_PROVISION_AGENT_INTERFACE,
__bt_hal_mesh_setup_agent_iface, NULL, false)) {
ERR("Mesh: Unable to register agent interface");
- return false;
+ //return false;
}
INFO("Mesh: Register Agent path [%s]", ptr->agent_path);
if (!ptr)
return false;
+ if (!dbus)
+ return false;
if (!l_dbus_register_interface(dbus, BT_HAL_MESH_APPLICATION_INTERFACE,
__bt_hal_mesh_setup_app_iface, NULL, false)) {
ERR("Mesh: Failed to register interface %s",
BT_HAL_MESH_APPLICATION_INTERFACE);
- return false;
+ //return false;
}
if (!l_dbus_register_interface(dbus, BT_HAL_MESH_PROVISIONER_INTERFACE,
__bt_hal_mesh_setup_prov_iface, NULL, false)) {
ERR("Mesh: Failed to register interface %s",
BT_HAL_MESH_PROVISIONER_INTERFACE);
- return false;
+ //return false;
}
if (!l_dbus_register_object(dbus, ptr->path, NULL, NULL,
__bt_hal_mesh_setup_ele_iface, NULL, false)) {
ERR("Mesh: Failed to register interface %s",
BT_HAL_MESH_ELEMENT_INTERFACE);
- return false;
+ //return false;
}
INFO("Mesh: Number of elements to be registsred [%d]",
- g_slist_length(ptr->elements));
+ g_slist_length(ptr->elements));
g_slist_foreach(ptr->elements, __bt_hal_mesh_register_element_obj, ptr);
INFO("Mesh: Add Object manager Interface: app path [%s]", ptr->path);
if (!l_dbus_object_add_interface(dbus, ptr->path,
L_DBUS_INTERFACE_OBJECT_MANAGER, NULL)) {
- ERR("Mesh: Failed to add interface %s",
- L_DBUS_INTERFACE_OBJECT_MANAGER);
- return false;
- }
+ ERR("Mesh: Failed to add interface %s",
+ L_DBUS_INTERFACE_OBJECT_MANAGER);
+ return false;
+ }
INFO("Mesh: Application Register completed");
return true;
INFO("Mesh: Created element index [%d] path [%s]",
elem->index, elem->path);
}
+ INFO("Mesh: This is model [0x%4.4x] for Element [0x%2.2x]",
+ model_info->model, elem->index);
/* Add Model in the element */
elem->models = g_slist_append(elem->models, model_info);
- INFO("Mesh: total models of the element with index [%d] is [%d]",
+ INFO("Mesh: Model added in element: total Model count in elem [%d] is [%d]",
elem->index, g_slist_length(elem->models));
}
if (is_prov) {
app->path = g_strdup_printf("/tizen/mesh/cfg/%s", uuid_str);
- app->agent_path = g_strdup_printf("/tizen/mesh/cfg/agent/%s", uuid_str);
+ app->agent_path = g_strdup_printf("%s/agent", app->path);
} else {
app->path = g_strdup_printf("/tizen/mesh/node/%s", uuid_str);
- app->agent_path = g_strdup_printf("/tizen/mesh/node/agent/%s", uuid_str);
+ app->agent_path = g_strdup_printf("%s/agent", app->path);
}
g_slist_foreach(models, __bt_mesh_hal_create_element_object, app);
if (mesh_event_cb)
mesh_event_cb(HAL_EV_MESH_PROVISIONING_STATUS,
(void*)&ev, sizeof(ev));
+ INFO("Mesh: Provisioning status sent");
}
static void __bt_hal_mesh_add_node_setup(struct l_dbus_message *msg,
void *user_data)
{
+ char *uuid;
bt_uuid_t *dev = user_data;
struct l_dbus_message_builder *builder;
+ uuid = l_util_hexstring(dev->uu, 16);
+ INFO("Mesh: Add Node Setup UUID [%s]", uuid);
builder = l_dbus_message_builder_new(msg);
__mesh_append_byte_array(builder, dev->uu, 16);
l_dbus_message_builder_leave_array(builder);
l_dbus_message_builder_finalize(builder);
l_dbus_message_builder_destroy(builder);
-
- l_free(dev);
}
bt_status_t _bt_hal_mesh_provision_device(
if (l) {
app = l->data;
dev = g_memdup((gpointer)dev_uuid, 16);
-
+ INFO("Mesh: Schedule Add Node request to meshd");
if (!l_dbus_proxy_method_call(app->mgmt_proxy, "AddNode",
__bt_hal_mesh_add_node_setup,
__bt_hal_mesh_add_node_reply,
ev.status = BT_STATUS_SUCCESS;
if (!strcmp("CreateSubnet", method)) {
+ INFO("Mesh: Reply for CreateSubnet");
ev.key_event = HAL_MESH_KEY_ADD;
} else if (!strcmp("DeleteSubnet", method)) {
+ INFO("Mesh: Reply for DeleteSubnet");
ev.key_event = HAL_MESH_KEY_DELETE;
} else if (!strcmp("UpdateSubnet", method)) {
+ INFO("Mesh: Reply for UpdateSubnet");
ev.key_event = HAL_MESH_KEY_UPDATE;
}
uint16_t net_idx = (uint16_t) req->net_idx;
uint16_t app_idx = (uint16_t) req->app_idx;
- l_dbus_message_set_arguments(msg, "qq", net_idx, app_idx);
+ if (g_strcmp0(req->str,"CreateAppKey") == 0)
+ l_dbus_message_set_arguments(msg, "qq", net_idx, app_idx);
+ else
+ l_dbus_message_set_arguments(msg, "q", app_idx);
}
static void __bt_hal_mesh_app_key_reply(struct l_dbus_proxy *proxy,
l_dbus_message_get_error(msg, &name, NULL);
ERR("Mesh: AppKey execute [%s] failed: error: [%s]", method, name);
ev.status = BT_STATUS_FAIL;
- }
-
- ev.status = BT_STATUS_SUCCESS;
+ } else
+ ev.status = BT_STATUS_SUCCESS;
if (!strcmp("CreateAppKey", method)) {
+ INFO("Mesh: AppKey Create Reply");
ev.key_event = HAL_MESH_KEY_ADD;
} else if (!strcmp("DeleteAppKey", method)) {
+ INFO("Mesh: AppKey Delete Reply");
ev.key_event = HAL_MESH_KEY_DELETE;
} else if (!strcmp("UpdateAppKey", method)) {
+ INFO("Mesh: AppKey Update Reply");
ev.key_event = HAL_MESH_KEY_UPDATE;
}
else if (op == BT_MESH_KEY_DELETE)
status = __mesh_subnet_appkey_command_execute(app,
netkey_idx, appkey_idx, "DeleteAppKey");
- else if (op == BT_MESH_KEY_UPDATE)
+ else if (op == BT_MESH_KEY_UPDATE) {
+ INFO("Mesh: Update ApKey command NK Idx [0x%2.2x] AK Idx [0x%2.2x]",
+ netkey_idx, appkey_idx);
status = __mesh_subnet_appkey_command_execute(app,
netkey_idx, appkey_idx, "UpdateAppKey");
+ }
if (!status)
return BT_STATUS_FAIL;
net_uuid->uu, __mesh_compare_network_uuid);
if (l) {
app = l->data;
+ if (!__bt_mesh_proxy_check(app)) {
+ ERR("Mesh: Proxy check failed!!");
+ return BT_STATUS_FAIL;
+ }
if (!l_dbus_proxy_method_call(app->mgmt_proxy,
"UnprovisionedScanCancel",
NULL, NULL, NULL, NULL))
uint32_t val_u32;
struct l_dbus_message *reply = NULL;
struct l_dbus_message_builder *builder;
- uint8_t alpha[16];
+ uint8_t *alpha;
+ bt_status_t ret = BT_STATUS_SUCCESS;
+ size_t sz = 0;
+ /* Proxy Check */
+ if (!__bt_mesh_proxy_check(0)) {
+ ERR("Mesh: Proxy check failed!!");
+ return BT_STATUS_FAIL;
+ }
+ INFO("Mesh: Authentication Reply: auth type [%d]", auth_type);
+ INFO("Mesh: Authentication Reply: auth value [%s]", auth_value);
/* For Numeric Type Inputs: Numeric, Blink, Beep & Vibrate */
if (auth_type >= BT_HAL_MESH_AUTH_REQ_NUMERIC_INPUT &&
auth_type <= BT_HAL_MESH_AUTH_REQ_VIBRATE_COUNT_INPUT) {
- INFO("Mesh: Authentication reply: Numeric ype");
+ INFO("Mesh: Authentication reply: Numeric Type");
val_u32 = atoi(auth_value);
reply = l_dbus_message_new_method_return(agent_msg);
l_dbus_message_set_arguments(reply, "u", val_u32);
- /* For Alpha-Numeric */
- } else if (auth_type == BT_HAL_MESH_AUTH_REQ_ALPHANUMERIC_INPUT) {
- INFO("Mesh: Authentication reply: Alpha-Numeric ype");
- memset(alpha, 0x00, 16);
- memcpy(alpha, auth_value, strlen(auth_value));
+ if (!reply)
+ reply = l_dbus_message_new_error(agent_msg, dbus_err_fail, NULL);
+ l_dbus_send(dbus, reply);
+ ret = BT_STATUS_SUCCESS;
+ /* For Alpha-Numeric */
+ } else if (auth_type == BT_HAL_MESH_AUTH_REQ_ALPHANUMERIC_INPUT ||
+ auth_type == BT_HAL_MESH_AUTH_REQ_OOB_STATIC_KEY_INPUT ||
+ auth_type == BT_HAL_MESH_AUTH_REQ_OOB_PUBLIC_KEY_INPUT ) {
+ INFO("Mesh: Authentication reply: Alpha-Numeric Type");
+ alpha = l_util_from_hexstring(auth_value, &sz);
reply = l_dbus_message_new_method_return(agent_msg);
builder = l_dbus_message_builder_new(reply);
__mesh_append_byte_array(builder, alpha, 16);
l_dbus_message_builder_finalize(builder);
l_dbus_message_builder_destroy(builder);
+ l_free(alpha);
+ if (!reply)
+ reply = l_dbus_message_new_error(agent_msg, dbus_err_fail, NULL);
+ l_dbus_send(dbus, reply);
+ ret = BT_STATUS_SUCCESS;
}
- return BT_STATUS_SUCCESS;
+ return ret;
}
bt_status_t _bt_hal_mesh_network_scan(bt_uuid_t *net_uuid,
l = g_slist_find_custom(mesh_apps, net_uuid->uu, __mesh_compare_network_uuid);
if (l) {
app = l->data;
+ if (!__bt_mesh_proxy_check(app)) {
+ ERR("Mesh: Proxy check failed!!");
+ return BT_STATUS_FAIL;
+ }
if (!l_dbus_proxy_method_call(app->mgmt_proxy, "UnprovisionedScan",
__mesh_scan_setup, __mesh_scan_reply,
L_UINT_TO_PTR(param->scan_time), NULL))
meshcfg_app *app;
INFO("Mesh: Create Network Request");
+
+ if (!__bt_mesh_proxy_check(0)) {
+ ERR("Mesh: Proxy check failed!!");
+ return BT_STATUS_FAIL;
+ }
+
+ INFO("Mesh: Node Element count [%d]", node->num_elements);
+ INFO("Mesh: Node Primary Unicast[0x%2.2x]", node->primary_unicast);
+ INFO("Mesh: Node Vendor Info: CID[0x%2.2x]", node->vendor_info.companyid);
+ INFO("Mesh: Node Vendor Info: VID[0x%2.2x]", node->vendor_info.vendorid);
+ INFO("Mesh: Node Vendor Info: VSID[0x%2.2x]", node->vendor_info.versionid);
+ INFO("Mesh: Node Vendor Info: CRPL[0x%2.2x]", node->vendor_info.crpl);
+ INFO("Mesh: Node Total Number of Models in the node[%d]", g_slist_length(models));
/* Create DBUS APP */
app = __bt_hal_mesh_create_app(node, models, is_prov);
if (!app)
l = g_slist_find_custom(mesh_apps, network->uu, __mesh_compare_network_uuid);
if (l) {
app = l->data;
+ if (!__bt_mesh_proxy_check(app)) {
+ ERR("Mesh: Proxy check failed!!");
+ return BT_STATUS_FAIL;
+ }
l1 = g_slist_find_custom(app->elements,
GUINT_TO_POINTER(src_elem_idx), __compare_element_index);
elem = l1->data;
req->idx = netkey_idx; /* Encryption Key index */
req->update_req = is_update;
- if (!l_dbus_proxy_method_call(app->mgmt_proxy, key_method,
+ if (!l_dbus_proxy_method_call(app->proxy, key_method,
__bt_hal_mesh_key_config_send, NULL,
(void*)req, l_free))
return BT_STATUS_FAIL;
__mesh_compare_network_uuid);
if (l) {
app = l->data;
+ if (!__bt_mesh_proxy_check(app)) {
+ ERR("Mesh: Proxy check failed!!");
+ return BT_STATUS_FAIL;
+ }
l1 = g_slist_find_custom(app->elements,
GUINT_TO_POINTER(src_elem_idx),
__compare_element_index);
req->rmt = true;
req->is_dev_key = is_dev_key;
- if (!l_dbus_proxy_method_call(app->mgmt_proxy, "DevKeySend",
+ if (!l_dbus_proxy_method_call(app->proxy, "DevKeySend",
__bt_hal_mesh_config_send, NULL,
(void*)req, l_free))
return BT_STATUS_FAIL;
{
struct hal_ev_mesh_provision_status *ev = buf;
+ INFO("Mesh: Send provstatus callback");
if (bt_hal_mesh_cbacks->provisioning_status_cb)
bt_hal_mesh_cbacks->provisioning_status_cb(ev->status,
(bt_uuid_t*)&ev->net_uuid,
(bt_uuid_t*)&ev->dev_uuid);
+ INFO("Mesh: Done Sending provstatus callback");
}
static void __bt_hal_handle_network_provisioning_finished(void *buf, uint16_t len)
__bt_hal_handle_network_scan_result(buf, len);
break;
case HAL_EV_MESH_PROVISIONING_STATUS:
- DBG("Mesh Event: HAL_EV_MESH_SCAN_RESULT");
+ DBG("Mesh Event: HAL_EV_MESH_PROVISIONING_STATUS");
__bt_hal_handle_network_provisioning_status(buf, len);
break;
case HAL_EV_MESH_PROVISIONING_FINISHED:
switch (event) {
default:
- ret = FALSE;
+ ret = TRUE;
break;
}
return ret;
result, sender,
function_name, (gpointer)network);
} else {
+ g_array_append_vals(*out_param1, &node, sizeof(bluetooth_mesh_node_t));
BT_ERR("Mesh: Mesh Network creation schedule failed");
g_slist_free_full(model_list, g_free);
}
__bt_service_get_parameters(in_param1,
&req, sizeof(bluetooth_mesh_provisioning_request_t));
+ BT_INFO("Mesh: Provision Device UUID [%s]", req.dev_uuid);
+ BT_INFO("Mesh: Provision Device in network[%s]", req.net_uuid);
+
result = _bt_mesh_network_provision_device(
requester_unique_creds, sender, &req);
break;
}
case BT_MESH_AUTHENTICATION_REPLY: {
+ BT_INFO("Mesh: BT_MESH_AUTHENTICATION_REPLY");
const char *auth_value = NULL;
gboolean authentication_reply = FALSE;
int auth_type;
&authentication_reply, sizeof(gboolean));
__bt_service_get_parameters(in_param1,
&auth_type, sizeof(int));
+ BT_INFO("Mesh: Auth Reply Type [%d]", auth_type);
+ BT_INFO("Mesh: Auth Value [%s]", auth_value);
+ BT_INFO("Mesh: Auth Accept [%d]", authentication_reply);
result = _bt_mesh_authentication_reply(auth_type,
auth_value, authentication_reply);
break;
case OAL_EVENT_MESH_NETKEY_EXECUTE_EVENT:
case OAL_EVENT_MESH_APPKEY_EXECUTE_EVENT:
case OAL_EVENT_MESH_DEVKEY_MESSAGE_RECEIVED:
+ BT_INFO("Mesh: Event");
if (mesh_cb)
mesh_cb(event_type, event_data);
break;
{
int r = l_main_prepare();
*timeout = r;
-
return FALSE;
}
uint16_t low, uint16_t high,
uint8_t ele_cnt);
-bool _bt_mesh_node_is_netkey_added(uint8_t net_uuid[],
+bool _bt_mesh_node_is_netkey_added_in_network(uint8_t net_uuid[],
uint16_t net_idx);
-bool _bt_mesh_node_is_appkey_added(uint8_t net_uuid[],
+bool _bt_mesh_node_is_appkey_added_in_network(uint8_t net_uuid[],
uint16_t app_idx);
+bool _bt_mesh_node_is_netkey_exists(uint8_t net_uuid[],
+ uint16_t addr, uint16_t net_idx);
+
+bool _bt_mesh_node_is_appkey_exists(uint8_t net_uuid[],
+ uint16_t addr, uint16_t app_idx);
+
bool _bt_mesh_node_add_net_key(uint8_t net_uuid[],
uint16_t addr, uint16_t net_idx);
default:
break;
}
+ BT_INFO("Mesh: Number of pending requests [%u] Remove the req",
+ l_queue_length(pending_requests));
l_queue_remove(pending_requests, req);
__mesh_request_remove(req);
}
{
struct mesh_pending_request *req;
const struct mesh_config_cmd *cmd;
+ char uuid_str[33];
cmd = __mesh_get_command(opcode);
if (!cmd)
return;
+ _bt_mesh_util_convert_hex_to_string((uint8_t *) net_uuid, 16, uuid_str,
+ BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
+ BT_INFO("Mesh: Net UUID[%s]",uuid_str);
+ BT_INFO("Mesh: Adding command opcode [0x%2.2x] response [0x%2.2x]",
+ cmd->opcode, cmd->response);
req = l_new(struct mesh_pending_request, 1);
req->cmd = cmd;
req->addr = dest;
memcpy(req->net_uuid, net_uuid, 16);
req->timer = l_timeout_create(MESH_DEFAULT_RESPONSE_TIMEOUT,
__bt_mesh_wait_response_timeout, req, NULL);
+
+ if (!pending_requests)
+ pending_requests = l_queue_new();
l_queue_push_tail(pending_requests, req);
+ BT_INFO("Mesh: Number of pending requests [%u]", l_queue_length(pending_requests));
}
static struct mesh_pending_request *__bt_mesh_get_request_by_response(
uint32_t response)
{
const struct l_queue_entry *entry;
+ char uuid_str[33];
+ char uuid_str1[33];
+ BT_INFO("Mesh: Number of pending requests [%u]", l_queue_length(pending_requests));
entry = l_queue_get_entries(pending_requests);
for (; entry; entry = entry->next) {
struct mesh_pending_request *req = entry->data;
+ /* Test */
+ BT_INFO("Mesh: Req addr [0x%2.2x] req opcode [0x%2.2x] res [0x%2.2x]", req->addr, req->cmd->opcode, req->cmd->response);
+ BT_INFO("Mesh: Current req addr [0x%2.2x] res [0x%2.2x]", addr, response);
+ _bt_mesh_util_convert_hex_to_string((uint8_t *) net_uuid, 16, uuid_str,
+ BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
+ BT_INFO("Mesh: Net UUID[%s]",uuid_str);
+
+ _bt_mesh_util_convert_hex_to_string((uint8_t *) req->net_uuid, 16, uuid_str1,
+ BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
+ BT_INFO("Mesh: Net UUID1[%s]",uuid_str1);
if (!memcmp(net_uuid, req->net_uuid, 16) &&
req->addr == addr &&
req->cmd->response == response)
if (BLUETOOTH_ERROR_NONE == result) {
/* Send event */
info = g_array_new(FALSE, FALSE, sizeof(gchar));
- g_array_append_vals(info, &evt,
+ g_array_append_vals(info, evt,
sizeof(bluetooth_mesh_model_configure_t));
out_var = g_variant_new_from_data((const GVariantType *)"ay",
if (BLUETOOTH_ERROR_NONE == result) {
/* Send event */
info = g_array_new(FALSE, FALSE, sizeof(gchar));
- g_array_append_vals(info, &evt,
+ g_array_append_vals(info, evt,
sizeof(bluetooth_mesh_model_configure_t));
out_var = g_variant_new_from_data((const GVariantType *)"ay",
if (BLUETOOTH_ERROR_NONE == result) {
/* Send event */
info = g_array_new(FALSE, FALSE, sizeof(gchar));
- g_array_append_vals(info, &evt, sizeof(bluetooth_mesh_model_configure_t));
+ g_array_append_vals(info, evt, sizeof(bluetooth_mesh_model_configure_t));
out_var = g_variant_new_from_data((const GVariantType *)"ay",
info->data, info->len,
if (BLUETOOTH_ERROR_NONE == result) {
/* Send event */
info = g_array_new(FALSE, FALSE, sizeof(gchar));
- g_array_append_vals(info, &ttl_evt,
+ g_array_append_vals(info, ttl_evt,
sizeof(bluetooth_mesh_node_ttl_info_t));
out_var = g_variant_new_from_data((const GVariantType *)"ay",
if (BLUETOOTH_ERROR_NONE == result) {
/* Send event */
info = g_array_new(FALSE, FALSE, sizeof(gchar));
- g_array_append_vals(info, &key_evt,
+ g_array_append_vals(info, key_evt,
sizeof(bluetooth_mesh_key_configure_t));
out_var = g_variant_new_from_data((const GVariantType *)"ay",
if (BLUETOOTH_ERROR_NONE == result) {
/* Send event */
info = g_array_new(FALSE, FALSE, sizeof(gchar));
- g_array_append_vals(info, &features_evt,
+ g_array_append_vals(info, features_evt,
sizeof(bluetooth_mesh_node_features_t));
out_var = g_variant_new_from_data((const GVariantType *)"ay",
if (BLUETOOTH_ERROR_NONE == result) {
/* Send event */
info = g_array_new(FALSE, FALSE, sizeof(gchar));
- g_array_append_vals(info, &browse_evt,
+ g_array_append_vals(info, browse_evt,
sizeof(bluetooth_mesh_node_discover_t));
out_var = g_variant_new_from_data((const GVariantType *)"ay",
event->unicast = req->unicast;
event->elem_count = req->elem_count;
+ /* Send Event */
+ __bt_mesh_send_node_get_vendor_features_event(result, event);
+
out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
g_array_append_vals(out_param, event, sizeof(bluetooth_mesh_node_features_t));
_bt_free_info_from_invocation_list(req_info);
g_free(req_info->user_data);
g_array_free(out_param, TRUE);
-
- /* Send Event */
- __bt_mesh_send_node_get_vendor_features_event(result, event);
}
break;
}
event = (event_mesh_devkey_message_t*) param;
node = (bluetooth_mesh_node_discover_t*)req_info->user_data;
+ BT_INFO("Mesh: Request Node UUID [%s]", node->dev_uuid);
+ BT_INFO("Mesh: Request Network UUID [%s]", node->net_uuid);
_bt_mesh_util_convert_hex_to_string((uint8_t *) event->net_uuid.uuid, 16, net_uuid,
BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
BT_DBG("Request Sender: [%s]", req_info->sender);
/* Match Network and Remote Node unicast*/
if (!g_strcmp0(node->net_uuid, net_uuid) && remote_addr == event->source) {
- out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
- g_array_append_vals(out_param, node, sizeof(bluetooth_mesh_node_discover_t));
-
_bt_mesh_node_get_element_count(event->net_uuid.uuid, remote_addr, &elem_count);
node->unicast = event->source;
node->count = elem_count;
+ /* Send Event */
+ __bt_mesh_send_node_browsed_event(result, node);
+
+ out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
+ g_array_append_vals(out_param, node, sizeof(bluetooth_mesh_node_discover_t));
/* Return DBUS Invocation*/
_bt_service_method_return(req_info->context, out_param, result);
g_free(req_info->user_data);
g_array_free(out_param, TRUE);
- /* Send Event */
- __bt_mesh_send_node_browsed_event(result, node);
}
}
break;
if (!g_strcmp0(req->net_uuid, event->net_uuid) &&
req->primary_unicast == event->primary_unicast &&
req->is_netkey == event->is_netkey) {
+ /* Send Event */
+ __bt_mesh_send_node_key_configuration_event(result, event);
+
out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
g_array_append_vals(out_param, event, sizeof(bluetooth_mesh_key_configure_t));
_bt_free_info_from_invocation_list(req_info);
g_free(req_info->user_data);
g_array_free(out_param, TRUE);
-
- /* Send Event */
- __bt_mesh_send_node_key_configuration_event(result, event);
- }
+ }
break;
}
case BT_MESH_NODE_TTL_EXECUTE: {
if (!g_strcmp0(req->net_uuid, event->net_uuid) &&
req->unicast == event->unicast) {
+ /* Send Event */
+ __bt_mesh_send_node_ttl_configuration_event(result, req);
+
out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
g_array_append_vals(out_param, req, sizeof(bluetooth_mesh_node_ttl_info_t));
_bt_free_info_from_invocation_list(req_info);
g_free(req_info->user_data);
g_array_free(out_param, TRUE);
-
- /* Send Event */
- __bt_mesh_send_node_ttl_configuration_event(result, req);
}
break;
}
if (!g_strcmp0(req->net_uuid, event->net_uuid) &&
req->primary_unicast == event->primary_unicast) {
+ /* Send Event */
+ __bt_mesh_send_model_configure_appkey_event(result, req);
+
out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
g_array_append_vals(out_param, req, sizeof(bluetooth_mesh_model_configure_t));
_bt_free_info_from_invocation_list(req_info);
g_free(req_info->user_data);
g_array_free(out_param, TRUE);
-
- /* Send Event */
- __bt_mesh_send_model_configure_appkey_event(result, req);
}
break;
if (!g_strcmp0(req->net_uuid, event->net_uuid) &&
req->primary_unicast == event->primary_unicast) {
+ /* Send Event */
+ __bt_mesh_send_model_get_appkey_list_event(result, event);
+
out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
g_array_append_vals(out_param, req, sizeof(bluetooth_mesh_model_configure_t));
_bt_free_info_from_invocation_list(req_info);
g_free(req_info->user_data);
g_array_free(out_param, TRUE);
-
- /* Send Event */
- __bt_mesh_send_model_get_appkey_list_event(result, event);
}
break;
}
if (!g_strcmp0(req->net_uuid, event->net_uuid) &&
req->primary_unicast == event->primary_unicast) {
+ /* Send Event */
+ __bt_mesh_send_model_get_subscription_list_event(result, event);
+
out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
g_array_append_vals(out_param, req, sizeof(bluetooth_mesh_model_configure_t));
_bt_free_info_from_invocation_list(req_info);
g_free(req_info->user_data);
g_array_free(out_param, TRUE);
-
- /* Send Event */
- __bt_mesh_send_model_get_subscription_list_event(result, event);
}
break;
}
req->primary_unicast == event->primary_unicast) {
req->sub_addr = event->sub_addr;
+ /* Send Event */
+ __bt_mesh_send_model_subscription_configure_event(
+ BLUETOOTH_EVENT_MESH_MODEL_SUBSCRIPTION_CONFGURED,
+ result, req);
+
out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
g_array_append_vals(out_param, req, sizeof(bluetooth_mesh_model_configure_t));
_bt_free_info_from_invocation_list(req_info);
g_free(req_info->user_data);
g_array_free(out_param, TRUE);
-
- /* Send Event */
- __bt_mesh_send_model_subscription_configure_event( \
- BLUETOOTH_EVENT_MESH_MODEL_SUBSCRIPTION_CONFGURED, \
- result, req);
}
break;
}
if (!g_strcmp0(req->net_uuid, event->net_uuid) &&
req->primary_unicast == event->primary_unicast) {
+ /* Send Event */
+ __bt_mesh_send_model_subscription_configure_event( \
+ BLUETOOTH_EVENT_MESH_MODEL_VIRTUAL_SUBSCRIPTION_CONFGURED, \
+ result, req);
+
out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
g_array_append_vals(out_param, req, sizeof(bluetooth_mesh_model_configure_t));
g_free(req_info->user_data);
g_array_free(out_param, TRUE);
- /* Send Event */
- __bt_mesh_send_model_subscription_configure_event( \
- BLUETOOTH_EVENT_MESH_MODEL_VIRTUAL_SUBSCRIPTION_CONFGURED, \
- result, req);
}
break;
}
req = (bluetooth_mesh_model_configure_t*)req_info->user_data;
if (!g_strcmp0(req->net_uuid, event->net_uuid) &&
- req->primary_unicast == event->primary_unicast) {
+ req->primary_unicast == event->primary_unicast) {
+ /* Send Event */
+ __bt_mesh_send_model_publication_status_event( \
+ BLUETOOTH_EVENT_MESH_MODEL_PUBLICATION_STATUS, \
+ result, event);
+
out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
g_array_append_vals(out_param, req, sizeof(bluetooth_mesh_model_configure_t));
_bt_free_info_from_invocation_list(req_info);
g_free(req_info->user_data);
g_array_free(out_param, TRUE);
-
- /* Send Event */
- __bt_mesh_send_model_publication_status_event( \
- BLUETOOTH_EVENT_MESH_MODEL_PUBLICATION_STATUS, \
- result, event);
- }
+ }
break;
}
case BT_MESH_MODEL_SET_PUBLICATION: {
if (!g_strcmp0(req->net_uuid, event->net_uuid) &&
req->primary_unicast == event->primary_unicast) {
+ /* Send Event */
+ __bt_mesh_send_model_publication_status_event( \
+ BLUETOOTH_EVENT_MESH_MODEL_PUBLICATION_STATUS, \
+ result, req);
+
out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
g_array_append_vals(out_param, req, sizeof(bluetooth_mesh_model_configure_t));
_bt_free_info_from_invocation_list(req_info);
g_free(req_info->user_data);
g_array_free(out_param, TRUE);
-
- /* Send Event */
- __bt_mesh_send_model_publication_status_event( \
- BLUETOOTH_EVENT_MESH_MODEL_PUBLICATION_STATUS, \
- result, req);
- }
+ }
break;
}
default:
struct mesh_pending_request *req;
if (_bt_mesh_util_opcode_get(data, data_len, &opcode, &n)) {
+ BT_INFO("Mesh: Opcode of response data [0x%2.2x], actual data len [%d]", opcode, n);
data_len -= n;
data += n;
} else
return;
- BT_INFO("Mesh: Received %s (len %u)",
- __mesh_get_opcode_string(opcode), data_len);
+ BT_INFO("Mesh: Received %s (len %u) opcode [0x%2.2x]",
+ __mesh_get_opcode_string(opcode), data_len, opcode);
req = __bt_mesh_get_request_by_response(event->source,
event->net_uuid.uuid, (opcode & ~MESH_OPCODE_UNRELIABLE));
if (req) {
+ BT_INFO("Mesh: Got Config Request");
cmd = req->cmd;
__mesh_request_remove(req);
l_queue_remove(pending_requests, req);
break;
bluetooth_mesh_node_features_t features;
memset(&features, 0x00, sizeof(bluetooth_mesh_node_features_t));
-
+ BT_INFO("Mesh: Got Response for Device Composition Data");
__bt_mesh_print_device_composition_data(data, data_len);
if (!_bt_mesh_network_save_remote_node_composition(
if (cmd->opcode == MESH_OPCODE_NETKEY_ADD) {
BT_INFO("Mesh: Resp recvd: MESH_OPCODE_NETKEY_ADD");
- if (_bt_mesh_network_save_remote_node_netkey(
+ if (!_bt_mesh_network_save_remote_node_netkey(
event->net_uuid.uuid, event->source, net_idx)) {
result = BLUETOOTH_ERROR_INTERNAL;
BT_INFO("Failed to save node Netkey!");
}
param.op = BLUETOOTH_MESH_NODE_KEY_ADD;
} else if (cmd->opcode == MESH_OPCODE_NETKEY_DELETE) {
- if (_bt_mesh_network_delete_remote_node_netkey(
+ if (!_bt_mesh_network_delete_remote_node_netkey(
event->net_uuid.uuid, event->source, net_idx)) {
result = BLUETOOTH_ERROR_INTERNAL;
BT_INFO("Failed to delete node Netkey!");
if (cmd->opcode == MESH_OPCODE_APPKEY_ADD) {
BT_INFO("Mesh: Resp recvd: MESH_OPCODE_APPKEY_ADD");
- if (_bt_mesh_network_save_remote_node_appkey(
+ if (!_bt_mesh_network_save_remote_node_appkey(
event->net_uuid.uuid, event->source,
net_idx, app_idx)) {
result = BLUETOOTH_ERROR_INTERNAL;
param.op = BLUETOOTH_MESH_NODE_KEY_ADD;
} else if (cmd->opcode == MESH_OPCODE_APPKEY_DELETE) {
BT_INFO("Mesh: Resp recvd: MESH_OPCODE_APPKEY_DELETE");
- if (_bt_mesh_network_delete_remote_node_appkey(
+ if (!_bt_mesh_network_delete_remote_node_appkey(
event->net_uuid.uuid, event->source,
net_idx, app_idx)) {
result = BLUETOOTH_ERROR_INTERNAL;
_bt_mesh_util_convert_string_to_hex(req->dev_uuid,
strlen(req->dev_uuid), dev_uuid.uuid, 16);
+ BT_INFO("Mesh: Browse Node UUID [%s]", req->dev_uuid);
+
/* Get Remote Node unicast address from Dev UUID */
if (!_bt_mesh_node_get_unicast_from_dev_uuid(net_uuid.uuid,
dev_uuid.uuid, &dest))
_bt_mesh_util_convert_string_to_hex(req->net_uuid, strlen(req->net_uuid), net_uuid.uuid, 16);
- if (req->is_netkey && _bt_mesh_keys_subnet_exists(net_uuid.uuid, req->netkey_idx)) {
+ if (req->is_netkey && !_bt_mesh_keys_subnet_exists(net_uuid.uuid, req->netkey_idx)) {
BT_ERR("Local Subnet not found..");
return BLUETOOTH_ERROR_INVALID_PARAM;
}
if (!_bt_mesh_conf_delete_application_key(cfg, idx))
return false;
- l_free(a);
+ BT_INFO("Mesh: freed Appkey index [%u]", idx);
return true;
}
static bool __mesh_remove_netkey_entry(void *a, void *b)
bool _bt_mesh_keys_get_new_appkey_index(uint8_t net_uuid[],
uint16_t *app_idx)
{
- const struct l_queue_entry *l;
+ const struct l_queue_entry *l, *l1;
struct mesh_network_t *network;
int maxkey = -1;
-
+ BT_INFO("Mesh: Find New appkey index");
network = l_queue_find(networks, __mesh_net_uuid_match, net_uuid);
if (!network)
return false;
+ BT_INFO("Mesh: Found network, number of netkeys present [%d]",
+ l_queue_length(network->net_keys));
+
if (!network->net_keys)
return false;
+ /* TODO: Save max appkey index in Network to avoid looping */
for (l = l_queue_get_entries(network->net_keys); l; l = l->next) {
struct mesh_net_key_t *key = l->data;
+ BT_INFO("Mesh: Number of Appkeys in current netkey is [%d]",
+ l_queue_length(key->app_keys));
+
if (!key->app_keys)
continue;
- for (l = l_queue_get_entries(key->app_keys); l; l = l->next) {
- uint16_t app_idx = L_PTR_TO_UINT(l->data);
+ for (l1 = l_queue_get_entries(key->app_keys); l1; l1 = l1->next) {
+ uint16_t app_idx = L_PTR_TO_UINT(l1->data);
+ BT_INFO("Mesh: Current AppKey Index [0x%2.2x]", app_idx);
if (app_idx > maxkey)
maxkey = app_idx;
}
l_queue_foreach_remove(key->app_keys,
__mesh_delete_bound_appkey, cfg);
l_free(key);
+ BT_INFO("Mesh: NetKey deleted");
}
void _bt_mesh_keys_add_app_key(uint8_t net_uuid[],
struct mesh_net_key_t *key;
struct mesh_network_t *network;
+ BT_INFO("Mesh: Add Appkey in Netkey");
network = l_queue_find(networks, __mesh_net_uuid_match, net_uuid);
if (!network)
return;
return;
l_queue_push_tail(key->app_keys, L_UINT_TO_PTR(app_idx));
+ BT_INFO("Mesh: Appkey with index [0x%2.2x] added to Netkey [0x%2.2x]",
+ app_idx, key->idx);
}
void _bt_mesh_keys_del_app_key(uint8_t net_uuid[], uint16_t app_idx)
if (!key->app_keys)
continue;
-
+ BT_INFO("Mesh: Delete AppKey index [%u]", app_idx);
if (l_queue_remove(key->app_keys, L_UINT_TO_PTR(app_idx)))
return;
}
_bt_mesh_util_convert_hex_to_string(
(uint8_t *) event->dev_uuid.uuid, 16, status_data.dev_uuid,
BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
+ BT_INFO("Mesh: Provision Status: Device UUID [%s]", status_data.dev_uuid);
+ BT_INFO("Mesh: Provision Status: Net UUID [%s]", status_data.net_uuid);
+ BT_INFO("Mesh: Provision Status: Result [%d]", event->status);
+ if (event->status == OAL_STATUS_SUCCESS)
+ BT_INFO("Mesh: Provisioning status : SUCCESS");
+ else
+ BT_INFO("Mesh: Provisioning status : FAIL");
BT_DBG("Request Sender: [%s]", req_info->sender);
if (!g_strcmp0(req_data->net_uuid, status_data.net_uuid)) {
if (event->status != OAL_STATUS_SUCCESS)
result = BLUETOOTH_ERROR_INTERNAL;
-
/* Handle DBUS Context return */
if (event->op == OAL_MESH_KEY_ADD) {
+ BT_INFO("Mesh: Appkey Add event");
if (result == BLUETOOTH_ERROR_NONE)
_bt_mesh_network_handle_appkey_added(
event->net_uuid.uuid, event->net_idx, event->app_idx);
__bt_mesh_handle_pending_request_info(result, BT_MESH_NETWORK_ADD_APPKEY,
event, sizeof(event_mesh_netkey_operation_t));
} else if (event->op == OAL_MESH_KEY_DELETE) {
+ BT_INFO("Mesh: Appkey Delete event");
if (result == BLUETOOTH_ERROR_NONE)
_bt_mesh_network_handle_appkey_deleted(
event->net_uuid.uuid, event->net_idx, event->app_idx);
__bt_mesh_handle_pending_request_info(result, BT_MESH_NETWORK_DELETE_APPKEY,
event, sizeof(event_mesh_netkey_operation_t));
} else if (event->op == OAL_MESH_KEY_UPDATE) {
+ BT_INFO("Mesh: Appkey Update event");
__bt_mesh_handle_pending_request_info(result, BT_MESH_NETWORK_UPDATE_APPKEY,
event, sizeof(event_mesh_netkey_operation_t));
}
GVariant *out_var = NULL, *param = NULL;
GArray *info = NULL;
bluetooth_mesh_network_t network;
-
int result = BLUETOOTH_ERROR_NONE;
- if (event->status != OAL_STATUS_SUCCESS)
+ if (event->status != OAL_STATUS_SUCCESS) {
+ BT_INFO("Mesh: Scan Finished: status:: FAILED!");
result = BLUETOOTH_ERROR_INTERNAL;
-
+ } else
+ BT_INFO("Mesh: Scan Finished: status:: SUCCESS!");
/* Handle Scan finsihed event */
if (result == BLUETOOTH_ERROR_NONE) {
event_mesh_provisioning_status_t *status)
{
int result = BLUETOOTH_ERROR_NONE;
+ BT_INFO("Mesh: Provisioning started");
__bt_mesh_handle_pending_request_info(result,
BT_MESH_NETWORK_PROVISION_DEVICE,
- status, sizeof(event_mesh_scan_status_t));
+ status, sizeof(event_mesh_provisioning_status_t));
_bt_mesh_set_provisioning_state(true);
}
event_mesh_provisioning_status_t *status)
{
int result = BLUETOOTH_ERROR_INTERNAL;
-
+ BT_INFO("Mesh: Provisioning failed!!");
__bt_mesh_handle_pending_request_info(result,
BT_MESH_NETWORK_PROVISION_DEVICE,
- status, sizeof(event_mesh_scan_status_t));
+ status, sizeof(event_mesh_provisioning_status_t));
_bt_mesh_set_provisioning_state(false);
}
GVariant *out_var = NULL, *param = NULL;
GArray *info = NULL;
bluetooth_mesh_provisioning_result_t prov_result;
+ BT_INFO("Mesh: Provisioning Finished!");
memset(&prov_result, 0x00,
sizeof(bluetooth_mesh_provisioning_result_t));
if (event->status != OAL_STATUS_SUCCESS)
prov_result.result = BLUETOOTH_ERROR_INTERNAL;
- prov_result.result = BLUETOOTH_ERROR_NONE;
+ else
+ prov_result.result = BLUETOOTH_ERROR_NONE;
prov_result.reason = event->reason;
prov_result.unicast = event->unicast;
/* Add Remote Node entry in Local CDB */
if (event->status == OAL_STATUS_SUCCESS) {
+ BT_INFO("Mesh: Provisioning done, add node to Network");
+ BT_INFO("Mesh: Node UUID [%s]", prov_result.dev_uuid);
+ BT_INFO("Mesh: Node Unicast[0x%2.2x] Element Count [%d]",
+ event->unicast, event->count);
+
_bt_mesh_network_add_remote_node(
event->net_uuid.uuid, event->dev_uuid.uuid,
event->unicast, event->count);
}
+ /* Unset provisioning state */
+ _bt_mesh_set_provisioning_state(false);
}
static void __handle_mesh_network_provisioning_data_requested_event(
(uint8_t *) event->net_uuid.uuid, 16, auth_req.net_uuid,
BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
+ BT_INFO("Mesh: Authentication Requested by Device: Network [%s]",
+ auth_req.net_uuid);
info = g_array_new(FALSE, FALSE, sizeof(gchar));
g_array_append_vals(info, &auth_req,
sizeof(bluetooth_mesh_authentication_request_t));
static void __handle_mesh_events(int event_type,
gpointer event_data)
{
+ BT_INFO("Mesh: Got Mesh event!!! event type [%d]", event_type);
+ if (event_type == OAL_EVENT_MESH_PROVISIONING_STARTED)
+ BT_INFO("Mesh: Provisioning started event");
+
switch (event_type) {
case OAL_EVENT_MESH_NETWORK_ATTACHED:
__handle_mesh_network_attached_event(
BT_PERMANENT_LOG("Mesh: Network Scan Result!!");
break;
case OAL_EVENT_MESH_PROVISIONING_STARTED:
+ BT_INFO("Mesh: Network Provisioning Started");
__handle_mesh_network_provisioning_started_event(
(event_mesh_provisioning_status_t*)event_data);
BT_PERMANENT_LOG("Mesh: Network Provisioning Started");
- break;
+ break;
case OAL_EVENT_MESH_PROVISIONING_FAILED:
+ BT_INFO("Mesh: Network Provisioning Failed!!!!");
__handle_mesh_network_provisioning_failed_event(
(event_mesh_provisioning_status_t*)event_data);
BT_PERMANENT_LOG("Mesh: Network Provisioning Failed");
static gint __mesh_compare_app_cdb_token(gconstpointer data,
gconstpointer user_data)
{
- char *token_str = NULL;
+ char token_str[17];
const _bt_mesh_cdb_t *cdb = data;
const char *token = user_data;
- int ret = 0;
retv_if(NULL == cdb, -1);
retv_if(NULL == token, -1);
- token_str = _bt_service_convert_hex_to_string(
- (unsigned char*)cdb->token, 8);
+ _bt_mesh_util_convert_hex_to_string((uint8_t *) cdb->token,
+ 8, token_str, 17);
- ret = g_strcmp0(token_str, token);
- g_free(token_str);
- return ret;
+ BT_INFO("Mesh: Match Token 1[%s] Toekn 2 [%s]",
+ token_str, token);
+ return g_strcmp0(token_str, token);
}
static gint __mesh_compare_addr(
static void __bt_mesh_free_temp_node(mesh_local_node_t *tmp)
{
+ if (!tmp)
+ return;
temp_nodes = g_slist_remove(temp_nodes, tmp);
g_free((gpointer)tmp->app_cred);
g_free((gpointer)tmp->sender);
- g_slist_free_full(tmp->model_list, g_free);
+ /* Do not free tmp->model_list here
+ This memory is also being used in HAL layer
+ This memory will be freed with the call of __mesh_client_disconnected */
+ tmp->model_list = NULL;
g_free(tmp);
}
uint16_t unicast;
int ret = OAL_STATUS_SUCCESS;
oal_uuid_t uuid;
+ char uuid_string[33];
+
+ _bt_mesh_util_convert_hex_to_string(net_uuid, 16,
+ uuid_string, sizeof(uuid_string));
+ BT_INFO("Mesh: Provisioning Data requested for network [%s]",
+ uuid_string);
+
unicast = _bt_mesh_node_get_next_unicast(net_uuid,
MESH_DEFAULT_START_ADDRESS,
MESH_DEFAULT_START_ADDRESS, count);
- BT_INFO("Mesh: Network: Got unicast [0x%2x]", unicast);
+ BT_INFO("Mesh: Network: Got unicast [%4.4x]", unicast);
memcpy(uuid.uuid, net_uuid, 16);
/* Register Mesh Node */
mesh_local_node_t *tmp;
_bt_mesh_cdb_t *cdb_cfg = NULL;
char uuid_string[33];
+ char token_string[17];
_bt_mesh_util_convert_hex_to_string(uuid, 16,
uuid_string, sizeof(uuid_string));
- BT_INFO("Mesh: Create CDB request for network UUID [%s]",
- uuid_string);
+ _bt_mesh_util_convert_hex_to_string(token, 8,
+ token_string, sizeof(token_string));
+ BT_INFO("Mesh: Create CDB request for network UUID [%s] token [%s]",
+ uuid_string, token_string);
BT_INFO("Mesh: Temporary node count [%d]",
g_slist_length(temp_nodes));
file_path = g_strdup_printf("%s%s_config.json",
dir_path, uuid_string);
BT_INFO("Mesh: CDB File path[%s]", file_path);
+ BT_INFO("Mesh: CDB App Cred[%s]", app_creds);
cdb_cfg = _bt_mesh_conf_database_create(file_path, uuid,
token, network, app_creds);
/* If Scanning is going on */
if (_bt_mesh_is_provisioning() ||
_bt_mesh_is_scanning()) {
- BT_ERR("Device is already scanning..");
+ BT_ERR("Device is buzy..");
return BLUETOOTH_ERROR_DEVICE_BUSY;
}
_bt_mesh_util_convert_string_to_hex(network->uuid,
int ret = OAL_STATUS_SUCCESS;
oal_uuid_t net_uuid;
+ if (!_bt_mesh_is_scanning()) {
+ BT_INFO("Mesh: Scanning is not ongoing");
+ return BLUETOOTH_ERROR_NOT_IN_OPERATION;
+ }
_bt_mesh_util_convert_string_to_hex(network->uuid,
strlen(network->uuid), net_uuid.uuid, 16);
/* Register Mesh Node */
bool _bt_mesh_is_provisioning(void)
{
- return bt_mesh_is_scanning;
+ return bt_mesh_is_provisoning;
}
void _bt_mesh_set_provisioning_state(bool state)
return BLUETOOTH_ERROR_INTERNAL;
}
+ BT_INFO("Mesh: Scheduled Prov Auth Reply!");
return BLUETOOTH_ERROR_NONE;
}
GSList *l;
_bt_mesh_cdb_t *cdb_cfg = NULL;
+ BT_INFO("Mesh: Handle Netkey Added");
/* Find CDB */
l = g_slist_find_custom(cdb_list, net_uuid,
__mesh_compare_app_network_uuid);
GSList *l;
_bt_mesh_cdb_t *cdb_cfg = NULL;
+ BT_INFO("Mesh: Handle Netkey Deleted");
/* Find CDB */
l = g_slist_find_custom(cdb_list, net_uuid,
__mesh_compare_app_network_uuid);
GSList *l;
_bt_mesh_cdb_t *cdb_cfg = NULL;
+ BT_INFO("Mesh: Handle Netkey Updated");
/* Find CDB */
l = g_slist_find_custom(cdb_list, net_uuid,
__mesh_compare_app_network_uuid);
GSList *l;
_bt_mesh_cdb_t *cdb_cfg = NULL;
+ BT_INFO("Mesh: Handle Appkey Added");
/* Find CDB */
l = g_slist_find_custom(cdb_list, net_uuid,
__mesh_compare_app_network_uuid);
GSList *l;
_bt_mesh_cdb_t *cdb_cfg = NULL;
+ BT_INFO("Mesh: Handle Appkey Deleted");
/* Find CDB */
l = g_slist_find_custom(cdb_list, net_uuid,
__mesh_compare_app_network_uuid);
{
GSList *l;
_bt_mesh_cdb_t *cdb_cfg = NULL;
+ BT_INFO("Mesh: Set network name, app_creds [%s]", app_cred);
+ BT_INFO("Mesh: UUID [%s]", network->uuid);
+ BT_INFO("Mesh: Token[%s]", network->token.token);
+ BT_INFO("Mesh: Name to be set[%s]", network->name.name);
+
/* Find CDB */
l = g_slist_find_custom(cdb_list,
network->token.token, __mesh_compare_app_cdb_token);
return BLUETOOTH_ERROR_INVALID_PARAM;
/* Check if NetKey is already added to one of the provisioned nodes */
- if (_bt_mesh_node_is_netkey_added(cdb_cfg->uuid, index))
+ if (_bt_mesh_node_is_netkey_added_in_network(cdb_cfg->uuid, index)) {
+ BT_INFO("Mesh: NetKey index [0x%2.2x] can not be deleted", index);
return BLUETOOTH_ERROR_INVALID_PARAM;
+ }
_bt_mesh_util_convert_string_to_hex(network->uuid,
strlen(network->uuid), net_uuid.uuid, 16);
return BLUETOOTH_ERROR_INVALID_PARAM;
/* Check if AppKey is already added to one of the provisioned nodes */
- if (_bt_mesh_node_is_appkey_added(cdb_cfg->uuid, appkey_idx))
+ if (_bt_mesh_node_is_appkey_added_in_network(cdb_cfg->uuid, appkey_idx))
return BLUETOOTH_ERROR_INVALID_PARAM;
_bt_mesh_util_convert_string_to_hex(network->uuid,
{
int ret = OAL_STATUS_SUCCESS;
- BT_INFO("Mesh: App Cred [%s] sender [%s] network [%s]",
+ BT_INFO("Mesh: App Credential [%s] sender [%s] network [%s]",
app_cred, sender, network_name);
/* TODO Handle Buzy status */
cdb_cfg = (_bt_mesh_cdb_t*)l->data;
+ if (_bt_mesh_node_is_appkey_exists(net_uuid,
+ remote_unicast, netkey_idx)) {
+ BT_INFO("Mesh: AppKey is already added to Node");
+ return true;
+ }
if (_bt_mesh_node_add_app_key(net_uuid,
remote_unicast, appkey_idx))
return _bt_mesh_conf_node_insert_application_key(cdb_cfg,
cdb_cfg = (_bt_mesh_cdb_t*)l->data;
+ if (_bt_mesh_node_is_netkey_exists(net_uuid,
+ remote_unicast, netkey_idx)) {
+ BT_INFO("Mesh: NetKey is already added to Node");
+ return true;
+ }
if (_bt_mesh_node_add_net_key(net_uuid,
remote_unicast, netkey_idx))
return _bt_mesh_conf_node_insert_network_key(cdb_cfg,
rmt = l_queue_find(network->nodes,
__mesh_match_node_dev_uuid, dev_uuid);
- if (rmt)
+ if (!rmt)
return false;
*unicast = rmt->unicast;
rmt = l_queue_find(network->nodes, __mesh_match_node_addr,
L_UINT_TO_PTR(unicast));
- if (rmt)
+ if (!rmt)
return false;
*count = rmt->num_ele;
if (!network->nodes)
network->nodes = l_queue_new();
- l_queue_insert(network->nodes, rmt, __mesh_compare_unicast, NULL);
+ if (l_queue_insert(network->nodes, rmt, __mesh_compare_unicast, NULL))
+ BT_INFO("Mesh: node added to Network");
+ else
+ BT_INFO("Mesh: node could not be added to Network");
return true;
}
struct _bt_mesh_node_t *node = entry->data;
n.primary_unicast = node->unicast;
- n.num_elements = node->num_ele;
+ _bt_mesh_util_convert_hex_to_string(node->uuid, 16,
+ n.dev_uuid, sizeof(n.dev_uuid));
+ BT_INFO("Mesh: Dev UUID [%s]", n.dev_uuid);
g_array_append_vals(*out, &n,
sizeof(bluetooth_mesh_node_info_t));
return true;
}
-bool _bt_mesh_node_is_netkey_added(uint8_t net_uuid[],
+bool _bt_mesh_node_is_netkey_added_in_network(uint8_t net_uuid[],
uint16_t net_idx)
{
struct mesh_network_t *network;
return false;
}
-bool _bt_mesh_node_is_appkey_added(uint8_t net_uuid[],
+bool _bt_mesh_node_is_appkey_added_in_network(uint8_t net_uuid[],
uint16_t app_idx)
{
struct mesh_network_t *network;
return false;
}
-bool _bt_mesh_node_add_net_key(uint8_t net_uuid[],
+bool _bt_mesh_node_is_appkey_exists(uint8_t net_uuid[],
+ uint16_t addr, uint16_t app_idx)
+{
+ struct _bt_mesh_node_t *rmt;
+ struct mesh_network_t *network;
+
+ network = l_queue_find(networks, __mesh_net_uuid_match, net_uuid);
+ if (!network)
+ return false;
+
+ rmt = l_queue_find(network->nodes,
+ __mesh_match_node_addr, L_UINT_TO_PTR(addr));
+ if (!rmt)
+ return false;
+
+ if (__mesh_key_present(rmt->app_keys, app_idx))
+ return true;
+
+ return false;
+}
+
+bool _bt_mesh_node_is_netkey_exists(uint8_t net_uuid[],
uint16_t addr, uint16_t net_idx)
{
struct _bt_mesh_node_t *rmt;
return false;
if (__mesh_key_present(rmt->net_keys, net_idx))
+ return true;
+
+ return false;
+}
+
+bool _bt_mesh_node_add_net_key(uint8_t net_uuid[],
+ uint16_t addr, uint16_t net_idx)
+{
+ struct _bt_mesh_node_t *rmt;
+ struct mesh_network_t *network;
+
+ network = l_queue_find(networks, __mesh_net_uuid_match, net_uuid);
+ if (!network)
+ return false;
+
+ rmt = l_queue_find(network->nodes,
+ __mesh_match_node_addr, L_UINT_TO_PTR(addr));
+ if (!rmt)
return false;
+ if (__mesh_key_present(rmt->net_keys, net_idx))
+ return true;
+
l_queue_push_tail(rmt->net_keys, L_UINT_TO_PTR(net_idx));
return true;
}
network = l_queue_find(networks,
__mesh_net_uuid_match, net_uuid);
- if (!network)
+ if (!network) {
+ BT_ERR("Mesh: Net UUID did not match");
return 0;
+ }
/* Note: the address space includes both
low and high terminal values */
bool _bt_mesh_util_opcode_get(const uint8_t *buf,
uint16_t sz, uint32_t *opcode, int *n)
{
+ BT_INFO("Mesh: Opcode Get DatLen [%d] Buf0 [0x%x]",
+ sz, buf[0]);
if (!n || !opcode || sz < 1) return false;
switch (buf[0] & 0xc0) {
typedef struct {
uint16_t primary_unicast;
- int num_elements;
+ char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
} bluetooth_mesh_node_info_t;
/**