-
• #2
'E.setBootCode' underpins the Espruino save on send functionality from the IDE, and that has an option to persist/run after reset. I guess there's an argument you can pass, but if not maybe you can use the IDE.
-
• #3
The option is called alwaysExec, see http://www.espruino.com/Reference#l_E_setBootCode
-
• #4
Ah thanks, so in that case, that won't help. Looks like OP is passing true for
alwaysExec
already. So @user87803 it looks like it will persist beyondreset()
but notreset(true)
which is going to empty the flash. -
• #5
isn't there a way to set the name characteristic using lower level code?
I've experimented with python bluepy for the raspberry pi zero w that appears to read and write the 0x2A00 name characteristic, but does not actually write.
Is there an espruino equivalent?
I have triedNRF.setAdvertising({0x2A00: "<Puck>"},{});
but that doesn't work either (despite the fact that it should if the puck conforms to bluetooth specifications.
-
• #6
I'm not quite sure I understand the question... If you do
E.setBootCode('NRF.setAdvertising({},{name: "<name>"});'/*,true*/);
withtrue
uncommented then the name change will persist through power cycling and callingreset()
.WARNING - THIS IS DANGEROUS if you run code with
E.setBootCode(..., true)
it is always called, which means if you do something that stops you connecting to your device it's non-connectable FOREVER. Always try without settingtrue
first to check that what you want to do actually works!The only thing it won't persist through is
reset(true)
because that erases everything you wrote to the device.If you want it to persist through completely erasing the device's memory then you have 2 options:
- Build your own firmware with the name changed
Replace
reset
so the user can't fully reset the device's memory:(function() { var r = reset; global.reset=function(){reset()}; });
- Build your own firmware with the name changed
I'm looking for a method of changing the bluetooth interfaces name in a way that persists through power cycling without modifying onInit() or setBootCode()
I have already used
however it does not persist through power cycling and whilst I have found a way to make that happen using the following code:
It is still removable with reset(true).
I can't use any methods that write to the onInit() function or E.init() handler as existing data there would be erased, so my question was whether writing to the 0X2A00 service (that defines the name), can be done at a lower level either via a puck, the web IDE, or a raspberry pi using the bluepy library.