Bluez profile and device connect callback - bluetooth-lowenergy

I am developing custom profile with GATT service server (acting as peripheral). I define profile via structure btd_profile, and there are function pointers to adapter_probe, device_probe, connect ...
When bluez deamon started adapter_probe is called and there I create GATT service.
After I connect to server via gatttool I see my services and characteristics, but device_probe function is not called. How can I then get nofication about device connection/disconnection, when some device is connected/disconnected to my server? And how works this device_probe and connect callback functions? When are they called then?
Thanks for help

While registering profile if we pass Role as "server" then only server related function will be called i.e adapter_probe etc. if we pass Role as "client" then device_probe will be called.
By default bluez enables both the thing but if you pass role as "server" or "client" then it will change accordingly. While registering profile pass role as NULL then both will be enabled

Related

SignalR connected client in Clients.User(..) shouldn't exist

In my SignalR hub, I use the following method to check whether a user has an active connection:
var receivingClient = Clients.User(receiver);
if (receivingClient != null)
{
But I also track the online users manually over OnConnected \ OnDisconnected (in a ConcurrentDictionary). Now even when I shut down everything and start the server from scratch (e.g. IISExpress from VS), the above code part returns a result for a connection that doesn't exist.
Let's say I send from User A to user B. I start the server, go online with user A, then send a message to B: The above code returns a Microsoft.AspNetCore.SignalR.Internal.UserProxy<mySite.Services.ChatHub>.
I don't get it. Is it wrong to check for existing client connections with a null check? Should I exclusively rely on my manual tracking?
Thanks for some insight!
(PS: This is all on the same server - no load balancing / sharding)
Clients.User(receiver) returns a type that is used to invoke methods for the given user. It doesn't have anything to do with whether the user you pass in exists or not.
Is it wrong to check for existing client connections with a null check? Should I exclusively rely on my manual tracking?
Yes. Use manual tracking.

Azure Notification Hub device registration

Since AppCenter retiring at the end of this year, I have started migrating to Azure-Notification-Hub.
But the documentation for notification-hub is not clear at all. Especially the documentation for Xamarin.Android. It does not match with their latest SDK.
In the latest (version 1.1.1) azure-notification-hub SDK for Android (or Xamarin.Android) there's no need to implement FirebaseMessagingService. NotificationHub.Start() method registers the device in the Notification-Hub. A device registered with this way gets notifications without any problem.
NotificationHub.Start(Application, <HubName>, <ConnectionString>);
Addition tags to existing NotificationHub instance are also straightforward with the new SDK.
NotificationHub.AddTag("username:user123");
But in Registration Management official doc states that devices can register with the notification-hub either from client-side or from server-side. Is it necessary to use one of those methods if my app registered with the notification-hub using the NotificationHub.Start() method? Or do I missing something?
Also, when I was using the AppCenter, I have used the AppCenter-InstallId to target a specific device.
With that in mind is it possible to use the NotificationHub.InstallationId to use as a tag (eg: "handle:<devce's InstallationId>") to send device-specific notifications?
Is it necessary to use one of those methods if my app registered with the notification-hub using the NotificationHub.Start() method?
When you invoke NotificationHub.start(Application, ...), the Android SDK will listen for changes like added tags, new FirebaseMessagingService tokens, etc. Anytime it detects a change, it will invoke an InstallationAdapter to inform a backend of the new details.
The default InstallationAdapter will send an PUT request to the Azure Notification Hubs backend as documented here. This is what is created by NotificationHub.start(Application, string, string); for people who are not hosting their own backend, this is a sensible default.
If you have your own backend where you track devices, or you're just looking to keep your credentials server-side, you can swap out the InstallationAdapter to be a class that invokes your API. All you need to do is implement the InstallationAdapter interface and initialize the SDK by calling NotificationHub.start(Application, InstallationAdapter).
If you use the NotificationHub.start(...) methods as indicated above, there is no further registration action required.
With that in mind is it possible to use the NotificationHub.InstallationId to use as a tag (eg: "handle:<devce's InstallationId>") to send device-specific notifications?
Yes! This documentation walks you through how to use the special tag format $InstallationId:{YOUR_TAG_ID} to target a specific device.
When you've used NotificationHub.start(), if you do not specify an InstallationId, it will generate one for you.
Question about setting the InstallationId and/or UserId. If I'm using Microsoft.Azure.NotificationHubs.Client, which makes more sense to do.
Should I set the InstallationId via the $InstallationId Tag (see here: https://learn.microsoft.com/en-us/azure/notification-hubs/notification-hubs-push-notification-registration-management#installations) or via implementing the InstallationEnrichmentAdapter and set it via a call to installation.InstallationId = in the EnrichInstallation method?
Additionally, the Microsoft.Azure.NotificationHubs.Client.Installation class provides a UserId property that can be updated too.
I'm also moving my push notifications from AppCenter to Azure Notification Hub and want to reuse my existing AppCenter InstallId.
i am able to add tags and userid as below(java)
NotificationHub.start(this.getApplication(), BuildConfig.hubName, BuildConfig.hubListenConnectionString);
NotificationHub.setInstallationId("123");
Set<String> tags = new HashSet<>();
tags.add("role_memeber");
NotificationHub.setUserId("123");
NotificationHub.addTags(tags);
sdk: com.microsoft.azure:notification-hubs-android-sdk:1.1.6

Corda - Get State Machine Feed from ServiceHub

CordaRPCOps provides a mechanism to access the state machine feed
ops.stateMachinesFeed().updates.subscribe {
...
}
I want to be able to access the state machine feed from a Corda service. Is there an equivalent to this using ServiceHub or AppServiceHub?
You can't do it at the moment. It requires accessing an instance of StateMachineManager and there is not a way to wire that into a service.

NotificationHub Push Notification returns : The Token obtained from the Token Provider is wrong

I have Wp8.1 Silverlight app that receives push notification (WNS) from Mobileservice (the old azure service).
I therefore wanted to update to the new service because of the new features. I have now created/upgraded a new server to use App Service - Mobile App. And tested push notification with the sample app from azure (everything works).
Going back to my app WP8.1 -> Adding the new package Microsoft.Azure.Mobile.Client through NuGet (2.0.1), there is the issue that the Microsoft.WindowsAzure.Mobile.Ext does not contain the 'GetPush' extension. It seems like it is missing it? looking to the WP8 version, it only registers to MPNS, and I need WNS. So I do not know if any other assembly could be used.
Can I add another assembly reference?
Update
The following code lets me register the device on the server, and I can see the device register correctly. where the channelUri and the installationInformation are retrieved by the client and send to the server.
Installation ins = new Installation();
ins.Platform = NotificationPlatform.Wns;
ins.PushChannel = uTagAndChan.ChannelUri;
ins.Tags = uTagAndChan.Tags;
ins.InstallationId = uTagAndChan.installationInformation;
await hubClient.CreateOrUpdateInstallationAsync(ins);
Sending a test toast-notification to the registered tags, results in the following error :
The Token obtained from the Token Provider is wrong
Searching on this issue I found Windows Store App Push Notifications via Azure Service Bus. Which the proposed solution says to register to the notification hub directly from the app, I would rather not have the app to have directly access to the hub. But is this the only way? (mind you the answer was not accepted, but I will try it all though it is not a desired solution)
Update
Registering for notifications via client (WP8.1 Silverligt), makes a registration to MPNS, which I do not want.
The snippet on the server registers a WNS, the two registrations can be seen here:
The URI retrieval is done using
var channel = await Windows.Networking.PushNotifications.PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
which in the description states it returns a WNS. This seems to infer that the registration I am doing on the server (code snippet in the top) is correct and the registration on the client is faulty.
But the registration on the image seems wrong. Shouldn't the PNS Identifier be different for the two registrations? also expiration date seems wrong ?
How to mend this since the GetPush() (which was available in the sample registered the client correctly for notifications) does not exist in the NuGet package?
Update
I read one place that deleting and recreating the NotificationHub could help. I will try this today. Even IF it works, it would be more desirable to have the solution, and to know if the registrations are done correctly?
Temporary solution:
Deltede, recreated, inserted Package SID and Secret. And it works again (strange)!
Still interested in the underlying issue!
Deleted and recreated the service, setting all the same settings made it work again.
I had same issue with my UWP. But in my case I had issue with self signed certificate.
When I set the AppxPackageSigningEnabled property to True (in .csproj) then notifications stopped working and I got "The token obtained from the Token Provider is wrong" (Test send from Azure Portal).
The certificate must have same issuer as Publisher in Identity element in .appxmanifest file.

Is there a way to update the ESB ALL.Exceptions send port to use the WCF.SQL adapter?

The ESB Toolkit 2.1 has the ALL.Exceptions send port using the old SQL adapter.
But the BizTalk Health Monitor reports ...
Non WCF SQL adapter used in some Send Ports
Prefer to use the WCF one which is more performant !
Is there any way to update to the WCF.SQL adapter?
Yes this is possible. It will however include some custom development.
You will need to create a map between the FaultMessage schema (in Microsoft.Practices.ESB.ExceptionHandling.Schemas.Reporting.dll) and the usp_insert_Fault schema (created using the Consume Adapter Service in Visual Studio, from the usp_insert_Fault SP in the EsbExceptionDb database), as the old SQL Adapter uses a different schema layout to execute a stored procedure.
Required Steps:
Change the Transport Type of the ALL.Exceptions port to WCF-SQL
Set the Address: mssql://SQLServer:1433/SQLInstance/EsbExceptionDb?
Set the Action: TypedProcedure/dbo/usp_insert_Fault
Change the ESBFaultProcessor Send Pipeline to use your custom map in the ESB Transform Component
EDIT: Note: The solution described here does not include the Message and its Context like the map with the SQL Adapter does. To accomplish this, you should make use of Composite Operation to insert into multiple tables in one transaction.

Resources