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
  • Hi 

    If you pull the latest update I increased the max connections to 16 for the nRF52840 project. 

    Have you modified the code to access the environmental values?
    Out of the box the multi link demo only accesses the UI service in the Thingys. 

    Best regards
    Torbjørn

  • 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 

    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?

  • Hi 

    Sorry for the late reply. I have been out travelling and haven't had time to follow up. 

    At first glance your code looks OK, but when enabling that many characteristics at the same time you might have to increase the buffer size inside the service module. 

    inside the ble_thingy_tsm_c.c file there should be two defines looking like this:
    #define TX_BUFFER_MASK 0x07 /**< TX Buffer mask, must be a mask of continuous zeroes, followed by continuous sequence of ones: 000...111. */
    #define TX_BUFFER_SIZE (TX_BUFFER_MASK + 1) /**< Size of send buffer, which is 1 higher than the mask. */

    Try to change them to this, and it should work better:
    #define TX_BUFFER_MASK 0x0F /**< TX Buffer mask, must be a mask of continuous zeroes, followed by continuous sequence of ones: 000...111. */
    #define TX_BUFFER_SIZE (TX_BUFFER_MASK + 1) /**< Size of send buffer, which is 1 higher than the mask. */

    Best regards
    Torbjørn

  • i don't found  ble_thingy_tsm_c.c 

    how to find  ble_thingy_tsm_c.c ?

  • Hi 

    This file was included in the ble_thingy_tms_c.zip file, that I sent you in my reply 16 days ago. 

    Please let me know if you still can't find it, and I will send it again. 

    Best regards
    Torbjørn

Reply Children
Related