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

     [#elif](https://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](https://forum.espruino.com/search/?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](https://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](https://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](https://forum.espruino.com/search/?q=%23else)
        uint32_t err_code = ble_nus_string_send(&m_nus, nusTxBuf, &nuxTxBufLength);
     [#endif](https://forum.espruino.com/search/?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