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

Large data transfer over ble.

Hi,

I would like to have a system such as follows:

  • Taking sensor data storing it locally till around 100 samples (Once per second)
  • Log this data to the SD with a time stamp
  • Then storing this data to an external SD card. (Utilising the fatfs example code in the SDK) Around  2 Mbytes
  • I then want a mobile device to request this data.

What therefore, is the best way of transferring the data from the SD card to BLE to be picked up by the mobile application.

Do I need to set up a GATT connection and wait on a notification change that I set in the Nordic board?

If so is there an example of this or a good starting point.

Would this post be a good starting point? : https://devzone.nordicsemi.com/f/nordic-q-a/553/dealing-large-data-packet-s-through-ble

If so what example is good to work from. Thanks

Parents
  • Hi

    I believe the ble_app_pwr_profiling example uses the sd_ble_gap_adv_set_configure function in order to set up two different advertising buffers, however, we don't have an example for updating advertising data regularly like you want to.

    Best regards,

    Simon

  • Hi Simon,

    I have looked through the ble_app_pwr_profiling example. I have gotten it to work with my advertising that updates once per second from data coming in via UART.

    However, whilst this works. Using the nordic semi conductor app (NRF connect). The device comes up with the live data and a connection is available.

    The way my code works at the moment is as follows:

    • init the advert via button press (connectable)
    • Wait for UART string data (received once per second)
    • Update the advert (Run advertising_mod function see below)
    • Loop

    Then when press connect nothing is populated within the services menu also, I am chucking the data out to a RTT viewer. When I press connect I stop my live advertising Via a boolean that is set from the ble_evt_handler connected state. Then I can see the services. But, when I disconnect I get fatal error.

    This runs from BLE_GATTS_EVT_TIMEOUT APP 

    Advertising Mod: Note m_beacon is just for storing my data values inside of.

    static void advertising_mod(int count, int T1_value,int T2_value,
                                           int t3_value_1,int t3_value_2, int p1_value_1, int p1_value_2,
                                           int p2_value_1,int p2_value_2)
    {
        uint32_t      err_code;
        ble_advdata_t advdata;
        uint8_t       flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;
        
        int t1_value_1 = (T1_value >>8) & 0XFF;//MSB shifting
        int t1_value_2 = T1_value & 0XFF;//LSB
    
        int t2_value_1 = (T2_value >> 8) & 0XFF;//MSB
        int t2_value_2 = T2_value & 0XFF;//LSB
    
        ble_advdata_manuf_data_t manuf_specific_data;
        m_beacon_info[0]=(unsigned char) count;
        m_beacon_info[1]=(unsigned char) t1_value_1;
        m_beacon_info[2]=(unsigned char) t1_value_2;
        m_beacon_info[3]=(unsigned char) t2_value_1;
        m_beacon_info[4]=(unsigned char) t2_value_2;
        m_beacon_info[5]=(unsigned char) t3_value_1;
        m_beacon_info[6]=(unsigned char) t3_value_2;
        m_beacon_info[7]=(unsigned char) p1_value_1;
        m_beacon_info[8]=(unsigned char) p1_value_2;
        m_beacon_info[9]=(unsigned char) p2_value_1;
        m_beacon_info[10]=(unsigned char) p2_value_2;
       
        manuf_specific_data.company_identifier = COMPANY_IDENTIFIER;
        manuf_specific_data.data.p_data = (uint8_t *) m_beacon_info;
        manuf_specific_data.data.size   = APP_BEACON_INFO_LENGTH;
    
        // Build and set advertising data.
        memset(&advdata, 0, sizeof(advdata));
    
        advdata.name_type             = BLE_ADVDATA_NO_NAME;
        advdata.flags                 = flags;
        advdata.p_manuf_specific_data = &manuf_specific_data;
    
        // Initialize advertising parameters (used when starting advertising).
        memset(&m_adv_params, 0, sizeof(m_adv_params));
    
        m_adv_params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED;
        //m_adv_params.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;
        m_adv_params.p_peer_addr     = NULL;    // Undirected advertisement.
        m_adv_params.filter_policy   = BLE_GAP_ADV_FP_ANY;
        m_adv_params.interval        = CONNECTABLE_ADV_INTERVAL;
        m_adv_params.duration        = APP_ADV_DURATION;       // 30 Second adverts
        m_adv_params.primary_phy     = BLE_GAP_PHY_1MBPS;
    
        err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
        APP_ERROR_CHECK(err_code);
    
        err_code = sd_ble_gap_adv_stop(m_adv_handle);
        APP_ERROR_CHECK(err_code);
    
        err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params);
        APP_ERROR_CHECK(err_code);
    
        err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG);
        APP_ERROR_CHECK(err_code);
    }

    The error comes from err_code = sd_ble_gap_disconnect(p_ble_evt->evt.gatts_evt.conn_handle,
    BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);

    But, I am not sure why.

    Thanks,

    Thomas

