I have a xamarin.MAC application built using Xamarin.MAC. Now I need to find a way to get the connected Wifi SSID in MAC application. I see lot of solution for xamarin.ios.But couldn't see the solution for MAC Application. Do any one know how can I detect SSID in the Xamarin.MAC application?
Thanks in Advance
Roshil
Use the CoreWLan framework, something like this will get you started:
var client = CWWiFiClient.SharedWiFiClient;
foreach (var #interface in client.Interfaces) // you can have multiple wifi devices connected at once
{
if (#interface.DeviceAttached)
{
Console.WriteLine(#interface.Ssid);
}
}
re: https://developer.apple.com/documentation/corewlan/cwwificlient
Related
I'm trying to develop winform(C#) application to search file from connected portable device(mobile device) using MTP.
I can get connected or disconnected status from wndproc method using WM_DEVICECHANGE.
But what I really want to develop is to cause an event when internal storage is created (it is able to read on window) after the deivce is connected from MTP.
So I was trying to create wndProc and input the code below in this code "if (m.Msg == UsbAlert.WM_DEVICECHANGE){ ... }"
if (devType == UsbAlert.DBT_DEVTUP_VOLUME)
{
Console.WriteLine("DBT DEVTUP VOLUME");
DEV_BROADCAST_VOLUME vol;
vol = (DEV_BROADCAST_VOLUME)Marshal.PtrToStructure(m.LParam, typeof(DEV_BROADCAST_VOLUME));
Console.WriteLine(vol.dbcv_unitmask);
}
But it is only can operate portable device such as USB not a mobile phone (android, ios)
There are so many codes for connecting device to windows but not for mobile phone.
Please let me know how can set an event when internal storage is ready to scan on windows.
Can I use WndProc function to develop this or not.
Thank you.
I just solved by myself not using the WM_DEVTUP_VOLUME using wnd_proc fuctions.
This article make me solved the problem below.
How to get MTP device Available Storage & Storage Capacity using C#?
You can get storage voulme using WPD lib from windows.
I'm using code similar to what is specified at WifiDirectSample to connect devices over Wifi Direct using legacy mode.
Connection/Disconnection works fine. However I want to show the name of the device being connected i.e. MyComputer or SamsungS20, something like that and detect if the device being connected is either of Windows or android or iOS type.
So far I have somehow managed to get the name of the device using the machine name as below
var EndpointPairs = wfdDevice.GetConnectionEndpointPairs();
EndpointPair connectionEndPointPair = EndpointPairs[0];
HostName remoteHostName = connectionEndPointPair.RemoteHostName;
IPHostEntry iPHostEntry = Dns.GetHostEntry(remoteHostName.ToString());
string machineName = iPHostEntry.HostName;
Which gives name of the device in case of Windows something like MyComputer.local and incase of android somthing like SamsungS20.mshome.net !?
is there some method/API or anything which can acomplish this?
Edit:
The application being developed of WinUI App.
Is there any way to know the game is running in an emulator application or a real device ?
Some Applications like VirtualXposed are virtual emulator for android devices. Such Applications allow users to install a game / application multiple times on their device with different identifies.
I want to know is there any way to recognize my game / application is running in emulator or a physical device in unity3d ?
something like :
if(isemulator)
{
dosomething();
}
It's not easy to do since there are many emulators out there. The answer from this post says that you can use Build.FINGERPRINT.contains("generic") to do that.
You can port the Java code to C# in Unity with the AndroidJavaClass class and without building Java plugin. Below is the ported version in C#:
public bool IsEmulator()
{
AndroidJavaClass osBuild;
osBuild = new AndroidJavaClass("android.os.Build");
string fingerPrint = osBuild.GetStatic<string>("FINGERPRINT");
return fingerPrint.Contains("generic");
}
To make sure that this covers most emulator, use the android-emulator-detector plugin. This plugin seems to be rigorously tested and detects most emulators. You can use AndroidJavaClass to communicate with it and UnityPlayer.UnitySendMessage to make callback into your Unity code in C#.
Maybe you can look for some emulator specific SystemInfos (Unity Docs SystemInfo) eg. SystemInfo.deviceModel
I have created a simple C# .NET framework console application.
In it, I am trying to get a list of paired bluetooth devices currently connected to the computer. However, I cannot figure out, how to access any bluetooth services from within the code.
I looked around the internet, and all I could find was a way to do this in an universal windows project (UWP), where I can simply use the using Windows.Devices.Bluetooth namespace which contains everything I would need, however in the .NET framework console application, this namespace is not available.
I don't need any advanced way to work with the bluetooth, all I need is a list of currently connected and paired bluetooth devices.
Try using below code :
BluetoothClient client = new BluetoothClient();
List<string> items = new List<string>();
BluetoothDeviceInfo[] devices = client.DiscoverDevicesInRange();
foreach (BluetoothDeviceInfo d in devices)
{
items.Add(d.DeviceName);
}
You will get the reference of BluetoothClient by installing 32feet.NET through Package Manager Console.
PM> Install-Package 32feet.NET -Version 3.5.0
After Installation you will get InTheHand.Net.Personal dll in the References
and then add the namespace using InTheHand.Net.Sockets; in your code
Now you will be able to access BluetoothClient
Hope this helps!!
I'm trying to get a serial communication over USB between an Arduino Nano and the Raspberry Pi 3. On the Raspberry is Windows IoT installed with a Background App that should read the incomming data.
My problem is that i can't find the connected Arduino. I wrote a simple app to iterate through all devices but i don't get a DeviceInformation for the connected Arduino.
public sealed class StartupTask : IBackgroundTask
{
public void Run(IBackgroundTaskInstance taskInstance)
{
while (true)
{
var devices = DeviceInformation.FindAllAsync(SerialDevice.GetDeviceSelector()).AsTask();
devices.Wait();
foreach (var dev in devices.Result)
{
Debug.WriteLine(dev.Name);
}
}
}
}
Has anyone an idea what is wrong? Maybe i have to install drivers manually?
Note: I can also find no device in the webinterface
List of connected Device on Webinterface
Thanks in advance.
EDIT:
I found out that the Name is always the same, so i changed it to print the ID.
I inserted the DeviceCapability Node and now i getting a bunch of informations. I'll guess the Id's starting with USB are interessting. But i'm getting always the same, regardles if the arduino is pluged in or not.
Here is one Example: \?\USB#VID_0424&PID_EC00#5&3753427a&0&1#{ad498944-762f-11d0-8dcb-00c04fc3358c}{2697A3B2-2715-443C-8A9F-B050D699B775}
Current OS Version: 10.0.14393.448
Arduino Nano use FTDI USB-To-Serial chip FT232RL to communicate with Host PC, and in your case Raspberry Pi with Windows IoT Core.
My experience with FT232RL chip on windows IoT is it's native supported with some latest versions(probably 10.0.10586 and above), so first make sure you have OS version above that. And use "devcon status xxxxxxx" command to verify the device driver is working properly.
If you're not sure what the device id looks like, plug the arduino nano into PC, and in the device property, check on the Hardware Ids. For example, mine shows
Second, check if you have the com port communication capability declared in your project manifest file, it should be something like below,
<DeviceCapability Name="serialcommunication">
<Device Id="any">
<Function Type="name:serialPort" />
</Device>
</DeviceCapability>
Last, make sure the USB port of your RP3 has enough power supply for Arduino nano, I don't think it should be a problem, but better have that checked as well.
Maybe you can try installing the Arduino IDE on the Windows installation, as it includes the Arduino USB drivers: