Web Bluetooth cannot detect my Mobile phone (Galaxy Note 9) - javascript

I am testing web blue tooth through
https://whatwebcando.today/bluetooth.html
one of the use cases there is from the browser, it should be able to detect BLE devices and extract the battery service, which should provide a facility to determine battery level of bluetooth connected device,
However during scanning, the site cannot detect my mobile phone, I have read that Web bluetooth only supports BLE
is this compatibility issues? Upon reading i see that Blue tooth 5 of galaxy note9 is supports BLE or am i wrong?

As far as I know, Galaxy Note 9 supports BLE. As per to the documentation, even though the Web Bluetooth API specification is not finalized yet, the Google Chrome team still in progress for the implementation. It is suggested to use the navigator.bluetooth.requestDevice function that takes a mandatory Object that defines filters. These filters are used to return only devices that match some advertised Bluetooth GATT services and/or the device name. From this, you can check if your device is compatible with Web Bluetooth API specification.

Your phone does not advertise BLE packets automatically. You should have an app that starts BLE advertising.

Your Phone needs to simulate a BLE device and send advertisements of the specific service. In this case the batter_service.
You can use the BLE Peripheral Simulater for testing

Related

How to check if any bluetooth device is connected in react native

I've been attempting to detect whether a bluetooth device is connected to an android phone once a button is clicked. If detected, I would like to interact with this device from within my app. The device I'm talking about is http://www.senanetworks.com/sd1000-01.html .
I've used the example code of https://www.npmjs.com/package/react-native-ble-manager to test it out, but unfortunately, it's not picking up this device even though the regular settings app does. Additionally, checking for already connected peripherals does not work if I connected to the device outside of the app. Any tips on how to do this?
The device you are using, the Parani-SD1000 Bluetooth Serial Adapter, does state in its specs that it uses Bluetooth 2.0. You are using a library for Bluetooth Low Energy devices, but BLE was only introduced with Bluetooth 4.0.
Your devices definitely uses Bluetooth Classic (also nown as Bluetooth Serial), thats also the reason why it shows up in the settings of your mobile phone. You need to use a library like react-native-bluetooth-serial. You can use the isConnected() method to detect wether or not it is connected.

Web Bluetooth on Chrome for Android is not finding any devices

I'm trying to use the new navigator.bluetooth Web Bluetooth APIs to connect to an older Bluetooth device, however using the requestDevice({acceptAllDevices: true}) method seems to not working.
According to the docs, it should show all of the bluetooth devices without any filters, but the Chrome beta on Android is not picking up any devices whatsoever, as seen in the picture.
I'm using the Web Bluetooth Terminal with the modified mentioned method above, and getting zero luck in listing any devices.
My device is not BLE, and I'm trying to use the SerialPort "SPP" profile similar to this question, which I believe has the UUID of 0x1101 or 00001101-0000-1000-8000-00805f9b34fb.
How do I list the nearby or paired Bluetooth devices on Chrome mobile for Android?(Additional Info: Chrome 56 on Android 6.0, the Bluetooth device is a HC-05 module - tested and confirmed working correctly with a dozen of Android Bluetooth terminal apps.)
Web Bluetooth supports only Bluetooth Low Energy devices for now. You won't be able to connect to Bluetooth Classic devices with this Web API.

Mobile Phonegap applications on a local network

I've created a game using html5 and websockets that is played with both a pc and a mobile device (multiple mobile devices can also be played):
The game has a Stage - The PC or a tablet device.
And several players — Other mobile devices
The current connection between the Stage and Players is with a number (the Stage shows a number and a player can join through that number), however, I'm searching for a way that the Players can join just by being in the same local network as the Stage - meaning auto-discovery through a local network.
I've been searching WebRTC and other p2p solutions but I can't find anything. Is there something else I can use or is it completely impossible?
You can try this cordova-plugin-networkinterface plugin that supports Android, Blackberry 10, iOS and Windows devices.
There's no javascript only way to the local ip address from inside a browser. There do seem to be a good number of cordova/phonegap plugins that purport to do this:
http://plugreg.com/plugin/weconstudio-it/phonegap-plugin-ipaddress
https://github.com/jcesarmobile/my-phonegap-plugins/tree/master/iOS/NetworkInterfacesPlugin
As well as the one pointed out in the comment above. It looks like it's either android or IOS. Someone should write one that works on both!
If it was me. I would probably work with the browser headers on the Stage: REMOTE_ADDR, HTTP_CLIENT_IP, etc. There are some fine points to doing this: http://roshanbh.com.np/2007/12/getting-real-ip-address-in-php.html
On a local network, you'll be able to get the real IP address of each device. Private networks fall into a particular address space:
10.0.0.0 - 10.255.255.255
172.16.0.0 - 172.31.255.255
192.168.0.0 - 192.168.255.255
So your Stage will know when its clients are connecting to it on a LAN. Does that get you where you need to go?

