RaspberryPi bluetooth le application always asks for pairing on iOS - c#

Im currently working on a Mobile application which connects to a Ble peripheral and reads data from it. In order to test if the connection is working. I have written a small C# application that utilizes the RaspberryPi4 bluetooth via DBus with BlueZ.
Everything works except that when connecting to iOS a pairing request is issued by the raspberry, eventhough I do not have any encrypted characteristics.
I have read on the Apple forum that this is because bluetoothd is automaticly trying to read the battery level of the phone. But sadly even after the fix suggested there I get the pairing requests.
Does anyone have an idea how I could fix this?
Thanks in advance

I believe disabling this bluez config option in /etc/bluetooth/main.conf would prevent the pi from trying to read characteristics from the iOS device, if that is the issue:
# Do reverse service discovery for previously unknown devices that connect to
# us. For BR/EDR this option is really only needed for qualification since the
# BITE tester doesn't like us doing reverse SDP for some test cases, for LE
# this disables the GATT client functionally so it can be used in system which
# can only operate as peripheral.
# Defaults to 'true'.
#ReverseServiceDiscovery = true

Check the connection min and max intervals, they shall be compliant with the iOS guidelines: https://developer.apple.com/accessories/Accessory-Design-Guidelines.pdf (page 180 - 40.6 Connection Parameters).
You can tune them like this:
echo "30" > /sys/kernel/debug/bluetooth/hci0/conn_min_interval
echo "45" > /sys/kernel/debug/bluetooth/hci0/conn_min_interval
The default values worked for me: [24,40]

Related

Why is the online enrolling of ZKTeco time attendance terminal returning result=6?

I am using a ZKTeco Time Attendance Terminal with these details:
Model: K50-A
Platform: JZ4725_TFT
Firmware: Ver 6.60 May 25 2018
FP Algorithm: 10
I can perform almost all operations found in the demo application, except the online enrolling. Whenever I try to enroll fingerprints to a user, the device just blinks an this error shows up in the application status:
Enroll finger failed. Result=6
From what I found for the GetLastError() method in the SDK doc, it probably means, Wrong Password. But I have already connected with the device with commKey and all other operations are working.
What error is it? How can I fix it?
Share the program you used for connecting the device, and SDK call used for enrolling fingerprint in the comment to have a better understanding. Anyway, your issue looks like firmware issue. You have to get your vendor to give you the updated firmware as per your mother board version (ZKMxxx/ZLMxxx). The bad thing is, your vendor might not have this knowledge to understand at SDK level. So, all the best.

WiFi Direct in Windows 10 says "UnsupportedHardware" althought it should be supported

