diff --git a/app/ble/ble_modem.c b/app/ble/ble_modem.c index 10fe1ad..ccd90aa 100644 --- a/app/ble/ble_modem.c +++ b/app/ble/ble_modem.c @@ -10,14 +10,15 @@ //Is needed for the BT off workaround #include "wm_wifi.h" -bool ble_modem_on(bool startService) +bool ble_modem_on(bool bluetoothOnly, bool startService) { int status = BLE_HS_ENOERR; bool serviceStartSuccess = true; uint8_t uart_no = 0xFF; tls_appl_trace_level = TLS_BT_LOG_VERBOSE; //Should be set with a config define - if(bt_adapter_state == WM_BT_STATE_ON) { + if(bt_adapter_state == WM_BT_STATE_ON) + { TLS_BT_APPL_TRACE_VERBOSE("ble modem already on"NEW_LINE); return true; } @@ -26,13 +27,19 @@ bool ble_modem_on(bool startService) tls_appl_trace_level); status = tls_bt_init(uart_no); - if((status != BLE_HS_ENOERR) && (status != BLE_HS_EALREADY)) { + if((status != BLE_HS_ENOERR) && (status != BLE_HS_EALREADY)) + { TLS_BT_APPL_TRACE_ERROR("%s, tls_bt_init ret:%s"NEW_LINE, __FUNCTION__, tls_bt_rc_2_str(status)); } - - // Start the ble service if it was asked and if it is not yet started - if(startService && !ble_service_is_started()) - serviceStartSuccess = ble_service_start(); + else + { + // If we successfully started the modem, we can set it's working mode. + if(bluetoothOnly) + tls_rf_bt_mode(true); + // Start the ble service if it was asked and if it is not yet started + if(startService && !ble_service_is_started()) + serviceStartSuccess = ble_service_start(); + } return ((status == BLE_HS_ENOERR || status == BLE_HS_EALREADY) && serviceStartSuccess) ? true : false; } diff --git a/app/ble/ble_modem.h b/app/ble/ble_modem.h index 9c4c186..0e3ae25 100644 --- a/app/ble/ble_modem.h +++ b/app/ble/ble_modem.h @@ -10,7 +10,7 @@ * @return true on success * @return false on failure */ -bool ble_modem_on(bool startService); +bool ble_modem_on(bool bluetoothOnly, bool startService); /** * @brief Turns the BLE modem off @@ -29,4 +29,4 @@ bool ble_modem_off(void); */ bool is_ble_modem_on(void); -#endif //BLE_MODEM_H \ No newline at end of file +#endif //BLE_MODEM_H diff --git a/app/ble/ble_service.c b/app/ble/ble_service.c index bf63063..b72d294 100644 --- a/app/ble/ble_service.c +++ b/app/ble/ble_service.c @@ -333,7 +333,7 @@ bool ble_service_request_mtu_exchange(void) bool ble_service_send_nus_data(const uint8_t *data, uint16_t length) { - // The NUS TX is using notifications + // The NUS is TX is using notifications if(notification_data.transfer_in_progress) { TLS_BT_APPL_TRACE_WARNING("%s, a transfer is already in progress"NEW_LINE, __FUNCTION__);