Windows Store Bluetooth

I have been looking through the MSDN docs for Windows Store apps and the only thing I found that was close to Bluetooth was the Windows.Networking.Proximity. This appears to be a class whose use is only for close proximity ie within 3-4 centimeters. The app I am developing is on a HTML5/WinJS platform.
Is there a BluetoothSocket class like there is for android? For those store developers who are not familiar with Bluetooth on android essentially you create a Bluetooth Device member variable and populate that member with the device information, which is a native java call.
That will give you a list of paired devices, and you just open a Bluetooth socket to that device and then its the standard socket operations on a in/outstream for read/write.
Do I need to do the same thing and write a C++/CX version of this and add it as a Windows Component? The key thing here is that the device I'm connecting to treats the Bluetooth as a COM port, so all I need is a stable, reliable way to read/write to this device as if I were connected to a COM port.
Looks like #JimONeil's answer predates Windows 8.1 and was indeed correct for Windows 8, when the only way to have custom communication with BT device would be to create so called "Device App".
As of Windows 8.1 there is a simplified API which allows for easier (as OP describes "Android style") communication with BT devices.
Here's the quote from MSDN docs for "New Windows 8.1 APIs":
For Windows 8.1, Windows Store apps can use the new RFCOMM and GATT
(Generic Attribute Profile) Windows Runtime APIs to access Bluetooth
devices. These APIs provide access to the Bluetooth BR/EDR and
Bluetooth LE transports.
There're also few good sample projects:
Heart Rate Device (C++/ C# and JavaScript)
Bluetooth Chat (C++/ C# and JavaScript)
Per this MSDN Forum article, there isn't a generalized Bluetooth stack available for Windows Store applications.
As the thread indicates, there is only a Bluetooth Call Control sample and
If a device manufacturer needs to use Bluetooth as part of their
device, they can provide a driver and metadata for a Store app to use
it.
Information here:
http://msdn.microsoft.com/en-us/library/windows/apps/hh464909.aspx

How do you detect 3G vs. Wifi connection on mobile safari?

I am specifically asking about javascript on a mobile webpage, not an objective-c application. Is there something like Apple Reachability for javascript so I can tell when Edge, 3G or Wifi connection is made or changed?
Not unless browsers start giving this information away through the DOM which, currently, they don't. There is a navigator javascript objects which holds many things but not what you're looking for. I've also read in the news recently that some cellular carrier was adding cookies to HTTP requests made on their phones. They were found to be adding customer IDs to cookies (huge security breach!!).
Mobile Safari does add some new DOM additions but not what you're asking for.
Short of these options, you can't. Layers of the Internet Protocol are meant to encapsulate & hide the details of the bottom layers. You can't detect Edge, 3G or Wifi any more than you can detect cable, DSL or finer optics.
Finally, even if you could get this information, it wouldn't do you any good unless you had details of every single node in your TCP connection. For example, I could have the following setup :
iPad ---WiFi----> iPhone's Hotspot ---3G---> Carrier ---unknown--->>>
Addendum
In 2012-2013, the W3C was fleshing out The Network Information API which was aimed at providing "an interface for web applications to access the underlying connection information of the device". At the time, the API stipulated that an "estimated" bandwidth for the browser would be obtainable via navigator.connection.bandwidth. As of April 2014, that work has since been discontinued!!
Update 1: As of 20th October 2015, work continues on this API. You can find the latest Editor's drafts for the Network Information API on the W3C's github pages.
Update 2: In June 2020, Apple declined to implement the Network Information API in Safari due to privacy concerns
Although you cannot use data from a browser to detect if the user is on Wifi or a cellular connection - capturing the user's IP may be one way to differentiate between a Wifi and Cellular connection.
In this article about how cellular impacts your IP address (http://classroom.synonym.com/wifi-change-ip-17586.html) it states the following:
While on Wi-Fi, your device's public IP will match all other computers on your network, and your router assigns a local IP. While using a cellular connection, your cell carrier assigns a public IP. Connecting to the cellular Internet does not use a router, so your device won't have a local IP.
IF ip = localIp, then connection = wifiConnection
IF ip = publicIp, then connection = cellularConnection
Here's a screenshot of my IP when I'm on cellular:
Here's a screenshot of my IP (right after turning off cellular) on Wifi:
This could be one answer to the problem without browser help.
At the moment this limitation has improved, but there are still restrictions with the Network Information API supported in the different browsers ( mobile or not ), https://caniuse.com/#search=network
If this helps you, In our case as our specific mobile application is hybrid and developed using Ionic, we have been able to do it on either iOs or Android using this cordova plugin: https://github.com/apache/cordova-plugin-network-information that works like a charm.

Categories