-
Hi @Gordon,
Do you think of using https://www.seeedstudio.com/MDBT50Q-1M-nRF52840-Based-BLE-Module-p-3147.html in the Puck ? Is it too hard to implement it on the hardware and software level ? Should this add support for Bluetooth 5 finally ?
-
Hi @Gordon,
Adding the two results for one seconds works better for me with 200Hz test.
var p=0, sBuff=new Uint8Array(2), sN=new Uint8Array(2); function soundTest() { var w = new Waveform(512,{doubleBuffer:true,bits:16}); var a = new Uint16Array(512); w.on("buffer", function(buf) { a.set(buf); E.FFT(a); var m=0,n=-1; for (var i=50;i<250;i++)if(a[i]>n)n=a[m=i]; sBuff[p]=m; sN[p]=n; if(p==1){ var avgF=E.sum(sBuff); var nAvg=E.sum(sN); console.log(avgF+"Hz @ "+nAvg); p=0; } else { p=1; } }); w.startInput(D2,1024,{repeat:true}); }
Do you know what is the accuracy loss on doubling the input sound compared to the buffer we have for processing ?
-
Hi @Gordon,
In order to calculate 400Hz when such frequency is produced, should I gather(concat) the two buffers for once second and then run FTT over them ?
-
Hi @Gordon,
I did some tests on point one above, it appeared that when you have:
1) Input at 512Hz with 512 buffer size restricting frequencies between 100Hz and 250Hz.
* Produce 200Hz sine wave audio frequency, then every thing is correctly determined - 200Hz @ XXX
2) Input at 1024Hz with 512 buffer size restricting frequencies between 100Hz and 500Hz.
* Produce 200Hz sine wave audio frequency, then you have - 100Hz @ XXX as buffer is received twice per second * Produce 400Hz sine wave audio frequency, then you have - 200Hz @ XXX as buffer is received twice per second
How can the correct frequency be determined from point 2 above ?
-
Hi @Gordon,
1) You mean this code can still measure 500Hz with lower accuracy ?var w = new Waveform(512,{doubleBuffer:true,bits:16}); var a = new Uint16Array(512); w.on("buffer", function(buf) { a.set(buf); E.FFT(a); var m=0,n=-1; for (var i=100;i<500;i++)if(a[i]>n)n=a[m=i]; console.log(m.toFixed(0)+"Hz @ "+n); }); w.startInput(D2,512,{repeat:true});
2) Is it possible to use 1024 buffer size on behalf of other functionalities ?
-
Hi @Gordon,
I am running with firmware 1v99.50 and trying run your example at https://www.espruino.com/Waveform
var w = new Waveform(1024,{doubleBuffer:true,bits:16}); var a = new Uint16Array(1024); w.on("buffer", function(buf) { a.set(buf); E.FFT(a); var m=0,n=-1; for (var i=100;i<500;i++)if(a[i]>n)n=a[m=i]; console.log(m.toFixed(0)+"Hz @ "+n); }); w.startInput(D2,1024,{repeat:true});
but have :
***Uncaught Error: Insufficient stack for computing FFT
at line 8 col 12E.FFT(a);***
Is it possible to measure 500Hz frequency or we are restricted by the Puck's memory ?
-
Hi @Gordon,
How should I interpret the returned Uint16Array buf in order to play it with javascript in the web browser for example ?
-
Hi @Gordon,
On Pi I gather the data via the built-in bluetooth and once per hour switch on the 3G modem to send data into the cloud and then switch it off.
Do you think that 3G modem could impact the bluetooth range ?
Do you think an additional BLE dongle could improve gathering the data ? -
Hi @Gordon,
All my tests are done with NRF.setTxPower(4).
Currently my server is Raspberry Pi 3 Model B with Bluetooth 4.2, but in future plan to use mobile phones or devices with Bluetooth5, because the range is an issue.As nRF52832 has Bluetooth5/ANT/2.4GHz, maybe I have to wait till the default build of Puck.js firmware is done with SDK14 and tested enough ?
Do you think in this direction ?
-
Hi @Gordon,
My usecase is to broadcast data which is pretty static and change slowly, once per hour. When we lower the interval, i.e. approaching maximum value, does it mean that we achieve lower range, the opposite what you say when we approaching the minimum value ?
If I understand you correctly if I set:
- {interval:200} close to the minimum will achieve higher range with will have higher battery consumption, and higher chance to connect to the device.
- {interval:8000} close to the maximum will achiveve lower range with lower battery consumption, and lower chance to connect to the device.
- {interval:375} is a balance between range and battery consumption and chance to connect to the device
- {interval:200} close to the minimum will achieve higher range with will have higher battery consumption, and higher chance to connect to the device.
-
Hi @Gordon,
Range is a crucial for the project I work on. My tests with PUCK in open space reached up to 30 meters visibility, but in practice I am able to scan the adverstised data if the PUCK is up to 12 meters. As Bluetooth5 provides "LE Long Range", do you plan to revisit this option a year later?
-
Hi @Gordon,
Could you explain setAdvertising interval option ?
I would like to save battery and decided to advertise data providing {interval:10000} the maximum possible, but in that time the device disappars and appears in the WebIDE, should I provide discoverable: true in order to be able always visible and connect to it?Which is the default value for the interval option? When should I prefer the minimum and maximum values ?
-
Hi @Gordon,
I upgraded two of my Puck from 1v97 to 1v99, uploaded a code and saved it.
1) Device1 does not contain any code, all the times I save the code and restart it the code is missing.
2) Device2 doesn't contained any code for the first 2 saves, after that somehow it succeeded to save it and is working as expected.Any ideas ?
-
Hi @Gordon,
Where can we find 'Storage' module ? Any examples using it ?
-
Hi @Gordon,
With 1v96 version of the PUCKJS firmware I was able to do following:
1) Produce hex file from the java script
2) Merge the firmware hex with the hex file from aboveOnce the hex file from 2) was uploaded I had a firmware with uploaded code from 1)
This is not possible with PUCKJS firmware 1v99.50 version, is there any reason for that ?
-
Hi @Gordon,
Could you explain more about "DFU_PRIVATE_KEY=targets/nrf5x_dfu/dfu_private_key.pem" specified during the build ?
This file contains private and public key. My understanding is that the generated zip file used for DFU and initial firware upload will be signed with the private key but will contain only the public key. When the device needs a DFU update the uploaded zip file will be tried to be opened with the public key on the device. If the zip cannot be opened then it is signed with different private key, thus we can be sure that on the device can be uploaded only firmware singed with the appropriate private key right ?
Thank you!
-
Hi @Gordon,
Suppose you have
var zero=Puck.mag(); function onMag(m) { m.x -= zero.x; m.y -= zero.y; m.z -= zero.z; var v=Math.sqrt(m.x*m.x+m.y*m.y+m.z*m.z).toFixed(0); console.log(v); } function main() { Puck.on('mag', onMag); Puck.magOn(); }
Multiple calls to main() will result multiple calls to onMag() function, which once the mag is stopped (Puck.magOff()) all are stopped and started if the mag is on (Puck.magOn()). Is there something like an id of the previous callback in order to be stopped ?
Calling main() 10 times you will have v like that:
21
1167
2355
3543
4731
5919
7107
8295
9484
10672i.e. mag values are exploding even without magnet close to the Puck.
I came upon this issue because in general I have:
function myMain() { Puck.on('mag', onMag); Puck.magOn(); } E.on('init', function() { myMain(); }); myMain();
which once the code is uploaded everything is working fine, but when saved I have two callbacks on the mag, if you save it again you will have three callbacks on the mag, etc. How can I have a single function where to receive the current mag values ?
Thank you!
-
Hi @Gordon,
The fix you provided is working fine, thank you!
Anyway I have a situation where Device2 for some reason hangs, i.e. it cannot be accessed via bluetooth unless it is restarted. Is it possible to get the last exception or failure somehow ?
Thank you!
-
Hi @Gordon,
Yes this is the code of Device2 and Device 1 code can be seen above, which just switch on/off the led and counts the successful invocations.
All this scenario is simulated because of a real use-case where Device2 have to invoke about 200 times a function on Device1 for a 2 hours and all the time I found Device2 reset and without any data.
Thank you!
-
Hi @Gordon,
I mean that on the 89 successful execution of a function to the remote device, the current device receive New interpreter error: CALLBACK,MEMORY and the device stops working.
Thank you!
-
Hi @Gordon,
I tried with 1v97.5 version of the firmware, it stopped on the 89 iteration with same error.
Thank you!
-
Hi @Gordon,
I have two devices:
Device1 has:
var s = false; var c = 0; function o() { c++; s=!s; LED2.write(s); }
Device2 has:
var busy = false; var gatt; setInterval(function() { console.log("Trying to connect..."); if (!busy) { busy = true; NRF.connect("xx:xx:xx:xx:xx:xx random").then(function(g) { gatt = g; return gatt.getPrimaryService("6e400001-b5a3-f393-e0a9-e50e24dcca9e"); }).then(function(s) { return s.getCharacteristic("6e400002-b5a3-f393-e0a9-e50e24dcca9e"); }).then(function(c) { return c.writeValue("o()\n"); }).then(function() { busy=false; if(gatt !== undefined)gatt.disconnect(); console.log("Write value success!"); }).catch(function(e) { busy=false; if(gatt !== undefined)gatt.disconnect(); console.log("Write value error. ", e); }); } else { console.log("Device is busy!"); } },1000);
Device 2 end dump is:
Uncaught Error: Unhandled promise rejection: Error: Got BLE error 0x8 (INVALID_STATE)
Trying to connect...
Trying to connect...
Device is busy!
Trying to connect...
Device is busy!
Write value success!
Trying to connect...
Trying to connect...
Device is busy!
Trying to connect...
Device is busy!
Write value success!
Trying to connect...
ERROR: Ctrl-C while processing interval - removing it.
Execution Interrupted during event processing.
New interpreter error: CALLBACK,MEMORY
Write value success!In this concrete test Device 2 succeeded to call function on Device 1 successfully 87 times and crashed, but sometimes it is 75, 78.
Please advice!
Thank you! -
Hi @Gordon,
Everything is working fine, it is side effect of my assumption that NRF.requestDevice could filter by id which is the mac address, but it is not. As a result my device is connected to the first found Puck and tries to execute this function there which is not available.
Is it possible to support NRF.requestDevice filtration by id ?
Thank you!
-
Hi @Gordon,
Does the Nordic SDK is a moving target in general or it becomes a moving target as you are trying to support multiple devices with single firmware ? As there is no backward compatibility in technologies as is bluetooth, added with the complexity of supporting multiple devices, are is your case, don't you think that forking the firmware for each, or required, device is the only solution to adopt most up-to-date technologies for the concrete device ?
I haven't tested your last proposal but hopefully will get back with some results soon.