| 3660 | } |
| 3661 | |
| 3662 | fl::json AutoResearchRemoteControl::startBleRemote() { |
| 3663 | if (mBleRemote) { |
| 3664 | fl::json response = fl::json::object(); |
| 3665 | response.set("success", true); |
| 3666 | response.set("message", "BLE remote already active"); |
| 3667 | response.set("device_name", AUTORESEARCH_BLE_DEVICE_NAME); |
| 3668 | return response; |
| 3669 | } |
| 3670 | |
| 3671 | // Create BLE GATT server (heap-allocates transport state) |
| 3672 | // On stub platforms, createTransport returns nullptr and logs FL_ERROR. |
| 3673 | mBleState = fl::net::ble::createTransport(AUTORESEARCH_BLE_DEVICE_NAME); |
| 3674 | if (!mBleState) { |
| 3675 | fl::json response = fl::json::object(); |
| 3676 | response.set("success", false); |
| 3677 | response.set("error", "BLE not available on this platform"); |
| 3678 | return response; |
| 3679 | } |
| 3680 | |
| 3681 | // Get transport lambdas that capture mBleState |
| 3682 | auto callbacks = fl::net::ble::getTransportCallbacks(mBleState); |
| 3683 | |
| 3684 | // Create BLE Remote instance with BLE transport |
| 3685 | mBleRemote = fl::make_unique<fl::Remote>(callbacks.first, callbacks.second); |
| 3686 | |
| 3687 | // Register RPC methods on the BLE remote |
| 3688 | registerAllMethods(mBleRemote.get()); |
| 3689 | |
| 3690 | mState->ble_server_active = true; |
| 3691 | getBleState().ble_server_active = true; |
| 3692 | |
| 3693 | fl::json response = fl::json::object(); |
| 3694 | response.set("success", true); |
| 3695 | response.set("device_name", AUTORESEARCH_BLE_DEVICE_NAME); |
| 3696 | response.set("service_uuid", FL_BLE_SERVICE_UUID); |
| 3697 | response.set("rx_uuid", FL_BLE_CHAR_RX_UUID); |
| 3698 | response.set("tx_uuid", FL_BLE_CHAR_TX_UUID); |
| 3699 | FL_WARN("[BLE] Remote created and advertising"); |
| 3700 | return response; |
| 3701 | } |
| 3702 | |
| 3703 | fl::json AutoResearchRemoteControl::stopBleRemote() { |
| 3704 | // Defer actual BLE teardown to tick() so the RPC response is sent first. |
no test coverage detected