void BluetoothHALInterface::CreateBond(const nsAString& aBdAddr, BluetoothTransport aTransport, BluetoothResultHandler* aRes) { bt_bdaddr_t bdAddr; int status; #if ANDROID_VERSION >= 21 int transport = 0; /* TRANSPORT_AUTO */ if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr)) && NS_SUCCEEDED(Convert(aTransport, transport))) { status = mInterface->create_bond(&bdAddr, transport); #else if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) { status = mInterface->create_bond(&bdAddr); #endif } else { status = BT_STATUS_PARM_INVALID; } if (aRes) { DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::CreateBond, ConvertDefault(status, STATUS_FAIL)); } } void BluetoothHALInterface::RemoveBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes) { bt_bdaddr_t bdAddr; int status; if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) { status = mInterface->remove_bond(&bdAddr); } else { status = BT_STATUS_PARM_INVALID; } if (aRes) { DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::RemoveBond, ConvertDefault(status, STATUS_FAIL)); } }
void BluetoothHALInterface::GetRemoteDeviceProperty( const nsAString& aRemoteAddr, const nsAString& aName, BluetoothResultHandler* aRes) { int status; bt_bdaddr_t remoteAddr; bt_property_type_t name; /* FIXME: you need to implement the missing conversion functions */ NS_NOTREACHED("Conversion function missing"); if (NS_SUCCEEDED(Convert(aRemoteAddr, remoteAddr)) && false /* TODO: we don't support any values for aName currently */) { // silence uninitialized variable warning for |name| name = static_cast<bt_property_type_t>(0); status = mInterface->get_remote_device_property(&remoteAddr, name); } else { status = BT_STATUS_PARM_INVALID; } if (aRes) { DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::GetRemoteDeviceProperty, ConvertDefault(status, STATUS_FAIL)); } }
void BluetoothHALInterface::PinReply(const nsAString& aBdAddr, bool aAccept, const nsAString& aPinCode, BluetoothResultHandler* aRes) { int status; bt_bdaddr_t bdAddr; uint8_t accept; bt_pin_code_t pinCode; if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr)) && NS_SUCCEEDED(Convert(aAccept, accept)) && NS_SUCCEEDED(Convert(aPinCode, pinCode))) { status = mInterface->pin_reply(&bdAddr, accept, aPinCode.Length(), &pinCode); } else { status = BT_STATUS_PARM_INVALID; } if (aRes) { DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::PinReply, ConvertDefault(status, STATUS_FAIL)); } }
void BluetoothHALInterface::SetRemoteDeviceProperty( const nsAString& aRemoteAddr, const BluetoothNamedValue& aProperty, BluetoothResultHandler* aRes) { int status; bt_bdaddr_t remoteAddr; bt_property_t property; /* FIXME: you need to implement the missing conversion functions */ NS_NOTREACHED("Conversion function missing"); if (NS_SUCCEEDED(Convert(aRemoteAddr, remoteAddr)) && false /* TODO: we don't support any values for aProperty currently */) { status = mInterface->set_remote_device_property(&remoteAddr, &property); } else { status = BT_STATUS_PARM_INVALID; } if (aRes) { DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::SetRemoteDeviceProperty, ConvertDefault(status, STATUS_FAIL)); } }
void BluetoothHALInterface::SspReply(const nsAString& aBdAddr, BluetoothSspVariant aVariant, bool aAccept, uint32_t aPasskey, BluetoothResultHandler* aRes) { int status; bt_bdaddr_t bdAddr; bt_ssp_variant_t variant; uint8_t accept; if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr)) && NS_SUCCEEDED(Convert(aVariant, variant)) && NS_SUCCEEDED(Convert(aAccept, accept))) { status = mInterface->ssp_reply(&bdAddr, variant, accept, aPasskey); } else { status = BT_STATUS_PARM_INVALID; } if (aRes) { DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::SspReply, ConvertDefault(status, STATUS_FAIL)); } }
void BluetoothHALInterface::Init( BluetoothNotificationHandler* aNotificationHandler, BluetoothResultHandler* aRes) { static bt_callbacks_t sBluetoothCallbacks = { sizeof(sBluetoothCallbacks), BluetoothCallback::AdapterStateChanged, BluetoothCallback::AdapterProperties, BluetoothCallback::RemoteDeviceProperties, BluetoothCallback::DeviceFound, BluetoothCallback::DiscoveryStateChanged, BluetoothCallback::PinRequest, BluetoothCallback::SspRequest, BluetoothCallback::BondStateChanged, BluetoothCallback::AclStateChanged, BluetoothCallback::ThreadEvt, BluetoothCallback::DutModeRecv #if ANDROID_VERSION >= 18 , BluetoothCallback::LeTestMode #endif }; sNotificationHandler = aNotificationHandler; int status = mInterface->init(&sBluetoothCallbacks); if (aRes) { DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::Init, ConvertDefault(status, STATUS_FAIL)); } }
void BluetoothHALInterface::Disable(BluetoothResultHandler* aRes) { int status = mInterface->disable(); if (aRes) { DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::Disable, ConvertDefault(status, STATUS_FAIL)); } }
void BluetoothHALInterface::CancelDiscovery(BluetoothResultHandler* aRes) { int status = mInterface->cancel_discovery(); if (aRes) { DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::CancelDiscovery, ConvertDefault(status, STATUS_FAIL)); } }
void BluetoothHALInterface::GetAdapterProperties(BluetoothResultHandler* aRes) { int status = mInterface->get_adapter_properties(); if (aRes) { DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::GetAdapterProperties, ConvertDefault(status, STATUS_FAIL)); } }
void BluetoothHALInterface::DutModeSend(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen, BluetoothResultHandler* aRes) { int status = mInterface->dut_mode_send(aOpcode, aBuf, aLen); if (aRes) { DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::DutModeSend, ConvertDefault(status, STATUS_FAIL)); } }
void BluetoothHALInterface::Cleanup(BluetoothResultHandler* aRes) { mInterface->cleanup(); if (aRes) { DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::Cleanup, STATUS_SUCCESS); } sNotificationHandler = nullptr; }
void BluetoothHALInterface::Init( BluetoothNotificationHandler* aNotificationHandler, BluetoothResultHandler* aRes) { static bt_callbacks_t sBluetoothCallbacks = { sizeof(sBluetoothCallbacks), BluetoothCallback::AdapterStateChanged, BluetoothCallback::AdapterProperties, BluetoothCallback::RemoteDeviceProperties, BluetoothCallback::DeviceFound, BluetoothCallback::DiscoveryStateChanged, BluetoothCallback::PinRequest, BluetoothCallback::SspRequest, BluetoothCallback::BondStateChanged, BluetoothCallback::AclStateChanged, BluetoothCallback::ThreadEvt, BluetoothCallback::DutModeRecv, #if ANDROID_VERSION >= 18 BluetoothCallback::LeTestMode, #endif #if ANDROID_VERSION >= 21 BluetoothCallback::EnergyInfo #endif }; #if ANDROID_VERSION >= 21 static bt_os_callouts_t sBluetoothOsCallouts = { sizeof(sBluetoothOsCallouts), BluetoothOsCallout::SetWakeAlarm, BluetoothOsCallout::AcquireWakeLock, BluetoothOsCallout::ReleaseWakeLock }; #endif sNotificationHandler = aNotificationHandler; int status = mInterface->init(&sBluetoothCallbacks); #if ANDROID_VERSION >= 21 if (status == BT_STATUS_SUCCESS) { status = mInterface->set_os_callouts(&sBluetoothOsCallouts); if (status != BT_STATUS_SUCCESS) { mInterface->cleanup(); } } #endif if (aRes) { DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::Init, ConvertDefault(status, STATUS_FAIL)); } }
/* Energy Information */ void BluetoothHALInterface::ReadEnergyInfo(BluetoothResultHandler* aRes) { #if ANDROID_VERSION >= 21 int status = mInterface->read_energy_info(); #else int status = BT_STATUS_UNSUPPORTED; #endif if (aRes) { DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::ReadEnergyInfo, ConvertDefault(status, STATUS_FAIL)); } }
void BluetoothHALInterface::LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen, BluetoothResultHandler* aRes) { #if ANDROID_VERSION >= 18 int status = mInterface->le_test_mode(aOpcode, aBuf, aLen); #else int status = BT_STATUS_UNSUPPORTED; #endif if (aRes) { DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::LeTestMode, ConvertDefault(status, STATUS_FAIL)); } }
void BluetoothHALInterface::GetRemoteServices(const nsAString& aRemoteAddr, BluetoothResultHandler* aRes) { int status; bt_bdaddr_t remoteAddr; if (NS_SUCCEEDED(Convert(aRemoteAddr, remoteAddr))) { status = mInterface->get_remote_services(&remoteAddr); } else { status = BT_STATUS_PARM_INVALID; } if (aRes) { DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::GetRemoteServices, ConvertDefault(status, STATUS_FAIL)); } }
void BluetoothHALInterface::DutModeConfigure(bool aEnable, BluetoothResultHandler* aRes) { int status; uint8_t enable; if (NS_SUCCEEDED(Convert(aEnable, enable))) { status = mInterface->dut_mode_configure(enable); } else { status = BT_STATUS_PARM_INVALID; } if (aRes) { DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::DutModeConfigure, ConvertDefault(status, STATUS_FAIL)); } }
void BluetoothHALInterface::CancelBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes) { bt_bdaddr_t bdAddr; int status; if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) { status = mInterface->cancel_bond(&bdAddr); } else { status = BT_STATUS_PARM_INVALID; } if (aRes) { DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::CancelBond, ConvertDefault(status, STATUS_FAIL)); } }
void BluetoothHALInterface::SetAdapterProperty( const BluetoothNamedValue& aProperty, BluetoothResultHandler* aRes) { int status; ConvertNamedValue convertProperty(aProperty); bt_property_t property; if (NS_SUCCEEDED(Convert(convertProperty, property))) { status = mInterface->set_adapter_property(&property); } else { status = BT_STATUS_PARM_INVALID; } if (aRes) { DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::SetAdapterProperty, ConvertDefault(status, STATUS_FAIL)); } }
void BluetoothHALInterface::GetAdapterProperty(const nsAString& aName, BluetoothResultHandler* aRes) { int status; bt_property_type_t type; /* FIXME: you need to implement the missing conversion functions */ NS_NOTREACHED("Conversion function missing"); if (false /* TODO: we don't support any values for aName currently */) { status = mInterface->get_adapter_property(type); } else { status = BT_STATUS_PARM_INVALID; } if (aRes) { DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::GetAdapterProperties, ConvertDefault(status, STATUS_FAIL)); } }
void BluetoothHALInterface::GetRemoteServiceRecord(const nsAString& aRemoteAddr, const uint8_t aUuid[16], BluetoothResultHandler* aRes) { int status; bt_bdaddr_t remoteAddr; bt_uuid_t uuid; if (NS_SUCCEEDED(Convert(aRemoteAddr, remoteAddr)) && NS_SUCCEEDED(Convert(aUuid, uuid))) { status = mInterface->get_remote_service_record(&remoteAddr, &uuid); } else { status = BT_STATUS_PARM_INVALID; } if (aRes) { DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::GetRemoteServiceRecord, ConvertDefault(status, STATUS_FAIL)); } }
void BluetoothHALInterface::GetConnectionState(const nsAString& aBdAddr, BluetoothResultHandler* aRes) { int status; #if ANDROID_VERSION >= 21 bt_bdaddr_t bdAddr; if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) { status = mInterface->get_connection_state(&bdAddr); } else { status = BT_STATUS_PARM_INVALID; } #else status = BT_STATUS_UNSUPPORTED; #endif if (aRes) { DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::GetConnectionState, ConvertDefault(status, STATUS_FAIL)); } }