• OK, so I removed #else and added similar code to two cases above

     [#elif](http://forum.espruino.com/search­/?q=%23elif) NRF_SD_BLE_API_VERSION==5
        uint32_t err_code = ble_nus_string_send(&m_nus, nusTxBuf, &nuxTxBufLength);
        if (err_code == NRF_SUCCESS) nuxTxBufLength=0; // everything sent Ok
     [#endif](http://forum.espruino.com/searc­h/?q=%23endif)
    

    and it seems to work fine, no lost characters and webide can connect. Then the nuxTxBufLength=0; // everything sent Ok is same for all three cases so final version is

        // We have data - try and send it
    
     [#if](http://forum.espruino.com/search/?­q=%23if) NRF_SD_BLE_API_VERSION>5
        uint32_t err_code = ble_nus_data_send(&m_nus, nusTxBuf, &nuxTxBufLength, m_peripheral_conn_handle);
     [#elif](http://forum.espruino.com/search­/?q=%23elif) NRF_SD_BLE_API_VERSION<5
        uint32_t err_code = ble_nus_string_send(&m_nus, nusTxBuf, nuxTxBufLength);
     [#else](http://forum.espruino.com/search­/?q=%23else)
        uint32_t err_code = ble_nus_string_send(&m_nus, nusTxBuf, &nuxTxBufLength);
     [#endif](http://forum.espruino.com/searc­h/?q=%23endif)
        if (err_code == NRF_SUCCESS) {
          nuxTxBufLength=0; // everything sent Ok
          bleStatus |= BLE_IS_SENDING;
        } else if (err_code==NRF_ERROR_INVALID_STATE) {
    
About

Avatar for fanoush @fanoush started