I'll try to keep it short. I've been running in Windows 10 (10130) Microsoft's WiFi Direct Services example available on GitHub , the C# one in Visual Studio 2015 RC. Now, in their Build conference they said you can run in CMD a command to know if your WiFi adapter is compatible with WiFi Direct
netsh wlan show wirelesscap
Which gives me a big YES, your wireless adapter is compatible.
Wi-Fi Direct Device : Supported
Wi-Fi Direct GO : Supported
Wi-Fi Direct Client : Supported
But when I run the mentioned sample, everything goes OK until the WiFiDirectServiceWrapper.OnAdvertisementStatusChanged(. . .) is triggered, almost inmediatly after creating the advertiser. While running the sample with the profiler attached I get this:
private void OnAdvertisementStatusChanged(WiFiDrectServiceAdvertiser sender, object args)
--
sender | {Windows.Devices.WiFiDirect.Services.WiFiDirectServiceAdvertiser}
AdvertisementStatus: Aborted
AutoAcceptSession: true
CustomServiceStatusCode: 0
DeferredSessionInfo: null
PreferGroupOwnerMode: true
PreferredConfigurationMethods : _native, can't see_
ServiceError: UnsupportedHardware
ServiceInfo: null
ServiceName: "myservice"
ServiceNamePrefixes: {System.__comObject}
ServiceStatus: Available
I really don't know how I'm supposed to depurate this, as I can't find where this Event is raised (the only references to that method are
this.advertiser.AdversitementStatusChanged += OnAdvertisementStatusChanged
this.advertiser.AdversitementStatusChanged -= OnAdvertisementStatusChanged
^ those), and I can't see the WifiDirectServiceAdvertiser implementation.
My WiFi Card is a Qualcomm Atheros AR9485, and I'm using the latest drivers available through Windows Update. In the device manager I get two Wi-Fi Direct Virtual adapters:
Microsoft Wi-Fi Direct Virtual Adapter
Microsoft Wi-Fi Direct Virtual Adapter #2
The second one is disabled sometimes (the UnsupportedHardware event is the same, enabled or disabled). For all of them I've disabled the "Allow the PC to shut down this device to save energy" option.
I've tried to compile the code to x86 and x64, but I get the same result at the same point. I've tried another two generic wireless thumbs (those USB WiFi adapters) which Windows says yes, they're compatible too with no luck.
I know Windows 10 is not final, but any help is appreciated.
It seems that the WiFiDirect capabilities are not the only ones you need to look at if the thing you want to do is advertise a service (which is actually the "new in Windows 10 thing" concerning Direct).
The command you must execute is exactly the same as before:
netsh wlan show wirelesscap
but if you want to advertise a service, the relevant capabilities are the following:
P2P Device Discovery : Supported
P2P Service Name Discovery : Supported
P2P Service Info Discovery : Supported
P2P Background Discovery : Supported
What WiFiDirect does in Windows since 8 and 8.1 is advertising the whole computer, but since 10, WiFiDirectServices advertises one or more services running simultaneously in your machine.
Lets say you are the developer of com.boardgames. If you want to host a board games competition somewhere without a WiFi hard AP, that could be the prefix of the name of all your services, so each client connects only to the one they want: for example, com.boardgames.solitaire or com.boardgames.chess instead of connecting to your machine.
Sadly, none of the computers nor WiFi antennas I've tried are compatible with P2P discoveries.

SSH C# & Cisco devices configuration download

I'm trying to write some software in C# VS which is going to be used to connect through SSH to network devices ( Cisco Switches / Routers ) and download their configuration periodically. I've already tried SharpSSH, SSH.NET. The former is outdated and bugged, the latter just spams exceptions. What I did manage to do is use plink through the Process class to log into the device. Using redirected IO I even managed to print out the configuration. Unfortunately it doesn't print out in full. After a couple of lines a control line stops the output and waits for input
R1#show running-config
Building configuration...
Current configuration : 890 bytes
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R1
!
boot-start-marker
boot-end-marker
!
enable secret 5 $1$Or0j$2.HDFSXaC9jh/KGxhyl6I1
!
no aaa new-model
memory-size iomem 5
ip cef
!
!
!
!
no ip domain lookup
--More--
Like so. It seems like it's a console issue since I turned the feature to output without waiting on on the device. Sending anything at that moment i just like sending a command to the device so I can't actually ask for MORE output ( or at least I haven't found a way ). This may be either the console output issue ( asking whether to output more ) or the StreamWriter going full. My question is: is it possible to turn waiting OFF in a console application? If no - what would you suggest I do? Any ideas are welcome.
kravvcu
Of course you can turn off " --More--". This command will help you (on routers and switches):
R1#terminal length 0
and this one (on Cisco ASA)
terminal pager 0
Use a lightweight TFTP library and use that instead of console downloads?
http://www.codeproject.com/Articles/19314/A-simple-TFTP-client-using-C
If you are set on the console version, just process start a plink connection and read your config off of the process i/o.
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Bluetooth and C# PC -> Cellphone connection without paring

I'm trying to write simple app, which sends short text message to cellphones in bluetooth adapter range.
My first try is sending files: I can send file from PC to cellphone, but i must enter PIN on cellphone, and on PC.
I would rather to send text messages (something like push message) - is it possible to send it without paring devices?
If isn't possible to send push messages, maybe I can send simple file without requesting PIN ?
I use 32feet library.
Sample code (used to send files to selected device)
static int BTSendFile(string adres, string FileName)
{
Uri uri = new Uri("obex://" + adres + '/' + Path.GetFileName(FileName));
ObexWebRequest req = new ObexWebRequest(uri);
req.ReadFile(FileName);
ObexWebResponse rsp = (ObexWebResponse)req.GetResponse();
return (int)rsp.StatusCode;
}
A quick answer would be; NO, you will ALWAYS need some kind of pairing.
But if you take a look at the different kinds of pairing out there, you would see that BT 2.1 supports Secure Simple Pairing (SSP) with the Just Works-mode. This allows you to pair devices (almost) without any user interaction. From Wikipedia:
Just works: As implied by the name, this method just works. No user interaction is required; however, a device may prompt the user to confirm the pairing process. This method is typically used by headsets with very limited IO capabilities, and is more secure than the fixed PIN mechanism which is typically used for legacy pairing by this set of limited devices. This method provides no man in the middle protection.
However, since "This method is typically used by headsets with very limited IO capabilities", it would probably not apply to the cellphones you are talking about, but I thought you should know :)
According to the offical Bluetooth Message Access Profile, i.e. the specific Bluetooth profile that deals with accessing SMS/MMS systems on phones via a remote device:
'The MCE device shall use the services of the MSE device only after successfully creating a secure connection. This includes exchanging of security initialization messages, creation of link keys, and enabling encryption'
From: https://developer.bluetooth.org/TechnologyOverview/Pages/MAP.aspx
There is also a link to the full spec there if you are interested.
This certtainly suggests that secure pairing is required, which I'd assume to involve the passkey. My experience is that once a device has been paired a connection can be made without repeating the pairing as long as that pairing is remembered by the devices (i.e. I've paired a device once and not had to do it again). As to simpler, non-keyed pairing mentioned by khellang above, I've not seen anything about this - if it is purely for devices like headsets then the security requirements may be lower due to their not likely wanting write access to a device?

