I'm trying to develop a class library for use from Uno Platform applications that can be distributed as a NuGet package. In the code, I need to be able to extract various information about the device currently running the code. I already figured out how to get the screen dimensions but now I'm stuck in getting the current operating system and version. I have seen code like this:
#if __ANDROID__
os = "android";
#elif __IOS__
os = "ios";
#endif
But as I understand, this is not supported in class libraries. I have also experimented with the Uno port of Xamarin.Essentials to use the DeviceInfo class. I couldn't get this to work, though.
Any help would be appreciated.
I approach getting the OS info in a different manner. I grab the OS info using the following code:
public static string getOSVersion()
{
string osInfo = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily.ToString();
int dotPosition = osInfo.IndexOf('.');
string shortOsInfo = osInfo.Substring(0, dotPosition);
return shortOsInfo + " " + Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamilyVersion.ToString();
}
If you are on Android- it will return Android 11, on IOS it will return iOS 14.4(Keep in mind the version number will probably be different- just using it for example purposes). I have not run this on WASM, UWP, Linux, or MacOS- but it should work. Hopefully this will be helpful to you!
Related
I'm using the NuGet package Plugin.BluetoothLE v6.3.0.19 and I can scan for nearby devices but mostly the names are blank. A few devices show their names but most do not. I also cannot see the mac address of the device I'm looking for.
The scenario is that I know the device name but need to look up the mac for connecting.
As I check the devices I need to check the device.name to see if it matches the device I'm looking for. If found it will attempt to pair and connect.
I'm thinking this LE (Low Energy) version does not get the names from every device unless it broadcasts it. So maybe I need to request more info? If so I don't know how to do that with this plugin.
var adapter = CrossBleAdapter.Current;
adapter.ScanExtra(new ScanConfig { ScanType = BleScanType.Balanced });
var scanner = CrossBleAdapter.Current.Scan().Subscribe(scanResult =>
{
var x = scanResult.Device;
System.Diagnostics.Debug.Print($"{x.Name} - {x.Status} _ {x.ToString()}");
});
I am not very familiar with the BluetoothLE, but I found a course about the problem. I hope this can help you.
In addition, you can put the issue on this git. People who know the problem may help you.
I have a respberry server and a windows client, both implemented in Python. The server transmits a BLE signal like a iBeacon signal.
Here is the code of the server:
import time
from bluetooth.ble import BeaconService
service = BeaconService()
uuid = "11111111-2222-3333-4444-555555555555"
major = 2 # 1 - 65535
minor = 1 # 1 - 65535
txpower = 1
interval = 200
service.start_advertising(uuid, major, minor, txpower, interval)
try:
time.sleep(300)
service.stop_advertising()
except KeyboardInterrupt:
print("cancelled")
finally:
service.stop_advertising()
print("Done.")
This code is working fine. I checked by installing an android app and I could find the device with that information.
Now I need to get that information in the windows client. In the windows client I'm using bleak library.
I have the following code to scan for beacon devices:
import asyncio
from bleak import discover
async def run():
devices = await discover()
for d in devices:
#if d.address == "B8:27:EB:03:5A:D6":
print(d.address, d.name, d.metadata, d.rssi)
loop = asyncio.get_event_loop()
loop.run_until_complete(run())
The problem is when I check the console, I dont see the major, minor and UUID information:
There are showed other devices and I can see in one of them that the UUID is readable.
What I'm doing wrong here? Is bleak impossible to get the information I want? (minor, major) or am I transmitting in the wrong way? I dont think so because the mobile app is reading fine. Is there another library available to windows to get this information?
Thanks for the help. Have a good day.
Do not confuse the GATT Service UUID list returned by bleak with the iBeacon ProximityUUID you want. They are two totally different identifiers. The iBeacon ProximityUUID is encoded inside the manufacturer data returned by bleak. It will not parse it for you, but you could write a parser yourself. If you print out the manufacturer data bytes as hex you will see the pattern.
I wrote a Windows Beacon Library that does what you want. It is a port of the Android Beacon Library for Windows 10. But the documentation is sorely lacking. If you are stuck, I can help you use it, but it is designed to be used with Visual Studio languages not Python.
Using that library you can parse an iBeacon frame from BluetoothLEAdvertisementReceivedEventArgs in C# like this:
var beaconParser = new BeaconParser();
beaconParser.SetBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24");
Beacon beacon = beaconParser.FromAdvertisement(args.Advertisement, args.RawSignalStrengthInDBm, args.BluetoothAddress);
if (beacon != null)
{
OLogger.Debug("Found iBeacon: UUID=" + beacon.Id1 + " major=" + beacon.Id2 + " minor=" + beacon.Id3 + " rssi: " + beacon.Rssi);
}
Yesterday I got the update for Android 5.0 on my Nexus 4, and the altbeacon library stopped detecting beacons. It appears that didEnterRegion and didRangeBeaconsInRegion are not even getting called when monitoring and ranging, respectively.
Even the Locate app from Radius Networks behaves differently now, the values from beacons, once they are detected, doesn't get updated anymore and often it appears as if the beacons went out of range.
One thing I noted differently, is that now in the logcat it appears the following line "BluetoothLeScannerďą• could not find callback wrapper". I went ahead and looked for that class and saw that it was introduced with Android L, but I don't know if that has something to do with it.
It's important to say that before the update I had been working with both the Locate app and the Reference Application without any trouble.
I don't know if this is a generalized problem or not, but if it happened to me I'm sure it could happen to someone else, so any help it would really be appreciated.
Thanks in advance!
UPDATE:
After failing at getting the library to work I decided to try the Android L branch of the library. What I did was that I plugged in the new library into the Reference App, but didn't work as expected either.
The Monitor Activity seems to be working ok by notifying when the device has entered a new region. However, the Ranging Activity doesn't report any beacons, although didRangeBeaconsInRegion is getting called, always report zero beacons. Curiously, when the activity is paused (switching momentarily to another app) the logcat shows that now didRangeBeaconsInRegion does get called with actual beacons.
I'm kind of stuck right now because I don't know how to get any of libraries working on Android L, so again, any help would really be appreciated.
I'm using the latest Altbeacon build on 5.0+ and have no problem with it. in fact, I never used it on kitkat so i'm not really sure i can help but here is my working code which listen to iBeacons.
implement beaconConsumer:
public class MainActivity implements BeaconConsumer
init BeaconManager
beaconManager = BeaconManager.getInstanceForApplication(this);
if (beaconManager != null && !beaconManager.isBound(this)) {
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout("m:0-3=4c000215,i:4-19,i:20-21,i:22-23,p:24-24"));
beaconManager.bind(this);
}
onConnect and start listner
#Override
public void onBeaconServiceConnect() {
beaconManager.setRangeNotifier(new RangeNotifier() {
#Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
if (beacons.size() > 0) {
Beacon firstBeacon = beacons.iterator().next();
}
}
});
beaconManager.startRangingBeaconsInRegion(new Region("com.example.app", null, null, null));
}
this code is working on 3 devices
Nexus 4 5.0.1
Samsung Galaxy s4 - Stock 5.0.1
Samsung Galaxy s4 - CM12 5.1.1
Old question, but maybe some people will try to find answer for higher systems where you have to ask for permissions. You need to ask for Manifest.permission.ACCESS_FINE_LOCATION before scanning. At least that was the problem I met. In my opinion lib should crash such cases at least and indicate the problem
I am using latest qt version 4.7,where i developed an application on Audio Recording.
I need to set the path to memory card(ie,mass memory),I have seen links based on carbide link->How to run C++ applications in symbian
But could not find any solution for this latest version.
Can anyone help me out in finding this!!
This is what i tried.
I used two methods but i am clueless….
But the audio file gets stored in simulator ,,but not in desired memory card location!!!
AudioBuffer::AudioBuffer()
{
audioSource = new QAudioCaptureSource();
capture = new QMediaRecorder(audioSource);
QAudioEncoderSettings audioSettings;
audioSettings.setCodec("audio/vorbis");
audioSettings.setQuality(QtMultimediaKit::HighQuality);
capture->setEncodingSettings(audioSettings);
capture->setOutputLocation(QUrl::fromLocalFile("test.wav"));
FileName path = PathInfo::MemoryCardRootPath();
path.Append( PathInfo::SoundsPath() );
// QFile file;
// QDir::setCurrent("/tmp");
// file.setFileName("test.wav");
// QDir::setCurrent("/home");
// file.open(QIODevice::ReadOnly);
}
I am using Symbian platform(Qt-Quick)
Regards,
Harish.
I don't develop applications for symbian platforms but IMHO you have to convert TDesC path to a QString (see Converting a Descriptor to a QString for details).
Internal memory is hardcoded to "E:/" and SD card is hardcoded to "F:/" on symbian.
Do a :
QDir d;
d.setPath("f:/");
if (d.exists()) {
[...]
}
to check the availability of the external storage
I've created a fileUpload.mxml component in flex 3 which basically uploads m4a's to a designated server. The general code is below:
private var uploadURL:URLRequest;
private var file:FileReference;
file=new FileReference();
file.browse(getTypes());
var params:URLVariables = new URLVariables();
params.fileID = model.selectedFileUpload.fileUploadId.toString();
uploadURL.data = params;
uploadURL.url= model.mainDir + "/php/upload.php";
file.upload(uploadURL);
Everything works fine on a windows pc, but not on a mac pc. It stops at file.upload(uploadURL) (and thus doesn't trigger Event.COMPLETE).
Has anyone experienced this problem on the mac os x? And if so, how did you overcome it?
Any advice would be appreciate.
Regards,
Angus
The COMPLETE event is not triggered in Mac due to a bug UNLESS the server send ANY output back to the server.
A simple echo of any string would do.
this issue is detailed in the SWFUpload boards along this very solution (there may be other causes, also discussed in that thread, but the not output is the most common one): http://swfupload.org/forum/generaldiscussion/872