-
Hi @Gordon,
Which magnetometer do you use in the Puck ? Is this a suitable one http://www.nxp.com/docs/en/data-sheet/MAG3110.pdf ?
Thank you!
-
Hi @Gordon,
This is what I needed, it's working. When the FlashEEPROM data is cleared ? On firmware update and lack of power like battery change ?
Thank you!
-
Hi @Gordon,
I need first zero to be saved forever, my starting point for any calculations. So one approach could be, on first code upload to save externally the first zero, and also save it on the Puck which will survive during resets. If a new code is uploaded it must be saved, containing the first zero as value and discard the current Puck.mag() value. What do you think ?
Thank you!
-
Hi @Gordon,
I have a magnetometer related question and think this post could host it, if not please move it.
I need to reset the magnetometer upon my command, now can I do that ? Now when you upload a new code or restart the Puck, the magnetometer value is reset. Do you have a possibility somewhere to store the last value take it once restarted ? Can I do that custom implementation on my own ?
Thank you!
-
Hi @Gordon,
Thank you for the bonding functionality, I tested it with latest build and it seems to work! How can I execute https://www.espruino.com/Puck.js+BLE+UART with bonding ? In general, accessing the primaryService and characteristics should happen after bonding right ? Do you have any docs for it ?
Thank you.
-
Hi @Gordon,
IP is the MAC address of the device that can connect to the Puck.
Concerning the process of update through firmware, how secure is it ? Once the package is on the party which is doing the update could it be decoded and source revealed, if we talk about the "bin" and "dat" file in the firmware I think not, but please confirm.
If not, should I build from https://github.com/espruino/Espruino with my code added in it ? Should I write the new firmware functions in "C" or I can pass my existing my Javascript code and Espurino translate it to C and include it into the distribution package ?
Thank you.
-
Hi @Gordon,
I think that a workable security scenario could be:
1) Provide a password and decrease transfer speed on start up - this will protect the uploaded code from being viewed or modified. Here we will save a mapping between the Puck MAC address and the generated password.
2) Once the client receive the Puck with the uploaded code it should create "bonded" connection from the Gateway(Android phone, for example which will gather all the data), and will set IP for access where onConnect will disconnect any different than the provided IP connections and will automatically generate a password for all getter characteristics to protect them from other unauthorized third parties.
3) If the Puck requires a new code, the most secure way of doing that is to send to the client physically a Puck with the new code, secured in same way as described above in 1), where it has a mapping between IP and password only for the Pucks that have to be updated. The new Puck should initiate "bonded" connection one by one with all Pucks that have to be updated and will "self-propagate the code".
What do you think ?
Thank you.
-
Hi,
Do you think that following approaches are good for production:
1) Provide password and decrease the transfer speed
E.on('init', function() { E.setPassword("Password"); E.lockConsole(); NRF.setLowPowerConnection(true); });
All possible password combinations based on this https://math.stackexchange.com/questions/2103361/derive-an-algorithm-for-computing-the-number-of-restricted-passwords-for-the-gen#2103361
combined with the low response speed, practically makes the Puck unbreakable ?2) Protect your functions with password ?
function someFunction(pwd, parameters) { if (pwd!='FunctionPassword') { NRF.disconnect(); } // process the request }
Thank you.
-
Hi @Gordon,
You are right. The main issue was how to enter new line character, but that can be done typing "g(5)" followed by "shift + enter" for new line character and then press "send" button and the characteristics return the expected result.
Thank you.
-
Hi @Gordon,
Thank you for the advice! I installed "nRF UART 2.0" and tried
var v; function g(s) { v=s; Bluetooth.write(s); }
If you write without a semicolumn once you connected to the Puck it says "unexpected EOF". With a semicolumn I succeeded to light the LED on from here https://www.espruino.com/Puck.js+BLE+UART
If you write the function(with or without) a semicolumn in "nRF UART 2.0" or "nRF Connect" with notifications enabled I receive what I wrote, for example in "nRF UART 2.0" I have:
TX:g(5);
RX:g(5);TX:g(9)\n
RX:g(9)\nDo you think this could be Android specific issue as appeared in the Security thread ?
Thank you.
-
Hi @Gordon,
Yes recording in 8 bits is reasonable.
I would like to send the clip to the client. I have following questions based on the code:
var soundBuff; NRF.setServices({ 0xBCDE : { 0xABCD : { value : "N/A", readable : true, // optional, default is false writable : true, // optional, default is false notify : true, // optional, default is false onWrite : function(evt) { // optional var clipSeconds = evt.data[0]; var w = new Waveform(512*clipSeconds,{bits:8}); w.on("finish", function(buf) { soundBuff=buf; NRF.updateServices({ 0xBCDE : { 0xABCD : { value : buf, notify: true } } }); }); w.startInput(D2,512); } } } });
- Is this the right way of doing this ?
- How can I free memory once the data is sent to the client ?
- How can I view the result with "nRF Connect"
Thank you.
- Is this the right way of doing this ?
-
Hi @Gordon,
There is a progress!
All previous tests were using "nRF Connect" on Android 4.4.2. Today I tried with Android 5.1.1 and happily everything worked as expected, i.e. Puck disconnect all connections to the device.
Then I did a stress test to the Puck, pressing connect button once disconnected around 40-50 times, and finally the Puck was reset.
Hope that helps.
-
Hi @Gordon,
I applied your suggestion. On the first try I have same problem as before, while on the second and third try the Puck was reset, 3LEDs were on for a second, and was not able to connect to the Puck except remove and put the battery. I am using latest Linux Mint with Web IDE. Just a note to my workflow:
1) Connect to the Puck, upload the code and disconnect.
2) Connect with the Phone to test the uploaded functionality.
3) Try to connect to the Puck, but this is not possible unless I close the browser, switch off the bluetooth, switch on the bluetooth and open the browser.Hope that could help somehow.
Thank you.
-
Hi @Gordon,
I use 1v92.
- Connect using WebIDE on PC, upload the code (do not save it) & disconnect.
- Try to connect using "nRF connect" - you are disconnected.
- Try again to connect using "nRF connect" - 3 leds are on for a second.
- Connect using WebIDE on PC - No code is available, the state is as if you called reset();
Thank you.
- Connect using WebIDE on PC, upload the code (do not save it) & disconnect.
-
Hi @Gordon,
The scenario above can be reproduced. Currently I have:
Puck 1:
Puck.getBatteryPercentage() = 33
NRF.getBattery() = 2.39Puck 2:
Puck.getBatteryPercentage() = 100
NRF.getBattery() = 2.97On the first attempt it works fine, but on the second it reboots. I use "nRF connect" to communicate with the Puck.
Thank you.
-
Hi @Gordon,
When trying again with 1v92 to disconnect all connections which are not whitelisted
var serverAddress="xx:xx:xx:xx:xx:xx"; NRF.on('connect',function(addr) { if (addr.split(' ')[0]!=serverAddress) { NRF.disconnect(); } });
On first attempt the non-whitelisted ip is disconnected, while on second attempt the puck reboots.
Thank you.
-
Hi @Gordon,
I have following use-cases.
Client requests an average frequency for the last N seconds.
var clipSeconds=5, currentSecond=0, sBuff=new Uint8Array(clipSeconds); 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=150;i<250;i++)if(a[i]>n)n=a[m=i]; sBuff[currentSecond]=m.toFixed(0); console.log(sBuff[currentSecond]+"Hz @ "+n); currentSecond++; if (currentSecond >= clipSeconds) { w.stop(); var avg = E.sum(sBuff)/clipSeconds; console.log("Average " + avg.toFixed(0) + " Hz"); } }); w.startInput(D2,512,{repeat:true});
This code is tested and working on firmware (1v92)
Client requests an audio for the last N seconds.
var clipSeconds = 5; var w = new Waveform(512*clipSeconds,{bits:16}); w.on("finish", function(buf) { console.log(buf.length); }); w.startInput(D2,512);
For ought I see the "buf" contains the audio which should be stored and send to the client ?
I really appreciate your feedback!
Thank you.
-
Hi @Gordon,
Based on the code below:
var clipSeconds = 3, currentSecond = 0; var w = new Waveform(512,{doubleBuffer:true,bits:16}); var a = new Uint16Array(512 * clipSeconds); w.on("buffer", function(buf) { a.set(buf, currentSecond * 512); currentSecond++; if (currentSecond >= clipSeconds) { w.stop(); E.FFT(a); var m=0,n=-1; for (var i=150;i<250;i++)if(a[i]>n)n=a[m=i]; console.log(m.toFixed(0)+"Hz @ "+n); } }); w.startInput(D2,512,{repeat:true});
My understanding is that all the sound as buffer will be stored in "a" from where once all the data is aggregated we could define the frequency.
When this code is deployed the flow hangs on "E.FFT(a);" and I cannot connect to the Puck anymore. Please advice.
Thank you.
-
Hi @Gordon,
Please advice how to update the firmware to a fairly huge number of pucks without manual interaction, may be puck password protection is enough for such mode ?
Thank you.
Hi @Gordon,
How can I read all the information stored ? When I try
it dumps "xxxxx"..."xxxxxx", i.e. prints just the beginning and the end of the stored string if it is too long ?
Thank you!