ret_code_t svc_2000_actual_send(sUartBufDesc_t * p_bd) { ret_code_t err_code = NRF_ERROR_INVALID_STATE; int32_t index = get_svc_2000_connection_index(p_bd->conn_handle); if (-1 != index) { NRF_LOG_INFO("MTU OUT %d", p_svc_2000->conn_index[index].max_svc_len); /* -------------------------------------------------------------- ** At this point the all info for the msg is loaded ** If the msg length is greater than the MTU then we just load up ** the size of the mtu and keep track of the offset. ** we continue to load bytes and call the send again until we get ** NRF_ERROR_RESOURCES: The internal send queue is full ** then wait for the BLE_GATTS_EVT_HVN_TX_COMPLETE to send the ** next round until the msg is completely sent ** -------------------------------------------------------------- */ uint16_t msg_offset = 0; uint16_t total_length = p_bd->length; memset(p_encoded_buffer, 0, JS_APP_SCRATCH_BUFFER_SIZE); ble_gatts_hvx_params_t write_params = { .type = BLE_GATT_HVX_NOTIFICATION, .handle = p_svc_2000->control_handle.value_handle, .offset = msg_offset, .p_len = (uint16_t *)&total_length }; jackshaft_encode(p_bd->p_buffer, p_encoded_buffer, total_length); write_params.p_data = p_encoded_buffer; do { // line 417 NRF_LOG_INFO("%s:%d", __FUNCTION__, __LINE__); if (true == svc2000_tx_complete) { #if 0 for (int32_t loop_counter = 0; loop_counter < total_length; loop_counter++) { NRF_LOG_ERROR("%X", write_params.p_data[loop_counter]) } #endif // line 426 NRF_LOG_INFO("%s:%d", __FUNCTION__, __LINE__); err_code = sd_ble_gatts_hvx(p_svc_2000->conn_index[index].conn_handle, &write_params); // line 428 NRF_LOG_ERROR("S %d", err_code); if (0 == err_code) { msg_offset += 20; err_code = NRF_SUCCESS; } else if (NRF_ERROR_RESOURCES == err_code) { svc2000_tx_complete = false; err_code = NRF_ERROR_INVALID_PARAM; break; } } else { break; } // NRF_LOG_ERROR("PHONE TX %d %d %d", err_code, msg_offset, total_length); } while ((msg_offset <= total_length) && ((NRF_ERROR_RESOURCES == err_code) || (NRF_SUCCESS))); } if (IPC_RSP_BIT & p_bd->msg_type) { // NRF_LOG_WARNING("%s:%d JS_FREE", __FUNCTION__, __LINE__); js_free(p_bd); } return err_code; }