Web Bluetooth contribute new service/characteristic to own device - javascript

Web Bluetooth, from reading through the spec and the APIs, seems like it can only handle pairing with a BT device and then reading or writing to it.
But it doesn't seem to be able to expose a new service or a new characteristic on an existing service on the device in the machine the page utilizing Web Bluetooth runs on.
Is there a way I missed how Web Bluetooth can be used to create a new service for the duration of the page being open and allow other machines/devices to pair with the one running the script on the page and use this new service?
My main interest is mesh networking with BTLE using the Web Bluetooth API, but for that all devices running the page need to be able to not only connect to other peers, but also to be connectable-to by other peers. That part I have no idea how to achieve with the current API.
Can I get a definitive answer on whether it is possible to contribute new services to the BT device of the computer the script runs on? Links to this being discussed in the WGs and whatnot would also be great, I am interested in why it is not possible if that's the case.

I have learnt a crucial piece of nomenclature which now allows me to answer this question: peripheral mode.
Not all Bluetooth adapters support it and the Web Bluetooth standard is not looking like it's going to support web pages acting as beacons/peripherals any time soon:
https://github.com/WebBluetoothCG/web-bluetooth/issues/231
So, as of now, what I asked for is not possible.

Related

Debugging from Web - Embedded boards

So excited to asks experts on this platform. I don't know where my question fits but anyone familiar with ARM mbed or dev.ti.com?
Let me give you a clue. On these website they provide an online IDE (just like desktop version) on which you can build an "Embedded Software" and download, run and Debug on some target board like (TIVA C, STM32 etc.) connected to PC. As far as i know javascript on web page doesn't have any access to local machine. So how does it access computer ports and computer drivers etc?
WEB Experts please give me a clue like how browser is allowed to access local computer resources??
In most cases, you're correct - Javascript running in your browser does not have access to many of the resources needed for reprogramming and debugging a development board.
However, there are a few ways to work around this:
1. Build development boards that can work with the hardware APIs the browser already allows access to.
This usually involves using APIs in unexpected ways. The integrated debug firmware on all mbed boards emulates a USB disk drive. The user can download the firmware file from the mbed site and then copy it onto the disk drive to install the firmware on the development board.
There are also some more creative (mis)uses of hardware APIs. For example, this Chibitronics board relies on the browser sending the new firmware via audio output. I have also heard about - but cannot find a suitable link to - an example of repurposing the U2F protocol to do double duty as a firmware update mechanism.
Because this approach repurposes existing APIs, it is generally widely supported, but requires extra work on the device side to fit a square peg into a round hole.
2. Install a native application/extension that accesses hardware and allows the website to access the hardware through the extension.
This is the approach used by TI Cloud Tools, Arduino Create, and Codebender. Once a user has installed a companion application, that application allows the website to access anything that a normal IDE would be able to access.
In a sense, this approach is very similar to building a native application with a very cloud-centric UI.
3. Extend browsers to add new hardware APIs that can be used to program development boards.
The WebBluetooth and WebUSB draft standards add new APIs to allow Javascript to access BLE and USB devices directly, which can then be used to communicate directly with connected USB debug hardware or BLE bootloaders.
micro:bit is currently testing a beta program that uses WebUSB to directly program and communicate with micro:bit boards.
These APIs are only implemented in Chrome, so they are not a universal solution. Additionally, due to security restrictions and driver issues, not all existing hardware is compatible with WebUSB.
As far as i know javascript on web page doesn't have any access to local machine. So how does it access computer ports and computer drivers etc?
You can access your local machine through a server. For example to ask it for a certain file or to run some commands/code through an API you define.
How browser is allowed to access local computer resources?
The browser is a program on your machine. The programming language(s) in which the browser was built provides interfaces to communicate with your system on a low level.
It's worth mentioning that the browser and the web application it renders are not the same and do not communicate in the same way with your system.

How to use the browser as the GUI for an offline application?

I want to be able to create an offline program that can use the browser as GUI. I'm not particularly good at GUI programming in general, and overall it seems that using HTML and CSS to structure a GUI would be the easiest.
Cross browser method is preferred, but I will most likely use Google Chrome
I need to be able to open an external program, possibly with command line arguments
Javascript seems like the best language for this, however as far as I know it isn't possible to launch programs with it.
This is on Windows 7.
That's a good idea and is done by a several popular softwares.
The best way is to make your offline program run a web server that the browser will be able to access.
ie: Your program starts a web server on localhost:5555 and then you'll be able to request http://localhost:5555/users in Javascript, from your browser.
Another approach could be using a UI framework like AngularJS + local storage. I'm working on an app right now that will be used online (connected to the web), online locally (connected to a local server that is not connected to the web), and offline.
You could build a single-page web app and let Angular manage all the "urls".

Activity Camera FirefoxOS