Suppress BTExplorer when another application needs to access the bluetooth connection (Bluetopia)

I am developing a C# device application for Motorola MC55 devices (Bluetopia is used). This application sets the bluetooth inquiry and pairing procedure in motion (by means of the Enterprise Mobility Developer Kit) and writes down the virtual serial port #:
public void DoConnection(IRemoteBTDevice rd)
{
RemoteDevice remoteDevice = new RemoteDevice(rd.DeviceName, rd.Id.Replace(":", ""), "");
this.bluetooth.RemoteDevices.Add(remoteDevice);
this.bluetooth.RemoteDevices.Refresh();
if (!remoteDevice.IsPaired)
{
remoteDevice.Pair(rd.Pin);
}
//TODO Note serial port # (get it by means of remoteDevice.LocalComPort)
//Works smoothly, but a second process has to do this (requirement).
remoteDevice.OpenPort();
}
But as soon as a second process (e.g. another c# device application) opens that serial port, BTExplorer is launched. How do I suppress this phenomenon?
this.comX = new SerialPort(this.BluetoothPortName);
this.comX.Open();
I'm just using another Assembly: http://32feet.codeplex.com/. It works smoothly for Motorola ES400 (Microsoft Stack). After seeing this: http://32feet.codeplex.com/wikipage?title=Stonestreet%20One%20Bluetopia, I used the same code, but it doesn't work trouble-free for MC55 yet.
Thank you for your support,
Roger Huber
As I understand it, it is BTExplorer.exe that actually provides/controls the virtual COM port service, so it needs to be running when a virtual COM port is in use...
Do be sure to let know what the issues you see on your MC55 when using my 32feet.NET Bluetopia support. As I noted at 32feet.NET: Stonestreet One Bluetopia I tested on a M3 Mobile device which has a quite recent version of the Bluetopia stack. Maybe StoneStreetOne changed something between your versions... (If Bluetopia start-up fails completely then I've more logging in version 3.3 -- which I'm not too far away from releasing).
Of course if that second C# program needs to use a virtual COM port then 32feet.NET won't help -- BTExplorer is still required as discussed above. However if you could change that program to use BluetoothClient etc instead of COM ports... (Remembering of course the "Bluetopia one at a time" restriction of course).
Alan

Categories