BLE Discovering Result different between Windows 10 and Android 6 - android

I'm today in front of a problem with bluetooth and web app.
Introduction
First, here is my goal:
I want to connect a KDC (barcode scanner) in a web application (which will be probably write in C#, ASP.Net Core and JS). You can find the model and characteristic of this scanner here : koamtac.com/wp-content/uploads/KDC300.pdf .
The goal of this project is to use this website mostly on tablet and mobile, and not to use scanner with windows (but we would like to be able to see the website in computer aswell)
Sadly, Koamtac gives a SDK for windows local applications, for Android applications, but not really for web applications...
BLE tool
With this objective in mind, i discovered BLE technologies and the new Web Bluetooth API powered by google : Google Web Bluetooth API Implementations Status.
As you can see, we could use it with windows to discover devices but not to be connect with them. (But with android 6+, it is possible to do both).
This tool seems to be just in line with my project but currently i didn't knew really if my KDC could be use as a BLE device. I decided to make a simple web application where i could test if i saw (or not) the KDC device.
Application
navigator.bluetooth.requestDevice(
{
acceptAllDevices: true,
optionalServices: ['battery_service']
})
.then(device => {
console.log('> Found ' + device.name);
console.log('Connecting to GATT Server...');
return device.gatt.connect();
})
I did it on a github rep to get the HTTPS protocol which is needed to empowered the Web Bluetooth API. You can see this app here : My GitHub Repository
Finally, i tried this application with 3 differents states:
With Windows 10, in local (using Chrome Dev Tool)
With Windows, connected to rlamotte.github.io
With Android 6+ on my smartphone, connected to rlamotte.github.io
Before giving my results, you can see every bluetooth device in range of windows/android on the picture named "Device_In_Range_......" in the Github Rep
Results
I had those results:
In local, KDC device is every time found (see Request_Device_Result_Windows_Local). I can't connect to it (see KDC_connect_Windows) because Windows is not able to connect to GATT.
In this page (see Request_Device_Result_Windows), KDC is found 10% of time, and it takes much time to get it (approx 1 min). As you can see, Request found Gwladys, and 81PRMX1.
(see Request_Device_Result_Android), KDC is never found, and the request found EST (a beacon) and JBL Flip 3 (a bluetooth speaker).
Conclusion:
As you can see, the result of request_device is not the same with windows 10 and android 6. But when we use the bluetooth manager of those device, we saw exactly the same devices (the sum of devices found by each request_device).
I'm new to Bluetooth API area and i don't know why Android doesn't show all bluetooth device with request_device.
THANKS for you help ;)
EDIT #1
It seems that KDC 300 doesn't support BLE. I'm currently searching a way to connect bluetooth classic device to web app. If anyone has an idea you can tell me. If i don't find any powerful way to solve it, i'm gonna try to make an hybrid app android/windows with xamarin to use native bluetooth connection.

Related

How to test OBD-II device ( for car ) response on android and iOS?

Currently I am upgrading an android and iOS app that will show Car RPM, speed, turbo and other things using OBD-II device (bluetooth). Most of the code was written on an old app source code and I am using that code on a new screen.
The problem is that I don't have a device for testing (I have just used code from an old source code ). I have a text file that has the response returned by the device. How can I send that response to mobile app using any windows/mac software ?
I mean is there any software available that will allow to connect mobile app via bluetooth and then I can send response. eg RPM, SPEED etc ?
Here is a sample response that I want to send via bluetooth (PC) to mobile app.
,$OBD-RT=2,76,1193,-40,0,103,-26,75,15.29,12.0,48,29.41,0,581.3,14.7,0.00,3.70,0.000,0.855,0.000,0.000,0
,$OBD-RT=2,76,1181,-40,0,103,-26,75,18.82,12.0,48,38.43,0,581.3,14.7,0.00,3.67,0.000,0.855,0.000,0.000,0
,$OBD-RT=2,76,1183,-40,0,103,2,103,18.82,12.0,48,38.43,0,579.1,14.7,0.00,5.04,0.000,0.845,0.000,0.000,0
I have attached 1 screenshot of the app
So is any software available ( for OBD-II) that will allow the mobile app to connect via bluetooth so I can send the response to the app ?
There isn't such an emulator as far as I know and if there is, normally not so reliable. But there are some devices such as Freematics that can emulate the vehicle's OBD II. In such devices there is a lack of multiple response from emulated ECU. (which as I see in your app is necessary and you probably want to have 6 requests together).
If you're serious about developing an OBD2-app, you should acquire a hardware simulator, i.e. the DIAMEX OBD2 Simulator. It's the next best thing apart from using a real car.
1
I did run into an obd II simulator I found in the google app store which I installed on one of my development phones https://play.google.com/store/apps/details?id=com.beastovest.obd.simulator
On a second phone, I installed the Car Scanner from the store (free) https://play.google.com/store/apps/details?id=com.ovz.carscanner
The setup is pretty simple. Just pair the device from the simulator to the scanner.
In the simulator, I can change engine values and I can see the commands and the changes in the scanner. You can see the rest of the communication as well. The simulator is $5. Very nice for that price. I can also see the complete communication which I need for my app development. I also speed up the understanding of the ELM327 commands. Here is the spec: https://www.elmelectronics.com/wp-content/uploads/2017/01/ELM327DS.pdf
Hope that helps anybody.