I am developing an app for Firefox OS which is supposed to load the camera when
an element is touched.
I had a search on the internet but I could not find a way to do such thing unless I was to start a "web activity" and let the user choose an application to pick.
I would like to force the camera application to start and not let the user choose the app to launch. Is there a way? (I really hope so!)
Thank you for the answer in advance!
Lorenzo
Launching the camera (app) and getting access to the camera (hardware) are two different things - depending on your needs, you may need the Camera API (as suggested by Jack) to pull images/video off the device camera hardware, or you might just want to launch the built-in camera app, so the user can interact with it (without requiring to retrieve any result, like a photo, from this interaction).
Unfortunately, both use cases are currently restricted by the permission system of Firefox OS.
Direct hardware access to the camera requires a "Certified" level permission, which prevents it to be used in third party applications. If you need this feature, your best chance is to wait until WebRTC (the getUserMedia() API) lands on Firefox OS devices, which will give you direct access to camera and microphone hardware in third-party applications (there are already some experiments on early Nightly builds of FxOS that use the WebRTC getUserMedia API on actual devices, so you it shouldn't take long before it is available to end users, too). Keep an eye on bug 750011 to follow implementation progress.
The other use case is launching the built-in camera application itself from your app. To launch an installed App on the device you need a reference to its App object, invoking the App object's .launch() method launches the selected app. Unfortunately though, currently the only way to acquiring said app object seems to be via the Apps.mgmt.getAll() function call, which lists all the installed apps on your device - scanning the list you would be able to pick the Camera app, and use its launch() method to launch it. You could see this in action in Kevin Grandon's "Matchscreen" homescreen-experiment. Unfortunately the permission system has the last word in this use case too, as the Apps.mgmt object calls, too require a "Certified" level permission (the webapps-manage permission). That is one of the main reasons why third party homescreens (like the one by Matteo D'Ignazio) can't function and actually launch apps currently. There is an ongoing discussion on relaxing the requirements on this, though, and there is work ongoing regarding third party home screens, so (in time) this should also be resolved.
As seen on the mdn page explaining App permissions, camera API is not available to third-party developers yet, but there are plans for it happening in the future.
Note: The reason that camera is limited to certified apps is that the sandbox that apps run in prevents access to the camera hardware. Our goal is to make it available to third party apps as soon as possible, but we don't have time to do that in the initial release.
You can use webRTC(getUserMedia API) in FxOS to access camera as in modern desktop browser after half a year. It will be a preffered way rather than the obsolete mozCamera API (which is not able to use for 3rd party developer).

Monitoring the displacement of a mobile device using GPS

I am wanting to develop an application for mobile devices, which shows in real time where a user (with this software installed on your mobile device) is. The idea would be that one (or more) users could follow the map the displacement of another user via GPS. I want to use PhoneGap with HTML5 and CSS and Javascript.
My question is: Is it possible to do that with these technologies? If yes, where can I get information of how to handle the GPS that way? If you can not, which language would give me this possibility and where can I get information? At first, I intend to develop this Application for Android and IOS.
Yes it’s very much possible with PhoneGap technology. You have to write a web service to keep the GPS coordinates as user updates (or auto updates) in server. You can let other users to connect to Web service and get the info they wanted (i.e. the data they wanted to see the current location of the user). You developed using PhoneGap means, it’ll work for iPhone too.
You can easily develop a web service either using PHP, Java or C# though C# web services are easy to write and maintain but PHP web servers are cheap compare to windows hosting (which you will need to host C# web service).
The question you asked is very broad so can write a 1000 words article and beyond. If you ask specific question I can answer that.

Get a tablets(iPad or Droid) mac address?

Synopsis: I am developing a HTML5 web app that will allow tablets(iPad or Droid) to login to a server and perform various functions. The client would like a way to check the devices mac address when logging in. From what I have read, most solutions use activex objects that will not work for webkit browsers.
Question: Does anyone know a solution that would hook into a HTML5 web app seamlessly(Idealy update a hidden form element with the value upon logging in)?
Thanks!
I don't think there's going to be a straightforward way to do this. The web server won't be exposed to a client's MAC address unless they're on the same physical segment...you'll only see the MAC from the most recent router hop in general.
If anything exists, it's going to be a browser plugin (show-stopper on iOS). And it would probably need more than the default permissions available (I don't suspect you can enumerate network interfaces in Java, for example, without asking for elevated permissions).
If you're looking for HTML/JS only then I don't think that this is possible. It won't be exposed.
The problem is that the packets you recieve back will only contain the MAC address of the node on the last hop.
This may be possible via a plugin, but then this limits you on iOS, and possibly also Android as you'd need to provide them a way of getting the plugin first (unless you used a plugin that was installed by default).
Edit: Not that I support an app for every little thing, but it shows that easy to press app buttons sometimes tend to do better than web apps (regardless of being able to make browser shortcuts to home screens). If it is suitable, you could consider loading this within a web view on the target device from within an app, from which you can then of course access MAC addresses and whatever else you may need.
MobiThinking: Mobile applications: native v Web apps – what are the pros and cons?
Forbes: Mobile Web App vs. Native App? It's Complicated

Categories