Most recent activity
-
Thanks Gordon,
That got rid of the warning but the variable I create from FlashEEPROM module is now undefined so it crashes at runtime.Uncaught TypeError: Expecting a number or something iterable, got undefined at line 226 col 31 var str = E.toString(f.read(0)); ^ in function "readBeacon" called from line 577 col 14 readBeacon(); ^ in function called from system
f is created by
var f = new (require("FlashEEPROM"))();
Is the Flash module supposed to be built into the firmware? Should I try reflashing.
Cheers
David -
Hi All,
I updated my Puck to v1.94 today and was reloading the software when I got a warning message "Module Flash not found".
I'm using the FlashEEPROM module to persist some data to flash, but FlashEEPROM has require("Flash") which doesn't exist at the URL the Web IDE looks for modules. (https://www.espruino.com/modules)
Has the Flash module been deprecated/removed? If so, is there something new for persisting small amounts of data across battery changes?
Cheers
Dave -
Thanks very much Gordon.
I gave it a go but had mixed results. Using the code above the iBeacon worked as expected, but nRF Connect on my iPhone showed the Service Data from the
NRF.setAdvertising
call alternated on and off. I.e. as nRF Connect scanned, the ServiceData would alternately display the correct advertisement data (e.g. <0x181A...) and 'N/A'.I didn't see that behaviour when the iBeacon data was sent in the scan response previously.
I tried turning on the advertising option in
NRF.setServices
to get iBeacon, Service Data and services simultaneously e.g.services = {....} options = { advertise: ['180A','180F','181A','87100001-703F-4AEE-A323-9AE013D98E93'], uart: true, }; function onInit() { NRF.setAdvertising([ require("ble_ibeacon").get({ uuid : beaconUUID, // iBeacon uuid major : beaconMajor, // optional minor : beaconMinor, // optional rssi : -59 // optional RSSI at 1 meter distance in dBm }), { 0x1815 : [button.single, button.long], 0x180F : [metrics.battery], 0x1809 : [metrics.temperature], 0x181A : [metrics.light] }],{ interval : 375 }); try { NRF.setServices(services, options); } catch(err) { // This always seem to throw BLE error 4 for some reason. console.log(err); } }
iBeacon worked ok, service data still blinked in and out in nRF Connect and only one of the 4 services in the
options.advertise
array was shown in ServiceUUID in nRF Connect. Connecting to the Puck in nRF Connect only showed the Nordic UART service, not any of the other defined services.Interestingly, the 'LightBlue Explorer' app on the iPhone showed the correct services, but connecting still also only listed the Nordic UART service.
I also tried reversing the order of the
NRF.setServices
andNRF.setAdvertising
calls but it made no difference. -
Thanks Gordon, I didn't realise the services advertisement was part of the scan response rather than the 'advertisement' as such, but that makes sense now.
I poked around in the source code to see if I could figure out how setAdvertising converts the object to an array, but my C fu is weak :)
nRF Connect on my iPhone doesn't seem to display the raw scan response data, are you referring to the desktop version? If so, I'll have to buy a nordic dongle or wait to see if you come up with something in an update. In the meantime I'll live without the extra services advertisement.
Thanks for your help!
Incidentally if anyone reading this is struggling to understand how advertisements and scan responses fit together I found this article useful: http://www.argenox.com/a-ble-advertising-primer/
-
-
Hi All,
I'm amazed by the capability of this little device and suspect I'm trying to have my cake and eat it, but I'm looking for a way to advertise an iBeacon, services and services data all at the same time. I'm almost there, but at the moment I can only have services and service data advertised, or service data and iBeacon.My application has the puck providing a number of services and characteristics including battery, light and temperature and a button service. These are set up with a call to NRF.setServices that specifies the advertising in the options e.g.
{ advertise: ['180A','180F','181A','87100001-703F-4AEE-A323-9AE013D98E93'] }
I'm then using a call to NRF.setAdvertising to create the service data advertisement e.g.
NRF.setAdvertising({ 0x1815 : [button.single, button.long], 0x180F : [metrics.battery], 0x1809 : [metrics.temperature], 0x181A : [metrics.light] },{ interval : 375 });
These two work together fine. I start the iBeacon using NRF.setScanResponse, e.g.
NRF.setScanResponse(require("ble_ibeacon").get({ uuid : beaconUUID, // iBeacon uuid major : beaconMajor, // optional minor : beaconMinor, // optional rssi : -59 // optional RSSI at 1 meter distance in dBm }));
The beacon works but it seems to stomp on the advertisement for services specified in the NRF.setServices() options, as these disappear. (the service data advertisements continue).
Is there some way I can use arrays in NRF.setAdvertising to specify all three advertisements, services, service data & iBeacon?
Cheers
Dave
Thanks Gordon, you were correct as usual: the firmware upgrade had done away with the previous data. I added a check for undefined as you suggested and all is well again.
Thanks very much for your help.
Cheers
Dave