WiFi-Direct P2P Service Discovery with Windows 10 and Android - possible?

I'm writing a mobile app that will be a remote control for a PC application. What I want to do is couple them using WiFi Direct.
I read about the P2P Service Discovery feature, that allows me to look only straight for devices running a certain service (and not for all of the available WiFi Direct devices).
On the Android side I implemented it using these tips: https://developer.android.com/training/connect-devices-wirelessly/nsd-wifi-direct.html
On the Windows side I'm running this app: https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/WiFiDirectServices
Unfortunately in case of the PC side, I'm not even able to start advertising my service - the Advertisement Status is automatically set to 'Aborted' just after trying to launch it.
1) Is that at all possible to couple a Windows application with the WiFi P2P NSD feature provided by Android devices? (asking if I should waste my time)
2) Is that possible for a Windows PC to support P2P Service Discovery? Here the issue of system capabilities is discussed; in case of my PC WiFi Direct is supported, and none of P2P Discovery features are. Is there any way to make it support it, either hardware or software?
WifiDirect works atleast over Windows 10 & 8.1 in UWP apps using PeerFinder library. However using this lib you can perform discovery either PC to PC OR mobile to mobile NOT PC to mobile or vice versa.
But note that It is PeerFinder library limitation NOT wifi-direct. You still can use underlying wifi-direct libraries for advertisement & discovery. It is possible and i have tested this atleast between window desktop app & windows mobile (NOT with Android).
About this problem: Advertisement Status is automatically set to 'Aborted'
I ran into the same issue. The problem was, in my case when I specified a PREFIX (Publsh Prefix: xxx ). If you enter only the service name and leave all the options in their default value, and NOI prefix, the service starts running and advertises as expected.
If you want to use prefixes you need to use the correct syntax for the prefix. Let say you want to have several services in your server, then use the following syntax for each service:
MyServer.Service1 MyServer.Service2, etc. (the period separating the words is part of the service name). THEN your prefix should be MyServer.
That was the answer in my case, but I am still struggling to get the systems to connect and do some actual work for me .... :(.

How to use android as ANCS content provider?

I'm trying to demo android side service (content provider in ANCS lingo), that communicates with embedded device that supports Apple Notification Service (ANCS) notification consumer. Reason for this is, that the embedded device only supports ANCS. As the ANCS BLE side things are publiced by Apple, this should be possible and I've already added that service + associated characterics to android side gatt server. Embedded device is nordic nRF52 and SW is nordic ANCS demo. Demo works OK with iPhone and apparently with the desktop version of nRF control panel (if added with nordic supplied config and if you have windows machine, which I don't).
However I cannot seem to be able to bond the device with android, that's required before connection. The advertisement is in limited discovery mode (before bonding) so I cannot find it via regular scanning from settings. Also bonding from java code doesn't work. With mBluetoothDevice.createBond() I get ACTION_BOND_STATE_CHANGED callback with state 10 (BluetoothDevice.BOND_NONE) with old state 11(BluetoothDevice.BOND_BONDING). Apparently I would need to exchange keys here, but no idea how to do that.
Also dunno if anyone has done this same exercise before, but any other tips would also be appreciated! Thanks!
Problem was that the phone BLE stack was corrupted or in some invalid state. REboot and removing battery solved the issue with the bonding.

Wireless (Wifi) Chat Application

I am a fellow Android developer and want to develop a similar app like Firechat for educational purposes
I just want to know what kind of packages and techniques I need to learn to develop a app like this
App Features :
I Need to discover the phones which Have wifi direct and my App on
Next I need to be able to send messages and start device to device communication
and If the device I want to connect is not in range ,The message should Hop from one device to another till the destination is reached
I think It can done by creating a mesh network
I have went through similar techonlogies like serval/Firechat/Opengarden ,But I am not being able to comprehend it
For being able to connect devices for peer to peer connection you have the following options:
1. Wifi Direct
2. Bluetooth
3. Wifi Hotspot
Here is a basic tutorial on how to build a chat over wifi direct
http://developer.android.com/guide/topics/connectivity/wifip2p.html
And for bluetooth
http://developer.android.com/samples/BluetoothChat/index.html
You can also import these sample projects in eclipse by:
1 For WifiDirect -
Go to New -> Android Sample Project -> Choose API level 16 (Android 4.1.2)-> WifiDirectDemo
2 For Bluetooth -
Go to New -> Android Sample Project -> Choose API level 16 (Android 4.1.2)> BluetoothChat

How to connect Android device to an iOS device over BLE (Bluetooth Low Energy)

I'm trying to make an application which uses the new Bluetooth Low Energy API of Android. For this, I started with the BLE sample coming with API level 18.
As I read that Android can not act as a Peripheral, I put the Android phone in central mode, scanning for BLE devices around it. For this purpose, I made some testing with a Nordic Platform simulating a Heart Sensor. Everything works in a perfect way!
After this, I try to pick an iPhone (iOS 7 beta 4) and put it in a Peripheral way and simulating a Heart Rate sensor as the previous testing. The Android app is able to see the device and connect to it. But after the connection is active, the 2 devices disconnect from each other in 3-4 seconds. In addition to that, when I call discoverServices() on Android side, no callback is triggered! In some cases the Android device receives the "Connected" event even if iOS Bluetooth chip is Off. This is very strange. To prove that, I put the Nordic Board in Central mode and I was correctly able to connect to the iOS device with no problems.
What could it be? There are some limitations on Android or iOS that don't permit to connect from an Android to an iOS or viceversa?
Thanks.
EDIT: After some hard testing, I raised an issue on the AOSP page. It can be checked here
Adding a summary for reference:
What could it be? There are some limitations on Android or iOS that don't permit to connect from an Android to an iOS or viceversa?
When connecting to a GATT server that is advertised as dualmode (BLE and BR/EDR) device by calling connectGatt(...), the TRANSPORT_AUTO flag that is internally added makes Android to default to the BR/EDR mode (link).
Following workarounds are possible:
Peripheral side: Stop advertising BR/EDR capabilities by adjusting
the appropriate flags (link)
Central side: Set the transport parameter explicitely to
TRANSPORT_LE by calling the hidden version of connectGatt() using
reflection
Example:
public void connectToGatt(BluetoothDevice device) {
...
Method m = device.getClass().getDeclaredMethod("connectGatt", Context.class, boolean.class, BluetoothGattCallback.class, int.class);
int transport = device.getClass().getDeclaredField("TRANSPORT_LE").getInt(null); // LE = 2, BREDR = 1, AUTO = 0
BluetoothGatt mGatt = (BluetoothGatt) m.invoke(device, this, false, gattCallback, transport);
...
}
Edit 4/2016
As Arbel Israeli pointed out in the comment, Google introduced an overloaded version of connectGatt(...) which allows to specify the transport in Android M.
I've written a simple working example, well relatively simple, and included it open-source on Github: https://github.com/GitGarage. So far it has only been tested with an Android Nexus 9 and an iPhone 5s, but I presume it would also work with a Nexus 6 and various iPhone types. So far it is set up explicitly to communicate between one Android and one iPhone, but I presume it is tweakable to do much more.
Maybe a bit delayed, but perhaps your pain can be relieved slightly ;)
We have been experimenting a lot with cross platform BLE connections (iOS<-> Android) and learned that there are still many incompatibilities and connection issues. Aside to the instability of Android you should also consider that still, as of today, not that many Android devices actually support the BLE Peripheral mode.
Therefore, if your use case is feature driven and you only need basic data exchange I would suggest to look at Frameworks and Libraries that can achieve cross platform communication for you, without you needing to build it up from scratch.
For example: http://p2pkit.io or google nearby
Disclaimer: I work for Uepaa, developing p2pkit.io for Android and iOS.
You can now pass in TRANSPORT_LE via BluetoothDevice.connectGatt as of API 23.
Please see Android Documentation references below:
TRANSPORT_LE
Bluetooth.connectGatt
iOS Devices always be a peripheral or central but Android devices cant be rarely.In this case your iOS device must be a peripheral and android must be a central.We can think peripheral is a server and central is a client.This is simple.

Categories

Resources