-
-
I try to play with sounds on my MDBT42Q module. It seems that
w.startOutput
is not doing anything. Any hint? Furthermore, event 'finish' is never emitted.My code is below:
(sound.raw is in internal storage and has been generated following the procedure explained here)BZ=D28; LS=D29; var w; function play() { var wave = require("Storage").read("sound.raw"); w = new Waveform(wave.length); w.buffer.set(wave); analogWrite(BZ, 0.5,{freq:40000} ); w.startOutput(BZ, 4000); w.on("finish", function(buf) { BZ.reset(); console.log("done!"); }); } var inited=false; function onInit(){ if(!inited) { inited=true; analogWrite(BZ, 0.0,{freq:4000} ); pinMode(LS,'input_pullup'); setWatch("play();", LS, {repeat:true,edge:'rising',debounce:50}); } } onInit();
-
@Gordon you are just fantastic, it works like a charm! I still don't understand how you can be so reactive on so many topics. Maybe we all think there is only one Gordon, but in reality you are a whole dedicated team sharing the same account name ;-)
Anyway, regardless of the number of Gordons out there, thank you very much for your help!
-
Any news regarding usage of OneWire on NRF52?
Did anyone tried to use an UART peripheral to achieve OneWire communication, as proposed by Analog Devices in this application note? -
Thanks for your useful answers.
I actually never used Serial1 because it seems to be the default console interface when BLE console is not available.
I will try forcing the console on BLE withE.setConsole("Bluetooth")
in order to avoid problems between the console and the device plugged onto the Serial port. -
Hi folks,
I played a lot with UART on Espruino based on STm32. Very handy to communicate with various sensors or external systems.
On STM32 boards SERIAL is very efficient thanks to the use of hardware peripherals in background. However, now that I am very convinced with Espruino on nRF52 (especially MDBT42Q which gives a lot of flexibility to build projects around), I struggle sometimes with the SERIAL library because it is implemented in software. I would say that with baudrate greater than 2400 Baud the Serial interface is not reliable anymore.
Is anyone experiencing the same limitation? Is there any plans to provide a better Serial on nRF52 boards? -
It is sad to read that, however all the reasons you mentioned are understandable. I think this watch is REALLY meant for coders/hackers/developers, and it does it really well (at least to me). I never used it as a health tracker, gps companion or any other use-cases that most of customers expect from a smart watch. I used it (and still use it everyday) as a remote control or as a wireless logger (my voltmeter sits on the lab while I get its value at my wrist and it is somehow useful), but the best I can get out of the Bangle.js 2 , and same from every Espruino devices, actually, is the ability to quickly test things related to electronics/control/programming.
I hope you will find a watch that suits your needs. I found mine!
-
-
My wife is using a puck.js everyday in the car to play/pause/next/previous songs she is streaming on the car audio system through Bluetooth. The phone connects automatically to both Bluetooth devices (car's audio system and puck.js through BLE).
The code which is running on the puck.js is this one:var controls = require("ble_hid_controls"); NRF.setAdvertising({},{name:"MediaButton",interval:500}); NRF.setServices({ 0x180F : { // Battery Service 0x2A19: { // Battery Level readable: true, notify: true, value : [Puck.getBatteryPercentage()] }}}, { hid : controls.report }); setInterval(function(){ NRF.updateServices({ 0x180F: { 0x2A19: { value : [Puck.getBatteryPercentage()] } } }); }, 60000); setWatch(function(e) { var len = e.time - e.lastTime; if(len>0.7) { controls.playpause(); digitalPulse(LED1,1,100); } else if (len > 0.3) { controls.prev(); digitalPulse(LED2,1,100); } else { controls.next(); digitalPulse(LED3,1,100); } }, BTN, { edge:"falling",repeat:true,debounce:50});
I think recent phones are always trying to connect to local Bluetooth/BLE devices that have previously been registered and allowed by the user
-
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...
-
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?
Just gave it a try, it seems to work like a charm! Great job, as always!
things will be lot easier for remote operations.