How to advertise Bluetooth using electron on Mac - node.js

I am aware of Web Bluetooth APIs being accessible in electron. The limitation right now is that those APIs can only be used to connect to nearby devices, but not advertise the device itself.
Are there any options for advertising the existance of the Mac OS app?
Currently researching for ways to use some CLI tool, calling Swift from electron, or interacting somehow with bluetooth via node.

Related

What language/libraries best for BLE connectivity?

Operating system: MacOS
Just for some context on what I am trying to do, I have an Ikea standing desk which has bluetooth. I am able to control the desk with a built in app. I want to create a server running on a raspberry pi that connects to desk and controls it, I then want to create an Alexa skill which will control the desk by calling the server endpoints.
What's the best language/library you would suggest I use? Ideally something that would run on MacOS and Ubuntu.
I don't know anything about BLE yet which is why it is hard for me to find a good answer. If you have resources, books or tutorials that will help me get running with BLE please recommend them.
My use case:
Get desk to go up
Get desk to go down
Get current position of desk
If you want to write one app that works for both MacOS and Ubuntu then as ukBaz said, python and Bleak are your best options. If you want to use the native way of writing BLE apps for each OS, then you can use CoreBluetooth on MacOS and BlueZ on Ubuntu. The advantage of the former is that you can get an application up and running quickly, and the advantage of the latter is that you will find a lot more resources and advanced functionality.
Below are some resources that can help you in your development:-
Theoretical Bluetooth:
Bluetooth Low Energy: A Primer
Getting Started with Bluetooth Low Energy
Ellisys Bluetooth Series
CoreBluetooth
Getting Started with CoreBluetooth
Ultimate Guide to Apple's CoreBluetooth
iOS App Full Example
BlueZ
Configuring Bluetooth devices with bluetoothctl
Ubuntu: Accessing GATT services
Python
Ikea IDÅSEN desk API and CLI
Idasen controller example
Using Python for Bluetooth

Bluetooth connection via HID/HSP profiles (Smartphone/PWA to IoT device)

Bluetooth connection via HID/HSP profiles (Smartphone/PWA to IoT device)
We are developing an IoT device and face issues with automatic connectivity to the smartphone via Bluetooth, as we have to use a PWA instead of a native app.
We consider using a standard profile (e.g. Headset Profile (HSP), Human Interface Device Profile (HID)) to enable communication via Bluetooth between device and PWA.
We now require a workaround for the following issue:
When using HSP/HID, existing connections to the smartphone's hardware (e.g. headset, keyboard) can be interrupted.
Have you faced similar issues and do you know workarounds for this?
Are you knowledgeable about alternative connection mechanisms (e.g. NFC, SIM) to connect IoT with PWA incl. pros and cons?

node.js BLE API for windows requires external dongle

I'm developping a node.js electron app and I need to decide if our Hardware will feature BLE or standard Bluetooth.
I found a couple of APIs (bleno & noble) for this purpose. However for Windows OS both of these require me to use an additional bluetooth usb adapter (used WinUSB & Zadig).
To put it bluntly, is there any way to communicate with a BLE device on a Windows OS using node.js without using an external dongle?
It seems like standard bluetooth is just way less of a hassle. Thanks!
Found a package which solves this issue using a UWP-to-noble bridge:
https://www.npmjs.com/package/noble-winrt
It works just like noble but supports BLE connectivity on Windows without the need for a dongle and complicated driver set-ups!
I was able to easily integrate it on Electron as well, problem solved! :)
The official Bluetooth API on Windows is built for Windows Runtime, https://learn.microsoft.com/en-us/microsoft-edge/windows-runtime. It supports Javascript but I'm not sure if you need a specific js environment. If you don't get that working, you should write or use a native binding for node.js.

Does the Universal Windows Application infrastructure support any Serial Port communications?

I have a WPF desktop application that would make a good candidate as a Universal Windows App. The application has a must-have dependence on USB or Bluetooth devices that act as a Serial Port.
In all my reading I've yet to discover whether there is any access to a SerialPort API in a UWA.
I suspect the answer is 'No support'. If so, does anyone know of a USB or Bluetooth GPS that supports whatever APIs the UWA has for that sort of thing. I have to be able to read things like ground speed, elevation, rate of climb, etc.
If the answer is 'Supported', could you point me to some documentation.
For the "Bluetooth devices that act as a Serial Port", I assume you mean the RFCOMM. They are both supported on Windows Runtime since Windows 8.1 and you can also use them in the Universal Windows Application.
namespace: Windows.Devices.Usb and Windows.Devices.Bluetooth.Rfcomm.
About the Bluetooth GPS, I'm not sure if it uses RFCOMM or not (it depends on the devices), and it is also possible to use the GATT.
Code Sample: Custom USB device access sample

Communicating with nearby devices

I want to develop a FirefoxOS privileged app that can send text messages to nearby devices.
Android app can use Bluetooth or Wifi P2P. But FirefoxOS privileged apps cannot use Bluetooth/Wifi API. These are only available for certified apps.
Privileged apps can use TCP socket API. Is this the only way?
Is there any way to get available IP addresses on LAN?
#Kazhik, unfortunately right now, that is the only way to go. And the explanation for that is that by using the socket API you can implement any protocol on top of TCP, such as IMAP, IRC, POP, HTTP, etc., or even build your own to sustain any specific needs you could have.
Since certified apps can only be included by the oem, access to Bluetooth or WiFi information API aren't a viable option now.
At today's date (September 18, 2015) the WebIDE supports installing certified apps in older Firefox OS versions like 1.3 and in physical devices.
I tried installing the Gaia test apps (these are certified) in one Alcatel OT FireC and everything worked perfectly fine ;)
DNS-SD (part of the Zeroconf specification) allows you to broadcast and receive "advertisements" from other devices on the local network. That requires UDP and TCP permissions, which means a "privileged" app, as you thought. That's not a problem, unless you need to distribute the app outside of the Firefox Marketplace.
There's an implementation of DNS-SD for JavaScript at https://github.com/justindarc/dns-sd.js
For compatibility with other messaging apps, you might want to implement XMPP:
http://www.xmpp.org/extensions/xep-0174.html

Resources