static GSList *prov_dev_list;
static GSList *srv_model_list;
static char *g_device_uuid;
-static bool node_discovered = false;
+static bool call_success = false;
+
+static int try = 0;
+static int max_try = 10;
static bt_mesh_netkey_h g_netkey;
static bt_mesh_appkey_h g_appkey;
print_node_handle(node_param);
if (result == BT_ERROR_NONE) {
g_node = node_param;
- node_discovered = true;
+ call_success = true;
}
wait_for_async_over();
}
{
TC_PRT("result: %s", __bt_get_error_message(result));
if (result == BT_ERROR_NONE) {
+ call_success = true;
//print_node_handle(node);
if (op == BT_MESH_NODE_KEY_ADD)
TC_PRT("AppKey Added!");
{
TC_PRT("result: %s", __bt_get_error_message(result));
if (result == BT_ERROR_NONE) {
+ call_success = true;
print_model_handle(model);
print_appkey_handle(appkey);
}
{
TC_PRT("result: %s", __bt_get_error_message(result));
if (result == BT_ERROR_NONE) {
+ call_success = true;
TC_PRT("opcode: 0X%2.2X", msg->opcode);
TC_PRT("msg: %s", msg->data);
print_element_handle(element);
print_appkey_handle(appkey);
}
+ wait_for_async_over();
}
void __bt_mesh_model_unbind_cb(int result, bt_mesh_model_h model, bt_mesh_appkey_h appkey,
{
TC_PRT("result: %s", __bt_get_error_message(result));
if (result == BT_ERROR_NONE) {
+ call_success = true;
switch(op) {
case 0:
TC_PRT("Model Subscription Operation is ADD");
print_model_handle(model);
print_group_handle(group);
}
+ wait_for_async_over();
}
bool __bt_mesh_model_subscription_list_cb(int result, bt_mesh_model_h model, int total, const GSList *sub_addr,
else if (state == BT_MESH_SCANNING_FINISHED) {
TC_PRT("The scanning state is: STOPPED");
print_network_handle(network);
+ wait_for_async_over();
}
else {
GSList *l;
request_type = auth_type;
}
+int __bt_mesh_model_send_msg(bt_mesh_model_h model,
+ bt_mesh_appkey_h appkey, bt_mesh_model_msg_params_s *msg_params,
+ bt_mesh_model_msg_cb callback, void *user_data)
+{
+ int ret = BT_ERROR_NONE;
+ call_success = false;
+ try = 0;
+
+ while (!call_success && try < max_try) {
+ try++;
+ ret = bt_mesh_model_send_msg(model, appkey, msg_params,
+ callback, user_data);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("return %s\n", __bt_get_error_message(ret));
+ else
+ wait_for_async();
+ }
+ return ret;
+}
+
+int __bt_mesh_group_send_msg(bt_mesh_group_h group,
+ bt_mesh_appkey_h appkey, bt_mesh_model_msg_params_s *msg_params,
+ bt_mesh_model_msg_cb callback, void *user_data)
+{
+ int ret = BT_ERROR_NONE;
+ call_success = false;
+ try = 0;
+
+ while (!call_success && try < max_try) {
+ try++;
+ ret = bt_mesh_group_send_msg(group, appkey, msg_params,
+ callback, user_data);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("return %s\n", __bt_get_error_message(ret));
+ else
+ wait_for_async();
+ }
+ return ret;
+}
+
int test_set_params(int test_id, char *param){
static int param_index = 0;
int param_count = 0;
ret = bt_mesh_stop_unprovisioned_device_scan(network);
if (ret != BT_ERROR_NONE)
TC_PRT("return %s\n", __bt_get_error_message(ret));
+ else
+ wait_for_async();
/* Start scan */
TC_PRT("The scan is set for [%u] seconds", scan_params.seconds);
ret = bt_mesh_stop_unprovisioned_device_scan(network);
if (ret != BT_ERROR_NONE)
TC_PRT("return %s\n", __bt_get_error_message(ret));
+ else
+ wait_for_async();
/* Provision device */
ret = bt_mesh_network_provision_device(network, g_device_uuid,
__bt_mesh_network_device_provision_cb, NULL);
if (ret != BT_ERROR_NONE)
TC_PRT("return %s\n", __bt_get_error_message(ret));
- wait_for_async();
+ else
+ wait_for_async();
/* Try to discover provisioned device */
- node_discovered = false;
- int try = 0;
- int max_try = 10;
if (ret == BT_ERROR_NONE) {
- while (!node_discovered && try < max_try) {
+ call_success = false;
+ try = 0;
+ while (!call_success && try < max_try) {
try++;
ret = bt_mesh_network_discover_node(network, (const char*)g_device_uuid,
__bt_mesh_node_discover_status_cb, NULL);
if (ret != BT_ERROR_NONE)
TC_PRT("return %s\n", __bt_get_error_message(ret));
- wait_for_async();
+ else
+ wait_for_async();
}
}
break;
TC_PRT("return %s\n", __bt_get_error_message(ret));
/* Add appkey in remote node*/
- ret = bt_mesh_node_configure_appkey(node_h, config, appkey_h,
- __bt_mesh_node_configure_appkey_cb, NULL);
- if (ret != BT_ERROR_NONE)
- TC_PRT("return %s\n", __bt_get_error_message(ret));
- wait_for_async();
+ call_success = false;
+ try = 0;
+ if (ret == BT_ERROR_NONE) {
+ while (!call_success && try < max_try) {
+ try++;
+ ret = bt_mesh_node_configure_appkey(node_h, config, appkey_h,
+ __bt_mesh_node_configure_appkey_cb, NULL);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("return %s\n", __bt_get_error_message(ret));
+ else
+ wait_for_async();
+ }
+ }
/* Bind appkey in on-off server*/
+ call_success = false;
+ try = 0;
model_h = g_model_onoff_srv;
- ret = bt_mesh_model_bind_appkey(model_h, appkey_h, __bt_mesh_model_bind_cb, NULL);
- if (ret != BT_ERROR_NONE)
- TC_PRT("return %s\n", __bt_get_error_message(ret));
- wait_for_async();
+ if (ret == BT_ERROR_NONE) {
+ while (!call_success && try < max_try) {
+ try++;
+ ret = bt_mesh_model_bind_appkey(model_h, appkey_h,
+ __bt_mesh_model_bind_cb, NULL);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("return %s\n", __bt_get_error_message(ret));
+ else
+ wait_for_async();
+ }
+ }
+ /*
+ * Configure group subscription
+ * Subscribe remote OnOff server model to Group with address c000
+ */
group_h = g_group;
- ret = bt_mesh_model_configure_group_subscription(op, model_h, group_h,
- __bt_mesh_model_subscription_op_cb, NULL);
- if (ret != BT_ERROR_NONE)
- TC_PRT("return %s\n", __bt_get_error_message(ret));
+ call_success = false;
+ try = 0;
+ model_h = g_model_onoff_srv;
+ if (ret == BT_ERROR_NONE) {
+ while (!call_success && try < max_try) {
+ try++;
+ ret = bt_mesh_model_configure_group_subscription(op, model_h,
+ group_h, __bt_mesh_model_subscription_op_cb, NULL);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("return %s\n", __bt_get_error_message(ret));
+ else
+ wait_for_async();
+ }
+ }
break;
}
const char *msg_s = "0101";
msg_params.opcode = 0x8202;
msg_params.data = g_strdup(msg_s);
- ret = bt_mesh_model_send_msg(model_h, appkey_h, &msg_params,
- __bt_mesh_model_msg_cb, NULL);
+ ret = __bt_mesh_model_send_msg(model_h, appkey_h, &msg_params,
+ __bt_mesh_model_msg_cb, NULL);
if (ret != BT_ERROR_NONE)
TC_PRT("return %s\n", __bt_get_error_message(ret));
break;
const char *msg_s = "0001";
msg_params.opcode = 0x8202;
msg_params.data = g_strdup(msg_s);
- ret = bt_mesh_model_send_msg(model_h, appkey_h, &msg_params,
+ ret = __bt_mesh_model_send_msg(model_h, appkey_h, &msg_params,
__bt_mesh_model_msg_cb, NULL);
if (ret != BT_ERROR_NONE)
TC_PRT("return %s\n", __bt_get_error_message(ret));
const char *msg_s = "0101";
msg_params.opcode = 0x8202;
msg_params.data = g_strdup(msg_s);
- ret = bt_mesh_group_send_msg(group_h, appkey_h, &msg_params,
+ ret = __bt_mesh_group_send_msg(group_h, appkey_h, &msg_params,
__bt_mesh_model_msg_cb, NULL);
if (ret != BT_ERROR_NONE)
TC_PRT("return %s\n", __bt_get_error_message(ret));
const char *msg_s = "0001";
msg_params.opcode = 0x8202;
msg_params.data = g_strdup(msg_s);
- ret = bt_mesh_group_send_msg(group_h, appkey_h, &msg_params,
+ ret = __bt_mesh_group_send_msg(group_h, appkey_h, &msg_params,
__bt_mesh_model_msg_cb, NULL);
if (ret != BT_ERROR_NONE)
TC_PRT("return %s\n", __bt_get_error_message(ret));