本文整理汇总了C++中BluetoothService::DistributeSignal方法的典型用法代码示例。如果您正苦于以下问题:C++ BluetoothService::DistributeSignal方法的具体用法?C++ BluetoothService::DistributeSignal怎么用?C++ BluetoothService::DistributeSignal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BluetoothService
的用法示例。
在下文中一共展示了BluetoothService::DistributeSignal方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: signal
//
// Notification Handlers
//
void
BluetoothGattManager::RegisterClientNotification(int aStatus,
int aClientIf,
const BluetoothUuid& aAppUuid)
{
BT_API2_LOGR("Client Registered, clientIf = %d", aClientIf);
MOZ_ASSERT(NS_IsMainThread());
nsString uuid;
UuidToString(aAppUuid, uuid);
size_t index = sClients->IndexOf(uuid, 0 /* Start */, UuidComparator());
NS_ENSURE_TRUE_VOID(index != sClients->NoIndex);
nsRefPtr<BluetoothGattClient> client = sClients->ElementAt(index);
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE_VOID(bs);
if (aStatus) { // operation failed
BT_API2_LOGR(
"RegisterClient failed, clientIf = %d, status = %d, appUuid = %s",
aClientIf, aStatus, NS_ConvertUTF16toUTF8(uuid).get());
// Notify BluetoothGatt for client disconnected
BluetoothSignal signal(
NS_LITERAL_STRING(GATT_CONNECTION_STATE_CHANGED_ID),
uuid, BluetoothValue(false)); // Disconnected
bs->DistributeSignal(signal);
// Reject the connect request
if (client->mConnectRunnable) {
NS_NAMED_LITERAL_STRING(errorStr,
"Connect failed due to registration failed");
DispatchBluetoothReply(client->mConnectRunnable,
BluetoothValue(),
errorStr);
client->mConnectRunnable = nullptr;
}
sClients->RemoveElement(client);
return;
}
client->mClientIf = aClientIf;
// Notify BluetoothGatt to update the clientIf
BluetoothSignal signal(
NS_LITERAL_STRING("ClientRegistered"),
uuid, BluetoothValue(uint32_t(aClientIf)));
bs->DistributeSignal(signal);
// Client just registered, proceed remaining connect request.
if (client->mConnectRunnable) {
sBluetoothGattClientInterface->Connect(
aClientIf, client->mDeviceAddr, true /* direct connect */,
new ConnectResultHandler(client));
}
}
示例2: OnError
void OnError(BluetoothStatus aStatus) override
{
BT_WARNING("BluetoothGattClientInterface::RegisterClient failed: %d",
(int)aStatus);
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE_VOID(bs);
// Notify BluetoothGatt for client disconnected
BluetoothSignal signal(
NS_LITERAL_STRING(GATT_CONNECTION_STATE_CHANGED_ID),
mClient->mAppUuid,
BluetoothValue(false)); // Disconnected
bs->DistributeSignal(signal);
// Reject the connect request
if (mClient->mConnectRunnable) {
NS_NAMED_LITERAL_STRING(errorStr, "Register GATT client failed");
DispatchBluetoothReply(mClient->mConnectRunnable,
BluetoothValue(),
errorStr);
mClient->mConnectRunnable = nullptr;
}
sClients->RemoveElement(mClient);
}
示例3: Run
NS_IMETHOD
Run()
{
MOZ_ASSERT(NS_IsMainThread());
BluetoothService* bs = BluetoothService::Get();
bs->DistributeSignal(mSignal);
return NS_OK;
}
示例4: Run
NS_IMETHOD
Run()
{
MOZ_ASSERT(NS_IsMainThread());
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE(bs, NS_ERROR_FAILURE);
bs->DistributeSignal(mSignal);
return NS_OK;
}
示例5: Run
nsresult Run()
{
MOZ_ASSERT(NS_IsMainThread());
BluetoothSignal signal(NS_LITERAL_STRING(REQUEST_MEDIA_PLAYSTATUS_ID),
NS_LITERAL_STRING(KEY_ADAPTER),
InfallibleTArray<BluetoothNamedValue>());
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE(bs, NS_ERROR_FAILURE);
bs->DistributeSignal(signal);
return NS_OK;
}
示例6: nsString
void
DispatchStatusChangedEvent(const nsAString& aType,
const nsAString& aAddress,
bool aStatus)
{
MOZ_ASSERT(NS_IsMainThread());
InfallibleTArray<BluetoothNamedValue> data;
BT_APPEND_NAMED_VALUE(data, "address", nsString(aAddress));
BT_APPEND_NAMED_VALUE(data, "status", aStatus);
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE_VOID(bs);
bs->DistributeSignal(aType, NS_LITERAL_STRING(KEY_ADAPTER), data);
}
示例7: signal
void
DispatchStatusChangedEvent(const nsAString& aType,
const nsAString& aAddress,
bool aStatus)
{
MOZ_ASSERT(NS_IsMainThread());
InfallibleTArray<BluetoothNamedValue> data;
data.AppendElement(
BluetoothNamedValue(NS_LITERAL_STRING("address"), nsString(aAddress)));
data.AppendElement(
BluetoothNamedValue(NS_LITERAL_STRING("status"), aStatus));
BluetoothSignal signal(nsString(aType), NS_LITERAL_STRING(KEY_ADAPTER), data);
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE_VOID(bs);
bs->DistributeSignal(signal);
}
示例8: UnregisterClient
void UnregisterClient() override
{
MOZ_ASSERT(mClient->mUnregisterClientRunnable);
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE_VOID(bs);
// Notify BluetoothGatt to clear the clientIf
BluetoothSignal signal(
NS_LITERAL_STRING("ClientUnregistered"),
mClient->mAppUuid,
BluetoothValue(true));
bs->DistributeSignal(signal);
// Resolve the unregister request
DispatchBluetoothReply(mClient->mUnregisterClientRunnable,
BluetoothValue(true),
EmptyString());
mClient->mUnregisterClientRunnable = nullptr;
sClients->RemoveElement(mClient);
}
示例9: void
void
BluetoothServiceBluedroid::AdapterStateChangedNotification(bool aState)
{
MOZ_ASSERT(NS_IsMainThread());
BT_LOGR("BT_STATE: %d", aState);
sAdapterEnabled = aState;
if (!sAdapterEnabled) {
static void (* const sDeinitManager[])(BluetoothProfileResultHandler*) = {
BluetoothHfpManager::DeinitHfpInterface,
BluetoothA2dpManager::DeinitA2dpInterface,
BluetoothGattManager::DeinitGattInterface
};
// Return error if BluetoothService is unavailable
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE_VOID(bs);
// Cleanup static adapter properties and notify adapter.
sAdapterBdAddress.Truncate();
sAdapterBdName.Truncate();
InfallibleTArray<BluetoothNamedValue> props;
BT_APPEND_NAMED_VALUE(props, "Name", sAdapterBdName);
BT_APPEND_NAMED_VALUE(props, "Address", sAdapterBdAddress);
if (sAdapterDiscoverable) {
sAdapterDiscoverable = false;
BT_APPEND_NAMED_VALUE(props, "Discoverable", false);
}
if (sAdapterDiscovering) {
sAdapterDiscovering = false;
BT_APPEND_NAMED_VALUE(props, "Discovering", false);
}
bs->DistributeSignal(NS_LITERAL_STRING("PropertyChanged"),
NS_LITERAL_STRING(KEY_ADAPTER),
BluetoothValue(props));
// Cleanup bluetooth interfaces after BT state becomes BT_STATE_OFF.
nsRefPtr<ProfileDeinitResultHandler> res =
new ProfileDeinitResultHandler(MOZ_ARRAY_LENGTH(sDeinitManager));
for (size_t i = 0; i < MOZ_ARRAY_LENGTH(sDeinitManager); ++i) {
sDeinitManager[i](res);
}
}
BluetoothService::AcknowledgeToggleBt(sAdapterEnabled);
if (sAdapterEnabled) {
// Bluetooth just enabled, clear profile controllers and runnable arrays.
sControllerArray.Clear();
sChangeDiscoveryRunnableArray.Clear();
sSetPropertyRunnableArray.Clear();
sGetDeviceRunnableArray.Clear();
sFetchUuidsRunnableArray.Clear();
sBondingRunnableArray.Clear();
sUnbondingRunnableArray.Clear();
sPairingNameTable.Clear();
// Bluetooth scan mode is SCAN_MODE_CONNECTABLE by default, i.e., it should
// be connectable and non-discoverable.
NS_ENSURE_TRUE_VOID(sBtInterface);
sBtInterface->SetAdapterProperty(
BluetoothNamedValue(NS_ConvertUTF8toUTF16("Discoverable"), false),
new SetAdapterPropertyDiscoverableResultHandler());
// Trigger BluetoothOppManager to listen
BluetoothOppManager* opp = BluetoothOppManager::Get();
if (!opp || !opp->Listen()) {
BT_LOGR("Fail to start BluetoothOppManager listening");
}
}
// Resolve promise if existed
if (!sChangeAdapterStateRunnableArray.IsEmpty()) {
DispatchReplySuccess(sChangeAdapterStateRunnableArray[0]);
sChangeAdapterStateRunnableArray.RemoveElementAt(0);
}
}