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

two slave, data, overlapped

i am using this project:

\nRF5_SDK_14.2.0_17b948a\examples\ble_central\ble_app_uart_c\main.c as center.

nRF5_SDK_14.2.0_17b948a\examples\ble_peripheral\ble_app_uart\main.c as slave.

i have two slave ,the data flow is this :

slave(two slave  air) -->center -( physical serial)---->andorid board -- >display screen 

the two slave send button state and position data to center.

if i use only one slave, data is all ok

but if i connect two slave. sometimes i miss one of slaves 's button press message 

and sometimes i found the position data is overlapped.

for example slave a send;    i am jam;

slave b send:  i am cherry 

when two slave is connected with center, the display screen show : i am  i am cherry 

i think slave a's data is interruped by slave b's data or may be some buffer is overflow,slave a's data is overwrite.

how can i fix this ???

Parents Reply Children
  • i have defined more instance, it works well .the only problem is i missed some data when two slave connect.

    BLE_NUS_C_DEF(m_ble_nus_c); /**< BLE NUS service client instance. */
    BLE_NUS_C_DEF(m_ble_nus_c1);
    BLE_NUS_C_DEF(m_ble_nus_c2);
    BLE_NUS_C_DEF(m_ble_nus_c3);

    BLE_DB_DISCOVERY_DEF(m_db_disc);
    BLE_DB_DISCOVERY_DEF(m_db_disc1);
    BLE_DB_DISCOVERY_DEF(m_db_disc2);
    BLE_DB_DISCOVERY_DEF(m_db_disc3);

    in function static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)

    i add the following code

    if(p_ble_evt->evt.gap_evt.conn_handle == 0)
    {
    err_code = ble_nus_c_handles_assign(&m_ble_nus_c, p_ble_evt->evt.gap_evt.conn_handle, NULL);
    APP_ERROR_CHECK(err_code);
    }
    if(p_ble_evt->evt.gap_evt.conn_handle == 1)
    {
    err_code = ble_nus_c_handles_assign(&m_ble_nus_c1, p_ble_evt->evt.gap_evt.conn_handle, NULL);
    APP_ERROR_CHECK(err_code);
    }
    if(p_ble_evt->evt.gap_evt.conn_handle == 2)
    {
    err_code = ble_nus_c_handles_assign(&m_ble_nus_c2, p_ble_evt->evt.gap_evt.conn_handle, NULL);
    APP_ERROR_CHECK(err_code);
    }
    if(p_ble_evt->evt.gap_evt.conn_handle == 3)
    {
    err_code = ble_nus_c_handles_assign(&m_ble_nus_c3, p_ble_evt->evt.gap_evt.conn_handle, NULL);
    APP_ERROR_CHECK(err_code);
    }


    if(p_ble_evt->evt.gap_evt.conn_handle == 0)
    {
    err_code = ble_db_discovery_start(&m_db_disc, p_ble_evt->evt.gap_evt.conn_handle);
    APP_ERROR_CHECK(err_code);
    }
    if(p_ble_evt->evt.gap_evt.conn_handle == 1)
    {
    err_code = ble_db_discovery_start(&m_db_disc1, p_ble_evt->evt.gap_evt.conn_handle);
    APP_ERROR_CHECK(err_code);
    }

    if(p_ble_evt->evt.gap_evt.conn_handle == 2)
    {
    err_code = ble_db_discovery_start(&m_db_disc2, p_ble_evt->evt.gap_evt.conn_handle);
    APP_ERROR_CHECK(err_code);
    }
    if(p_ble_evt->evt.gap_evt.conn_handle == 3)
    {
    err_code = ble_db_discovery_start(&m_db_disc3, p_ble_evt->evt.gap_evt.conn_handle);
    APP_ERROR_CHECK(err_code);
    }
    err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
    APP_ERROR_CHECK(err_code);

    if (ble_conn_state_n_centrals() == NRF_SDH_BLE_CENTRAL_LINK_COUNT)
    {
    ;
    }
    else
    {
    scan_start();
    }

    the config's following

    // <o> NRF_SDH_BLE_PERIPHERAL_LINK_COUNT - Maximum number of peripheral links.
    #ifndef NRF_SDH_BLE_PERIPHERAL_LINK_COUNT
    #define NRF_SDH_BLE_PERIPHERAL_LINK_COUNT 0
    #endif

    // <o> NRF_SDH_BLE_CENTRAL_LINK_COUNT - Maximum number of central links.
    #ifndef NRF_SDH_BLE_CENTRAL_LINK_COUNT
    #define NRF_SDH_BLE_CENTRAL_LINK_COUNT 4
    #endif

    // <o> NRF_SDH_BLE_TOTAL_LINK_COUNT - Maximum number of total concurrent connections using the default configuration.
    #ifndef NRF_SDH_BLE_TOTAL_LINK_COUNT
    #define NRF_SDH_BLE_TOTAL_LINK_COUNT 4
    #endif

    // <o> NRF_SDH_BLE_GAP_EVENT_LENGTH - The time set aside for this connection on every connection interval in 1.25 ms units.
    #ifndef NRF_SDH_BLE_GAP_EVENT_LENGTH
    #define NRF_SDH_BLE_GAP_EVENT_LENGTH 3
    #endif

    // <o> NRF_SDH_BLE_GATT_MAX_MTU_SIZE - Static maximum MTU size.
    #ifndef NRF_SDH_BLE_GATT_MAX_MTU_SIZE
    #define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 247
    #endif

    // <o> NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE - Attribute Table size in bytes. The size must be a multiple of 4.
    #ifndef NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE
    #define NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE 1408
    #endif

    // <o> NRF_SDH_BLE_VS_UUID_COUNT - The number of vendor-specific UUIDs.
    #ifndef NRF_SDH_BLE_VS_UUID_COUNT
    #define NRF_SDH_BLE_VS_UUID_COUNT 1
    #endif

    // <q> NRF_SDH_BLE_SERVICE_CHANGED - Include the Service Changed characteristic in the Attribute Table.

    #ifndef NRF_SDH_BLE_SERVICE_CHANGED
    #define NRF_SDH_BLE_SERVICE_CHANGED 0
    #endif

Related