Reply
  • Hi Simon,

    I have looked through the ble_app_pwr_profiling example. I have gotten it to work with my advertising that updates once per second from data coming in via UART.

    However, whilst this works. Using the nordic semi conductor app (NRF connect). The device comes up with the live data and a connection is available.

    The way my code works at the moment is as follows:

    • init the advert via button press (connectable)
    • Wait for UART string data (received once per second)
    • Update the advert (Run advertising_mod function see below)
    • Loop

    Then when press connect nothing is populated within the services menu also, I am chucking the data out to a RTT viewer. When I press connect I stop my live advertising Via a boolean that is set from the ble_evt_handler connected state. Then I can see the services. But, when I disconnect I get fatal error.

    This runs from BLE_GATTS_EVT_TIMEOUT APP 

    Advertising Mod: Note m_beacon is just for storing my data values inside of.

    static void advertising_mod(int count, int T1_value,int T2_value,
                                           int t3_value_1,int t3_value_2, int p1_value_1, int p1_value_2,
                                           int p2_value_1,int p2_value_2)
    {
        uint32_t      err_code;
        ble_advdata_t advdata;
        uint8_t       flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;
        
        int t1_value_1 = (T1_value >>8) & 0XFF;//MSB shifting
        int t1_value_2 = T1_value & 0XFF;//LSB
    
        int t2_value_1 = (T2_value >> 8) & 0XFF;//MSB
        int t2_value_2 = T2_value & 0XFF;//LSB
    
        ble_advdata_manuf_data_t manuf_specific_data;
        m_beacon_info[0]=(unsigned char) count;
        m_beacon_info[1]=(unsigned char) t1_value_1;
        m_beacon_info[2]=(unsigned char) t1_value_2;
        m_beacon_info[3]=(unsigned char) t2_value_1;
        m_beacon_info[4]=(unsigned char) t2_value_2;
        m_beacon_info[5]=(unsigned char) t3_value_1;
        m_beacon_info[6]=(unsigned char) t3_value_2;
        m_beacon_info[7]=(unsigned char) p1_value_1;
        m_beacon_info[8]=(unsigned char) p1_value_2;
        m_beacon_info[9]=(unsigned char) p2_value_1;
        m_beacon_info[10]=(unsigned char) p2_value_2;
       
        manuf_specific_data.company_identifier = COMPANY_IDENTIFIER;
        manuf_specific_data.data.p_data = (uint8_t *) m_beacon_info;
        manuf_specific_data.data.size   = APP_BEACON_INFO_LENGTH;
    
        // Build and set advertising data.
        memset(&advdata, 0, sizeof(advdata));
    
        advdata.name_type             = BLE_ADVDATA_NO_NAME;
        advdata.flags                 = flags;
        advdata.p_manuf_specific_data = &manuf_specific_data;
    
        // Initialize advertising parameters (used when starting advertising).
        memset(&m_adv_params, 0, sizeof(m_adv_params));
    
        m_adv_params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED;
        //m_adv_params.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;
        m_adv_params.p_peer_addr     = NULL;    // Undirected advertisement.
        m_adv_params.filter_policy   = BLE_GAP_ADV_FP_ANY;
        m_adv_params.interval        = CONNECTABLE_ADV_INTERVAL;
        m_adv_params.duration        = APP_ADV_DURATION;       // 30 Second adverts
        m_adv_params.primary_phy     = BLE_GAP_PHY_1MBPS;
    
        err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
        APP_ERROR_CHECK(err_code);
    
        err_code = sd_ble_gap_adv_stop(m_adv_handle);
        APP_ERROR_CHECK(err_code);
    
        err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params);
        APP_ERROR_CHECK(err_code);
    
        err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG);
        APP_ERROR_CHECK(err_code);
    }

    The error comes from err_code = sd_ble_gap_disconnect(p_ble_evt->evt.gatts_evt.conn_handle,
    BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);

    But, I am not sure why.

    Thanks,

    Thomas

Children
No Data
Related