Receive telmetry from IoT hub on Android with Xamarin Forms - c#

I have a Xamarin.Forms shared project created for Android 7.0 and UWP.
What I am attempting to do is receive information from an IoT hub on Azure.
I have previously been able to receive telemetry to a console application by following this tutorial
https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-csharp-csharp-getstarted
I was using Microsoft.ServiceBus.Messaging library
Is this not supported on Android? and if so, is there a way to receive messages on an android device from an IoT hub using Xamarin?

You might want to use the newer library for event Hub monitoring: https://github.com/azure/azure-event-hubs-dotnet
This new lib is .Net Standard 1.3 compatible and should work on Xamarin.Android.
We need to update the Azure IoT Hub docs to point to this new lib instead of the older Microsoft.ServiceBus.Messaging one. I'll make sure it's added to our backlog.

Related

How to use Iot.Device.Bindings nuget package on Windows uwp app?

I have Windows UWP foreground app running on my raspberry (windows 10 iot core). I want to use Iot.Device.Bindings nuget package to capture data from various sensors (e.g. bme680). But looks like this package is unsupported on UWP:
NU1202: Package Iot.Device.Bindings 1.2.0 is not compatible with uap10.0.17763 (UAP,Version=v10.0.17763). Package Iot.Device.Bindings 1.2.0 supports:
- net5.0 (.NETCoreApp,Version=v5.0)
I tried to create backroung job for iot core, but same error.
Can someone suggest approch how to achive that?
Thanks in advance!
Yes, the Iot.Device.Bindings package does not support UWP on Windows IoT Core but works for .net core. Since the library uses APIs in namespace System.Decive.. For UWP app, you need to use APIs in namespace Windows.Device.. At the moment, I can not find a package which is implemented for various sensors. Here are two suggestion for that:
Create a .net core app which uses the Iot.Device.Bindings nuget package, and build a channel to send the data from .net core app to your UWP app, such as tcp, or web API.
Imeplement the library for UWP by referring the source code.

Uno platform: MapControl in not UWP projects

I have a quite big project developed in UWP, and I'm thinking of migrate to Uno Platform with Android, iOS and MacOS users in mind. The biggest and most important part of the project is a MapControl, but I don't know if when migrating the project, in Android, and other OS, the app will continue using BingMaps (with all the tools and things that brings) or will use OS default map provider and engine.
Will be possible to achieve something like that with Uno on other OS that is not Windows?
Direct support for Uno to use the UWP map control isn't available yet, but there are Native Android and iOS versions of the Bing maps SDK available which may be able to be called from Uno.
Here's the SDK getting started page: https://www.microsoft.com/en-us/maps/mobile

How to call UWP function from ASP.NET Core 2.1 in Windows 10 IoT Core for Raspberry PI 3

I need to call a UWP function that can talk with USB Serial Port from a WebAPI in ASP.NET Core 2.1 but at compile time Visual Studio 2017 get the following error.
Error NU1201 Project SerialPort is not compatible with netcoreapp2.1 (.NETCoreApp,Version=v2.1). Project SerialPort supports: uap10.0.17134 (UAP,Version=v10.0.17134)
WebAPI project and UWP project are working well on Raspberry PI3 with Windows 10 IoT as a separate projects. My need is to use UWP and ASP together but seams that is not possible. Asp.NET Core 2.1 seams doesn't support UWP classes for serial port communication and UWP seams not supporting ASP.NET WebAPI integration. How the two worlds can cooperate?
Tanks
AFAIK, it is not possible to add the reference for the UWP project from .Net core project at present. It may support when the .Net core 3, you can refer .NET Core 3 and Support for Windows Desktop Applications about mote detail.
Based on the description, it seems that you want public the hardware info via the web API. If I understood correctly, you may consider developing a web server by yourself and implement the business logic. You can refer the thread below about how to implement a web server in the background app:
Building a Windows 10 IoT Core background webserver
I am having a similar problem. I think the easiest way might be to reverse the logic. UWP reaches out to WebAPI, rather than WebAPI reaching out to UWP. The WebAPI stores the data, the UWP app gets the data via an http client, and in my case to manage state, the UWP app will store the most recent copy of a JSON file from the API to preserve state in case of power failure. If the power comes back on, it will read the most recent file stored locally prior to reaching out to the API for new data.

Serial port on Raspberry Pi 3 with .Net Core

I am trying to use the onboard UART on a Raspberry Pi 3 on Windows 10 IoT with .Net Core 2.0.
I referenced the System.IO.Ports (4.5.0-preview1-25914-04) NuGet package in a .NET Core 2.0 Console app but the System.IO.Ports.SerialPort.GetPortNames() function gives me only a strange name (ďżżďżżăŞč˝¨ě¬č»­ 㤀腞ă¨č˝¨ĺ«č…łéŞ€čş„ 㨸轨ç»č…łă¨ č˝¨ęŞ­č…‡ ě¬č»­ 쬨軭ě‡č…˘ă¨¸č˝¨ŕ«č…Źă¨‚é„» ᬀ腞 㨂鄻 㨂鄻 ă©č˝¨ëŞ­č…Śă©¨č˝¨ëŻ»č…Ś ď•âź¸ě€¤ 㫀轨靻腊 ăŞč˝¨ă­č…žĺ€€ăĽˇ ŕ§ŕ¦śŕ¦śŕ¦€ŕ¦śŕ¦€ က鄮 " 뀴鋾■&ă¬č˝¨ç–鋾က鄮) that I cannot use.
If I plug in an USB serial converter I get an other port but its name is empty.
The Desktop version works perfectly.
I can use the serial port in a UWP app.
Is there anybody how can use Serial port from .NET Core 2.0 on RPi3?
System.IO.Ports does not support Windows IoT Core. On Windows IoT you have to use Windows.Devices.SerialCommunication namespace to access serial ports. But it is available only in UWP context however not in .Net Core because of Windows OS policy. About this question, there have been several same discusses in StackOverflow and MSDN. But it is very frustrating that there is no any solution about this issue.

GRPC C# Library For a Windows 8.1 Phone App

Is it possible to use GRPC C# library with a Windows Phone App? When I try to install GRPC through NuGet I receive the following error:
Error Could not install package 'Grpc.Core 1.0.0'. You are trying to install this package into a project that targets 'WindowsPhoneApp,Version=v8.1', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. 0
Has anyone had any luck installing GRPC C# library for a windows phone app?
As of now, Windows Phone Apps are not supported by gRPC C#. Technically, supporting them would be possible but we are not sure it's worth the work at this point - we have different priorities (User experience, performance and supporting other platforms).
Here's a github issue that tracks the discussion: https://github.com/grpc/grpc/issues/7859

Categories