-
You need an app like this one to connect to your Bluetooth device.
-
Just to mention:
I just discovered this really cool open PLC project which provides an IDE and runtime environnment for PLC applications. What I found really interesting is its ability to extend inputs/outputs on various targets through modbus. One can use arduinos, ESP8266, ESP32, raspberry pis, ... to create a distributed PLC system. I think at some point it would be of interest to provide compatibility between Espruino and this project, just because Espruino hardwares are really good devices and can provide useful features like sensing (with puck.js) or displaying (pixl.js) that could help people building home automation applications.
Of course Modbus is the key for interactions right now but maybe at some point if it could be extended to BLE as well it would make sense.
If I figure out a proper way of doing this I will post it here, for those who are interested in home automation or PLCs. -
-
-
Sorry I just mixed up the 2 events actually.
I made the update you proposed.here is a proposal: https://github.com/espruino/Espruino/pull/2299
Feel free to reject it and ask me to modify it if needed.
Usage:
NRF.on('indicateconfirmed', function() {console.log("JS HVC!");});
-
The modification has been done in this way:
case BLE_GATTS_EVT_WRITE: { // Peripheral's Characteristic was written to const ble_gatts_evt_write_t * p_evt_write = &p_ble_evt->evt.gatts_evt.params.write; // TODO: detect if this was a nus write. If so, DO NOT create an event for it! // We got a param write event - add this to the bluetooth event queue jsiConsolePrintf("indication confirmed!"); jsble_queue_pending_buf(BLEP_WRITE, p_evt_write->handle, (char*)p_evt_write->data, p_evt_write->len); jsble_peripheral_activity(); // flag that we've been busy break; }
Everytime an
BLE_GATTS_EVT_HVC
event is raised from the softdevice,indication confirmed!
is printed in the console. This is a really good start.Now I just need to understand how to update this in order to be able to react on this event on the JS layer. If anyone has a clue, Please share :-)
-
Actually I misunderstood the behavior of the BLE stack.
sd_ble_gattc_hv_confirm
is to be called on client side to send an application level acknowledge of an incoming "indication" packet.
Server side, however, the BLE stack will emit anBLE_GATTS_EVT_HVC
event upon reception of such an application level acklowledge sent by the peer. While this mecanism seems to be used in some specific BLE services, it seems that thisBLE_GATTS_EVT_HVC
event is not available for a custom BLE service. Do anyone know how and where should I try to add this event in such a way for the server application to be able to react on it? -
it looks like something is done here. Moreover, in release 2v15, the changelog says
nRF5x: Call sd_ble_gattc_hv_confirm in response to BLE indications
After that I am a bit lost, is it possible that this event is currently lost but could be exposed in JS by calling ?jsble_queue_pending()
with a new enum of typeBLEPending
? -
Supporting confirmations seems great ! I didn't test it but it could happen soon. By the way, I just wondered, is there any way for the application that just sent an Indication packet (
NRF.updateServices
called with optionindicate: true
) to be "notified" (either with a callback or promise or ? ) when the confirmation has been received from the other side?
I have some ideas in mind that would need to use as much bandwidth as possible without loosing data... -
As always, there is an impressive mass of work done in order to let the Espruino users have a much better experience with every new release!
Thank you so much Gordon (as well as the community, but everyone knows that Gordon spends 28 hours per day on making Espruino even better everyday)
I have been using Espruino since the first kickstarter and I must say that it has changed my life as a maker, but also as an electronic engineer. Espruino has given us the opportunity to automate a lot of things, provide BLE connectivity where we would have struggled otherwise
A huge thank you Gordon!
-
by the way @Gordon, is the Puck.js online doc not rendering correctly? On my browsers (Firefox and Chrome) the pinout does not appear anymore
http://www.espruino.com/Puck.js#pinout -
-
-
Thank you @Gordon. I tried to implement this feature according to your recommendation and made a pull request here: https://github.com/espruino/EspruinoDocs/pull/665
However, when testing, I got this error
Uncaught Error: Function "connect" not found! at line 96 col 26 in ADS1X15 function ADS1X15(i2c,opts={part:"ads1015"}) { ^ at line 198 col 30 ads = require("ADS1X15").connect(i2c,{part:"ads1115"}); ^ in function "onInit" called from line 212 col 8 onInit();
It is most probably a very noob, basic javascript error. Could you help me figure out what's going wrong with the way I made the change?
-
I just made a few experiments with an Adafruit 1115 breakout board along with the module EspruinoDocs/devices/ADS1X15.js. I compared the datasheet of ADS1115 and ADS1015 and it appears that the datarate config (DR[2:0]) is not the same. Thus, the ADS1X15.js is only valid for ADS1015. As long as the ADC type cannot be discovered at runtime, it may be better to make 2 modules instead of one, but it means renaming the js file. I don't know @Gordon what would be the best way to go because renaming the current js module will break compatibility for those who currently use it.
Any hint?
Kind regards,
-
-
-
I am not sure about that, but could it be that you are missing the file "weather.json" in the storage area?
I see that the app is not meant to run without it -
Thanks everyone for your inputs!
I'd advise this too. It's just super easy, and Espruino handles this more efficiently than a custom BLE service. If you're looking at x/y/z every 500ms bandwidth isn't going to be much of an issue for you at all though :)
For one Puck.js it seems definitely to be the best way to go, however I would like to have let's say 5 or more Pucks running simultaneously, and 500ms is a minimum. I did not explain well what I was trying to do: I would like to build a 3d motion sensing platform, a bit like what they use in film-making for motion capture. I am unsure of the precision I will get but it is worth a try.
At first I was thinking of using a Raspberry Pi as a central device, able to establish several connections simultaneously, but I would also love to try and evaluate the performance of an Espruino device as a central device, if the feature is being added to the firmware at a given time ;-)
Currently, I think that the EspruinoHub (MQTT) could help me implementing the central device. -
Hi @allObjects, thanks for your inputs.
I am not sure BLE can transport HTTP yet, but the protocols you are suggesting are inspiring me and I start to think that a custom protocol, based on a custom profile, could be an answer to my problem. At least it could help me challenge the BLE stack to reach the bandwidth limit -
Hi there,
For a project, I would like to use several Puck.js devices acting as wireless sensors. A computer would serve as the BLE central device, collecting the data.
So far so good, anyone would advise me to use broadcasting, and it would be fine as long as data quantity to be sent is kept low. But I would like to send as much datapoints as possible, like x,y and z acceleration for each Puck.js every 500ms or more if possible.
For such a use-case which BLE profile would you advise me to use? I originally thought of HID profile with binary data encoded in base64, but I also need downlink to send command to the Pucks.js.
If anyone has a clue about which BLE profile would best address my needs, I would love to hear about!
In the meantime, I wish you all a happy Easter. -
-
Hi.
First to do is read the doc here to know what it is all about, what is inside and what can be done with: http://www.espruino.com/Bangle.js2Then, you can connect your Bangle.js 2 and customize it with the apps you want: https://banglejs.com/apps/
As is, it already provides a lot of possibilities, but remember, it is meant to run you own apps. To know how to do that, you can follow this very good example:
https://www.espruino.com/Bangle.js+First+App -
Sure, my idea was not to create a PLC out of Espruino, but rather to expand a PLC system (such as one made with Open PLC Project) with distibuted sensors/actuators which could be Espruino devices.
At some point I will probably try to write a module capable of exposing ressources through a Modbus RTU client. This way, one could bind physical ressources (sensors, actuators) with the Modbus registers for a remote access.
To be eventually continued...