This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Only some of the connected thingy are output

https://github.com/NordicPlayground/nrf52-ble-multi-link-multi-role

I use this code. 

The connection to thingy was successful. max connection is 10.

The discovery of environmental services has been successful.

but only the environmental values of some devices are output.

for example connect  10 device but print only 7 device 

How can I print the environment values of all devices?

Parents Reply Children
  • I modified the code to access the environmental values and motion value

    but if one thingy access one value such as temperature, that don't access other values.

    It is possible for thingy to access a lot of values?
    and It is possible for multi thingy to access a lot of values?

  • Hi

    The Thingy's should update values automatically as soon as you enable notifications for the corresponding characteristic (set the CCCD). 

    You can enable notifications on multiple characteristics in one thingy, and it should be possible to enable notifications on multiple characteristics in multiple thingy's as well. 

    If this is not working it might be down to the method you use for enabling notifications across the different thingy's.

    Best regards
    Torbjørn

  • case THINGY_TMS_UUID_EULER_CHAR :
    evt.params.peer_db.euler_cccd_handle = p_char->cccd_handle;
    evt.params.peer_db.euler_handle = p_char->characteristic.handle_value;
    NRF_LOG_INFO("evt euler handle = %d",p_ble_thingy_tms_c->conn_handle, evt.params.peer_db.euler_handle);
    break;

    case THINGY_TMS_UUID_CONFIG_CHAR :
    evt.params.peer_db.config_cccd_handle = p_char->cccd_handle;
    evt.params.peer_db.config_handle = p_char->characteristic.handle_value;
    NRF_LOG_INFO("%d >> evt config handle = %d", p_ble_thingy_tms_c->conn_handle,evt.params.peer_db.config_handle);
    break;

    case THINGY_TMS_UUID_GRAVITY_CHAR :
    evt.params.peer_db.gravity_cccd_handle = p_char->cccd_handle;
    evt.params.peer_db.gravity_handle = p_char->characteristic.handle_value;
    NRF_LOG_INFO("%d >> evt gravity handle = %d", p_ble_thingy_tms_c->conn_handle, evt.params.peer_db.gravity_handle);



    case THINGY_TMS_UUID_ROT_MAT_CHAR :
    evt.params.peer_db.rot_cccd_handle = p_char->cccd_handle;
    evt.params.peer_db.rot_handle = p_char->characteristic.handle_value;
    NRF_LOG_INFO("%d >> evt rot handle = %d", p_ble_thingy_tms_c->conn_handle,evt.params.peer_db.rot_handle);
    break;


    case THINGY_TMS_UUID_HEADING_CHAR :
    evt.params.peer_db.heading_cccd_handle = p_char->cccd_handle;
    evt.params.peer_db.heading_handle = p_char->characteristic.handle_value;
    NRF_LOG_INFO("%d >> evt heading handle = %d", p_ble_thingy_tms_c->conn_handle, evt.params.peer_db.heading_handle);
    break;


    case THINGY_TMS_UUID_ORIENTATION_CHAR:
    evt.params.peer_db.orientation_cccd_handle = p_char->cccd_handle;
    evt.params.peer_db.orientation_handle = p_char->characteristic.handle_value;
    NRF_LOG_INFO("%d >> evt orientation handle = %d",p_ble_thingy_tms_c->conn_handle, evt.params.peer_db.orientation_handle);
    break;



    case THINGY_TMS_UUID_QUATERNION_CHAR :
    evt.params.peer_db.quat_cccd_handle = p_char->cccd_handle;
    evt.params.peer_db.quat_handle = p_char->characteristic.handle_value;
    NRF_LOG_INFO("%d >> evt quaternion handle = %d", p_ble_thingy_tms_c->conn_handle, evt.params.peer_db.quat_handle);
    break;

    */


    case THINGY_TMS_UUID_PEDOMETER_CHAR:
    evt.params.peer_db.pedo_cccd_handle = p_char->cccd_handle;
    evt.params.peer_db.pedo_handle = p_char->characteristic.handle_value;
    NRF_LOG_INFO("%d >> evt pedo handle = %d", p_ble_thingy_tms_c->conn_handle,evt.params.peer_db.pedo_handle);
    break;


    case THINGY_TMS_UUID_RAW_CHAR :
    evt.params.peer_db.raw_cccd_handle = p_char->cccd_handle;
    evt.params.peer_db.raw_handle = p_char->characteristic.handle_value;
    NRF_LOG_INFO("%d >> evt raw handle = %d",p_ble_thingy_tms_c->conn_handle, evt.params.peer_db.raw_handle);
    break;


    case THINGY_TMS_UUID_TAP_CHAR:
    evt.params.peer_db.tap_cccd_handle = p_char->cccd_handle;
    evt.params.peer_db.tap_handle = p_char->characteristic.handle_value;
    NRF_LOG_INFO("%d >> evt tap handle = %d", p_ble_thingy_tms_c->conn_handle,evt.params.peer_db.tap_handle);
    break;

    this is my code 

  • Hi 

    It seems you are setting up the handles correctly, but you also need functions to enable notifications. 

    As luck should have it I recently implemented the TMS client for a different project, and I am attaching the files here so you can use it for reference:
    ble_thingy_tms_c.zip

    Please note all the functions at the bottom of the .c file called something like ble_thingy_tms_c_xxx_notif_enable(..)

    You need to call this function for each characteristic from which you want to receive notifications. 

    Best regards
    Torbjørn

  • uint32_t ble_thingy_tms_c_quat_notif_enable(ble_thingy_tms_c_t * p_ble_thingy_tms_c)
    {
    VERIFY_PARAM_NOT_NULL(p_ble_thingy_tms_c);

    if (p_ble_thingy_tms_c->conn_handle == BLE_CONN_HANDLE_INVALID)
    {
    return NRF_ERROR_INVALID_STATE;
    }
    // NRF_LOG_INFO("quat notif_enable");


    return cccd_configure(p_ble_thingy_tms_c->conn_handle,
    p_ble_thingy_tms_c->peer_thingy_tms_db.quat_cccd_handle,
    true);
    }
    uint32_t ble_thingy_tms_c_tap_notif_enable(ble_thingy_tms_c_t * p_ble_thingy_tms_c)
    {
    VERIFY_PARAM_NOT_NULL(p_ble_thingy_tms_c);

    if (p_ble_thingy_tms_c->conn_handle == BLE_CONN_HANDLE_INVALID)
    {
    return NRF_ERROR_INVALID_STATE;
    }
    // NRF_LOG_INFO("tap notif_enable");

    return cccd_configure(p_ble_thingy_tms_c->conn_handle,
    p_ble_thingy_tms_c->peer_thingy_tms_db.tap_cccd_handle,
    true);
    }

    uint32_t ble_thingy_tms_c_pedo_notif_enable(ble_thingy_tms_c_t * p_ble_thingy_tms_c)
    {
    VERIFY_PARAM_NOT_NULL(p_ble_thingy_tms_c);

    if (p_ble_thingy_tms_c->conn_handle == BLE_CONN_HANDLE_INVALID)
    {
    return NRF_ERROR_INVALID_STATE;
    }
    // NRF_LOG_INFO("pedo notif_enable");

    return cccd_configure(p_ble_thingy_tms_c->conn_handle,
    p_ble_thingy_tms_c->peer_thingy_tms_db.pedo_cccd_handle,
    true);
    }
    uint32_t ble_thingy_tms_c_raw_notif_enable(ble_thingy_tms_c_t * p_ble_thingy_tms_c)
    {
    VERIFY_PARAM_NOT_NULL(p_ble_thingy_tms_c);

    if (p_ble_thingy_tms_c->conn_handle == BLE_CONN_HANDLE_INVALID)
    {
    return NRF_ERROR_INVALID_STATE;
    }
    // NRF_LOG_INFO("raw notif_enable");

    return cccd_configure(p_ble_thingy_tms_c->conn_handle,
    p_ble_thingy_tms_c->peer_thingy_tms_db.raw_cccd_handle,
    true);

    }


    uint32_t ble_thingy_tms_c_euler_notif_enable(ble_thingy_tms_c_t * p_ble_thingy_tms_c)
    {
    VERIFY_PARAM_NOT_NULL(p_ble_thingy_tms_c);

    if (p_ble_thingy_tms_c->conn_handle == BLE_CONN_HANDLE_INVALID)
    {
    return NRF_ERROR_INVALID_STATE;
    }

    return cccd_configure(p_ble_thingy_tms_c->conn_handle,
    p_ble_thingy_tms_c->peer_thingy_tms_db.euler_cccd_handle,
    true);
    }
    uint32_t ble_thingy_tms_c_orientation_notif_enable(ble_thingy_tms_c_t * p_ble_thingy_tms_c)
    {
    VERIFY_PARAM_NOT_NULL(p_ble_thingy_tms_c);

    if (p_ble_thingy_tms_c->conn_handle == BLE_CONN_HANDLE_INVALID)
    {
    return NRF_ERROR_INVALID_STATE;
    }
    // NRF_LOG_INFO("orientation notif_enable");


    return cccd_configure(p_ble_thingy_tms_c->conn_handle,
    p_ble_thingy_tms_c->peer_thingy_tms_db.orientation_cccd_handle,
    true);
    }
    uint32_t ble_thingy_tms_c_gravity_notif_enable(ble_thingy_tms_c_t * p_ble_thingy_tms_c)
    {
    VERIFY_PARAM_NOT_NULL(p_ble_thingy_tms_c);

    if (p_ble_thingy_tms_c->conn_handle == BLE_CONN_HANDLE_INVALID)
    {
    return NRF_ERROR_INVALID_STATE;
    }
    NRF_LOG_INFO("gravity notif_enable");

    return cccd_configure(p_ble_thingy_tms_c->conn_handle,
    p_ble_thingy_tms_c->peer_thingy_tms_db.gravity_cccd_handle,
    true);
    }
    uint32_t ble_thingy_tms_c_heading_notif_enable(ble_thingy_tms_c_t * p_ble_thingy_tms_c)
    {
    VERIFY_PARAM_NOT_NULL(p_ble_thingy_tms_c);

    if (p_ble_thingy_tms_c->conn_handle == BLE_CONN_HANDLE_INVALID)
    {
    return NRF_ERROR_INVALID_STATE;
    }
    NRF_LOG_INFO("heading notif_enable");
    return cccd_configure(p_ble_thingy_tms_c->conn_handle,
    p_ble_thingy_tms_c->peer_thingy_tms_db.heading_cccd_handle,
    true);
    }
    uint32_t ble_thingy_tms_c_config_notif_enable(ble_thingy_tms_c_t * p_ble_thingy_tms_c)
    {
    VERIFY_PARAM_NOT_NULL(p_ble_thingy_tms_c);

    if (p_ble_thingy_tms_c->conn_handle == BLE_CONN_HANDLE_INVALID)
    {
    return NRF_ERROR_INVALID_STATE;
    }

    return cccd_configure(p_ble_thingy_tms_c->conn_handle,
    p_ble_thingy_tms_c->peer_thingy_tms_db.config_cccd_handle,
    true);
    }
    uint32_t ble_thingy_tms_c_rot_notif_enable(ble_thingy_tms_c_t * p_ble_thingy_tms_c)
    {
    VERIFY_PARAM_NOT_NULL(p_ble_thingy_tms_c);

    if (p_ble_thingy_tms_c->conn_handle == BLE_CONN_HANDLE_INVALID)
    {
    return NRF_ERROR_INVALID_STATE;
    }

    return cccd_configure(p_ble_thingy_tms_c->conn_handle,
    p_ble_thingy_tms_c->peer_thingy_tms_db.rot_cccd_handle,
    true);
    }

    this is my code  in ble.c 

    there is code in main.c

    static void thingy_tms_c_evt_handler(ble_thingy_tms_c_t * p_thingy_tms_c, ble_thingy_tms_c_evt_t * p_thingy_tms_c_evt)
    {
    ret_code_t err_code;
    switch (p_thingy_tms_c_evt->evt_type)
    {
    case BLE_THINGY_TMS_C_EVT_DISCOVERY_COMPLETE:
    {


    // uint32_t ble_thingy_tms_c_raw_notif_enable(ble_thingy_tms_c_t * p_ble_thingy_tms_c)
    err_code = ble_thingy_tms_c_heading_notif_enable(p_thingy_tms_c);
    APP_ERROR_CHECK(err_code);
    err_code = ble_thingy_tms_c_raw_notif_enable(p_thingy_tms_c);
    APP_ERROR_CHECK(err_code);
    err_code = ble_thingy_tms_c_quat_notif_enable(p_thingy_tms_c);
    APP_ERROR_CHECK(err_code);
    err_code = ble_thingy_tms_c_orientation_notif_enable(p_thingy_tms_c);
    APP_ERROR_CHECK(err_code);
    err_code = ble_thingy_tms_c_tap_notif_enable(p_thingy_tms_c);
    APP_ERROR_CHECK(err_code);
    err_code = ble_thingy_tms_c_pedo_notif_enable(p_thingy_tms_c);
    APP_ERROR_CHECK(err_code);
    err_code = ble_thingy_tms_c_euler_notif_enable(p_thingy_tms_c);
    APP_ERROR_CHECK(err_code);
    err_code = ble_thingy_tms_c_gravity_notif_enable(p_thingy_tms_c);
    APP_ERROR_CHECK(err_code);
    err_code = ble_thingy_tms_c_config_notif_enable(p_thingy_tms_c);
    APP_ERROR_CHECK(err_code);
    err_code = ble_thingy_tms_c_rot_notif_enable(p_thingy_tms_c);
    APP_ERROR_CHECK(err_code);

    ble_gap_conn_params_t conn_params;
    conn_params.max_conn_interval = MAX_CONNECTION_INTERVAL;
    conn_params.min_conn_interval = MIN_CONNECTION_INTERVAL;
    conn_params.slave_latency = SLAVE_LATENCY;
    conn_params.conn_sup_timeout = SUPERVISION_TIMEOUT;

    sd_ble_gap_conn_param_update(p_thingy_tms_c_evt->conn_handle, &conn_params);

    } break;
    // case BLE_THINGY_TES_C_EVT_TEMPERATURE_NOTIFICATION:
    //app_aggregator_temp_update(p_thingy_tes_c_evt->conn_handle, p_thingy_tes_c_evt->params.temperature.integer);
    // break;
    // case BLE_THINGY_TES_C_EVT_HUMIDITY_NOTIFICATION:
    //app_aggregator_humid_update(p_thingy_tes_c_evt->conn_handle, p_thingy_tes_c_evt->params.humidity.humidity);
    default :/*
    app_aggregator_temp_update(p_thingy_tes_c_evt->conn_handle, p_thingy_tes_c_evt->params.temperature.integer);
    app_aggregator_humid_update(p_thingy_tes_c_evt->conn_handle, p_thingy_tes_c_evt->params.humidity.humidity);*/
    break;

    }
    }

    it is correct?

Related