I am trying to access the GPIO on my custom SBC using Windows 10 IoT Core. I have discovered that I must use LightningProviders to accomplish this . So I tried to follow this guide to use lightning providers properly.
I used very simple code:
if (LightningProvider.IsLightningEnabled)
{
LowLevelDevicesController.DefaultProvider = LightningProvider.GetAggregateProvider();
}
GpioStatus = "Initializing...";
var gpio = GpioController.GetDefault();
if (gpio == null)
{
GpioStatus = "There is no GPIO controller on this device.";
}
else
{
gpio.OpenPin(1).Write(GpioPinValue.High);
GpioStatus = gpio.OpenPin(1).Read().ToString();
}
Where GpioStatus is output text on a UI.
I discovered that if I run the LowLevelDevicesController.DefaultProvider = LightningProvider.GetAggregateProvider(); line outside of the enabled check, it picks up the GPIO controller and lets me detect how many pins I have and read them (All low). However I can't change the DriveMode or write to the pins without error. The error I get just says to Make sure the LightningProviders are enabled.
This brings me back to the guide I linked at the start. It suggests to enable DMAP drivers using the Device Portal for W10IoT or DMAPUtil.exe. I have tried both. In the Device Portal the area where it should be is just blank. And in the command line trying to use the DMAPUtil.exe only returns that dmaputil.exe is not available on this system.
Therefore I am asking if there is any other way to enable the LightningProviders or if there a way to know if they are incompatible with my board?
Thanks!
UPDATE
Also tried using the devcon.exe commands in the W10IoT Command line.
I am able to locate the Direct memory access controller but when i do devcon.exe enable *PNP0200 it says it is enabled but remains disabled when checked with devcon.exe status *PNP0200
Please confirm if you have added the IOT_DMAP_DRIVER feature in your OEMInput.xml, this feature will add the DMAP driver in the image. If IOT_DMAP_DRIVER is removed from the OEMInput.xml, the Default Driver Controller will be blank in device protal, and dmaputil will be not available on Windows IoT Core. Please see the IoT Core feature list.
Update:
You can download the source of Lighting Provider, and then deploy and debug in your custom image.
Related
I am trying to add User & Device context to the SentrySdk using c# and but that information never shows in the sentry portal.
here is the code
SentrySdk.ConfigureScope(scope =>
{
scope.SetTag("SStGAppAId", sstgAppId);
scope.User = new User
{
Id = sstgAppId
};
scope.Contexts.Device.Model= DeviceInfo.Model;
scope.Contexts.Device.Manufacturer = DeviceInfo.Manufacturer;
scope.Contexts.Device.Name = DeviceInfo.Name;
scope.Contexts.Device.Simulator = DeviceInfo.DeviceType != DeviceType.Physical;
});
this what sentry shows
What is not being done for the context information to be sent to sentry?
We solved "Global Mode" on version 3.8.1.
It makes it so that any call to SentrySdk.SetTag or AddBreadcrumb or anything else that you do through SentrySdk.ConfigureScope mutates a single, static Scope object that affects all threads of the app. This is useful for Desktop and Mobile apps when you have a single user session and you add context to Sentry anywhere in the app and want that to be included if it crashes in any other thread.
You can opt-in to this mode through:
options.IsGlobalModeEnabled = true
This option will be set by default on Sentry.Xamarin and Sentry.Xamarin.Forms which you could be using to get extra device information and breadcrumbs for system events.
It's a bug in the SDK, a AsyncLocal issue. For now to bypass it you can call SentrySdk.ConfigureScope every time before logging.
Edit
I found out, that the requirements for showing a notification consist of setting a content-title, a context-text and a small icon. The last of which I do not do. Unfortunately, I don't know, how to provide a small icon especially in unity.
Original Question
I'm currently trying to show a notification from a unity-instance via android. I want to show the notification, when the user enters a specific gps-area. Thus, the script should run, when the app is paused. That's why I want to use the android-functionality.
With this code, I currently try to show the notification manually:
public void createNotification(){
NotificationManagerCompat nManager = NotificationManagerCompat.from(curContext);
NotificationCompat.Builder builder = new NotificationCompat.Builder(curContext, CHANNEL_ID)
.setContentTitle("Stuff")
.setContentText("MoreStuff")
.setPriority(NotificationCompat.PRIORITY_DEFAULT);
nManager.notify(1551, builder.build());
}
The context is stored in a static variable and is set, when calling the method.
The function is called in C# with:
PluginInstance.Call("createNotification");
The PluginInstance works, the function can be called, but I get the error:
AndroidJavaException: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/app/NotificationManagerCompat
I found the solution for my problem: I used the Unity Android Jar-Resolver in which I provided the *Dependencies.xml (Where the * presents the Name of my project). In the *Dependenices.xml I specified: <androidPackage spec="androidx.appcompat:appcompat:1.1.0"> and run through the steps, provided in the Tutorial of the Resolver.
Afterwards, multiple dependencies appeared in my /Assets/Plugin/Android-Folder, which were successfully transferred to the app, when building it.
I want to turn on or off airplane mode using AccessibilityService.
Any idea how we can do it?
Yes, you can't change it from app that target bigger than Android 4.2. But you can open the settings page instead if you want:
if (Android.OS.Build.VERSION.SdkInt < BuildVersionCodes.JellyBeanMr1)
{
try
{
Intent intentAirplaneMode = new Intent(Android.Provider.Settings.ActionAirplaneModeSettings);
intentAirplaneMode.SetFlags(ActivityFlags.NewTask);
Context.StartActivity(intentAirplaneMode);
}
catch (ActivityNotFoundException e)
{
Log.Error("exception", e + "");
}
}
else
{
Intent intent1 = new Intent("android.settings.WIRELESS_SETTINGS");
intent1.SetFlags(ActivityFlags.NewTask);
Context.StartActivity(intent1);
}
}
And AccessibilityService can used with dependency service.
Kamal you’re not going to be able to do it.
It doesn’t seem like you’re doing iOS, but iOS has a lot of limitations due to privacy and security purposes that won’t allow you to do this. You can see more details here stackoverflow.com/q/20469425/11104068
Also android blocked being able to do this from Android 4.2 onwards. Only system apps can make changes to Airplane mode, as you can see here stackoverflow.com/a/5533943/11104068
Since it doesn’t seem you’re creating a system app that gets installed with the operating system, and not through the Play Store, you won’t be able to get permissions. It will give you an error /exception even if you implement everything
I am using Lecia Disto e7100i which basically measures distance and area using laser. This device has bluetooth and can be paired with windows.
I am trying to develop an wpf app that reads the mesaured data using c#
There is no sdk that comes along with the device.
I have tried to use 32feet.Net but since there is no proper documentation I don't know where to start.
Is there any way that I can do to solve my problem?
This is not a full response, instead its more of a guideline on how to resolve your issue:
Pair the device with your Computer
Run the included software that displays the data somehow
Use WireShark to analyze the traffic
see if it is a standard protocol type or something custom
understand the protocol and reimplement it using c# and BluetoothSockets
To get started, you can try:
var client = new BluetoothClient();
// Select the bluetooth device
var dlg = new SelectBluetoothDeviceDialog();
DialogResult result = dlg.ShowDialog(this);
if (result != DialogResult.OK)
{
return;
}
BluetoothDeviceInfo device = dlg.SelectedDevice;
BluetoothAddress addr = device.DeviceAddress;
Console.WriteLine(device.DeviceName);
BluetoothSecurity.PairRequest(addr, "PIN"); // set the pin here or take user input
device.SetServiceState(BluetoothService.HumanInterfaceDevice, true);
Thread.Sleep(100); // Precautionary
if (device.InstalledServices.Length == 0)
{
// handle appropriately
}
client.Connect(addr, BluetoothService.HumanInterfaceDevice);
Also make sure that
Device appears in "Bluetooth devices" in the "Control panel".
Device is HID or change code accordingly.
Hope it helps. Cheers!
Try this demo project, and the following articles after that one.
Try to follow this tutorial
Here you can see a direct answer by the mantainer of 32feet, with which you can get in touch
Check also this answer
I have created a watcher to connect to BarcodeScanner using Windows.Devices.PointOfService
var watcher = DeviceInformation.CreateWatcher(BarcodeScanner.GetDeviceSelector());
var id = "";
watcher.Added += async (sender, information) =>
{
id = information.Id;
var barcodeScanner = await BarcodeScanner.FromIdAsync(id);
...
}
information parameter contains all data releted to my barcodeScanner, but when i try to get it with FromIdAsync is always null.
Those are data contained into information
- information {Windows.Devices.Enumeration.DeviceInformation} Windows.Devices.Enumeration.DeviceInformation
EnclosureLocation null Windows.Devices.Enumeration.EnclosureLocation
Id "\\\\?\\HID#VID_0536&PID_02E1&MI_01#c&d907bf5&0&0000#{c243ffbd-3afc-45e9-b3d3-2ba18bc7ebc5}\\POSBarcodeScanner" string
IsDefault false bool
IsEnabled true bool
Kind DeviceInterface Windows.Devices.Enumeration.DeviceInformationKind
Name "3800G" string
+ Pairing {Windows.Devices.Enumeration.DeviceInformationPairing} Windows.Devices.Enumeration.DeviceInformationPairing
+ Properties {System.__ComObject} System.Collections.Generic.IReadOnlyDictionary<string, object> {System.__ComObject}
+ Native View 0x1d148140 <Information not available, no symbols loaded for Windows.Devices.Enumeration.dll> IUnknown *
This device is listed as enabled to be accessed with POS.
Where I'm wrong? I have tried also to create the watcher behind a button click, but nothigs change.
If the model name of the scanner you are using is "3800G" as in the question code, it may not be supported by Windows.Devices.PointOfService.
A list of supported models is below.
Supported Point of Service Peripherals
If you want to use it with Windows.Devices.PointOfService, please change it to the model described in this.
In Addition:
Unified POS standard and Windows® Embedded for Point of Service are OPOS/POS for.NET/JavaPOS API. It is not Windows.Devices.PointOfService API.
That model is not listed on Honeywell's site.
And, sales agencies in Japan may be displayed as sales ended. Probably it is an old model. It is better to switch to a new model.
For example, the USB HID Bar code scanner mode setting is described on page 21 of the detailed manual of 1900 series.
If this mode setting description is not in the 3800G manual, you can not use Windows.Devices.PointOfService API on 3800G.
If you can set it, you will be able to use it if you install a device driver corresponding to this mode.
#Luigi Saggese,
You must first put this scanner into USB HID Barcode Scanner Mode. Please see Page 1-3 of the Honeywell 3800g Users Guide for the programming code to put the scanner into this mode.
Once the scanner is in this mode, you should see a POS Barcode Scanner node in Windows Device Manager. The specific scanner will show up in Device Manager as POS HID Barcode Scanner since it is using an in-box class driver which supports the USB HID POS Scanner protocol. At this point it should work with your Watcher.
Terry Warwick, Microsoft