Windows Store Bluetooth - javascript

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

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 cannot detect my Mobile phone (Galaxy Note 9)

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

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.

Write data to USB HID using JavaScript, HTML5, or any cross platform language (supports Android)

I've written an UI in HTML5 and JavaScript. I chose this implementation so that I could share the same code between both Android Chrome and Windows 8 RT.
Now, my next objective is to write data to a USB HID. The device that I'm communicating with is treated as an HID. I'm mentioning this part in case there's a way to write to an HID device rather than a USB RAW device.
I've done a lot of research on the matter. But, the HTML5 specifications are changing so often that maybe I missed something.
**Anyway, is there a language or implementation that I can use to share common code to access a USB device on Android and Windows 8 RT?
If there isn't a way to share between the two, how about a suggestion to get USB communication only on Android?**
Below is my research along with conclusions:
Silverlight: unsupported. In terms of web plugins, it is not supported on Windows 8 RT or Android
Flash: Possible option. It is supported in both operating systems, although they removed support for Android with release of Android 4.1 (Jelly Bean).
HTML5: unsupported
I looked at the GamePad API, but it seems to only support reading from a gamepad.
I looked at Device tag, but this tag no longer exists in the current draft. I read that the "navigator" object replaces it in JavaScript, but it seems completely different. Also, Device only targets acquiring video and audio
JavaScript: unsupported. From my understanding, this is because it'd be a security risk.
Chrome Packaged App: unsupported. I am unsure about support in Windows 8 RT. But, it is not supported in Android Chrome, either.
A USB API exists that accomplishes exactly what I need, but the API is only available to a packaged app.
Java applet: unsupported. I am unsure about support in Windows 8 RT. But, it is not supported in Android Chrome, either.
There are many resources available regarding how to communicate with USB devices. However, since Java applets aren't supported on smartphones, this ends up being unsupported.
A couple of useful posts
How can I send and receive data to a serial port or USB port in ASP.NET?
Is accessing USB from a web application for cross browser cross OS possible at all?
Is that possible to provide a JavaScript API to control USB, LPT, and COM devices?
I've actually thought about how to do things similar to this...
Here's is one way sure way to do it if you have control over the computer which has the USB device attached:
Have the computer with the USB device run a web server such as Apache and PHP. Have it only listen to localhost.
Then in the HTML page being viewed, execute an Ajax post to localhost/somescript.php (or CGI or cfm or whatever).
In the PHP/CGI script, communicate to the USB device and then return a JSON string to the browser saying something happened.
Another approach is to use custom URL protocols. You create an executable and "install" it on the client computer along with your custom URL protocol.
Then you can invoke the executable from the browser using your custom URL protocol.
There is one more alternative Web Socket.Create a web socket server which will access the usb device in local system.
Connect your web server using Web Socket from Web Application.Web Socket has standard Api
You can do something like this
var host = "wss://localhost:25000/test";
Websokcet ws = new WebSocket(host);
You can create your web sokcet Server using RFC 6455
for older browser you can think of http server as well.
Please have a look at JSFS. It works similar to Chris_vr's approach and is already a working solution.
https://github.com/jsfsproject/jsfs.
It's free and licensed under GPL.
If the USB device you want to control is a barcode printer, you can use jZebra.
This is an applet which directly communicates to locally connected printers.
Writing to a serial port:
var writeSerial = function(str) {
chrome.serial.write(connectionId, str2ab(str), onWrite);
}
// Convert string to ArrayBuffer
var str2ab = function(str) {
var buf = new ArrayBuffer(str.length);
var bufView = new Uint8Array(buf);
for (var i=0; i<str.length; i++) {
bufView[i] = str.charCodeAt(i);
}
return buf;
}
More is at http://developer.chrome.com/apps/app_hardware.html.

Communication between multiple user sessions in HTML5 using Windows Azure notification service

We are building a HTML5 application, we have a need for colloboration between two users the same way as in Google Docs two users can simultaniously edit a document and they can see each others changes.
In our case the document is never stored at server side. And we will only have HTML5 app running in IE10 on XBOX, Windows PC (7 or 8) and Windows Phone (7.5 and 8).
The users will be on same WiFi network.
Where can we find some samples to learn how we can use Windows Azure services/ Mobile services for this scenario.
Thanks,
Navneet
You are probably looking at something like this:
http://laktek.com/2010/05/25/real-time-collaborative-editing-with-websockets-node-js-redis/
For HTML5, you can use Websockets...which can be implemented in Azure using Node.js or using the SignalR (http://signalr.net/) that abstracts websockets/polling in ASP.NET and runs in Windows Azure.

Categories