Comments (7)
- is it possible to do this via the vanilla API (access the device local address, and use it to set the local name, before advertising)?
It's a bit ugly, but it might be possible with 2 calls to begin
.
- Call
begin
once - Get local address
- Set local name based on address
- Call
begin
again.
- if not, what is the right way to achieve this?
This is not a use case this library had in mind.
The library to could be modified to initialize SPI communications and reset the nRF8001 prior to begin
if the local address request is requested.
What Nordic nRF8001 SDK API were you using to update the local name at runtime? I'm wondering if this technique could be used in this library ....
from arduino-bleperipheral.
Thanks, sandeep. I already tried your idea of calling begin() twice and the sketch hung on the second call to begin(). I'll try this again to verify that for certain it's hanging the sketch.
The code we used with the nRF8001 SDK API isn't open source, but I can describe what we did (and we can also open source the file if it helps). I can't be 100% certain any of the following steps is truly required to successfully change the name.
- in our own begin() routine, we setup aci_state and call lib_aci_init
- in the Poll loop, for ACI_EVT_DEVICE_STARTED, mode=ACI_SETUP, we set setup_required=true
- at the end of the poll loop, if setup_required==true, we call do_aci_setup(), and if there is no error, set setup_required=false
- in poll loop, for ACI_EVT_DEVICE_STARTED, mode=ACI_STANDBY, we set addrRetrieved=false, lib_aci_get_address(), then call poll in a loop until addrRetrieved=true,
- in poll loop, for ACI_EVT_CMD_RSP, when ACI_CMD_GET_DEVICE_ADDRESS == aci_evt->params.cmd_rsp.cmd_opcode we retrieve device address from the hardware into a global variable and set addrRetrieved = true
- once step 4 reaches addrRetrieved=true, we use the device address global variable to create a name based on the device address, then set the advertised name via
lib_aci_set_local_data(&aci_state, PIPE_GAP_DEVICE_NAME_SET,
(unsigned char *)&deviceName, strlen(deviceName));
(see https://devzone.nordicsemi.com/question/6108/change-the-peripheral-name-over-air-through-iphone/ and https://forums.adafruit.com/viewtopic.php?f=19&p=288990)
I guess maybe the device name can be updated at runtime via that PIPE_GAP_DEVICE_NAME_SET call, although that constant is defined in services.h generated by nRF Go.
from arduino-bleperipheral.
I confirmed: calling begin() twice definitely seems to hang the sketch.
from arduino-bleperipheral.
I use the library and do change both devicename and localname on the fly. But, I delete the current BLEPeripheral class before instanciating it again and setting new names/uuid before calling begin. Seems to work good for my purpose.
from arduino-bleperipheral.
Thanks, linuxdevel. That technique worked! I don't think I would have thought of that.
I'm going to close this as sandeep said he didn't anticipate this use case, and I have a workaround that works fine.
from arduino-bleperipheral.
I confirmed: calling begin() twice definitely seems to hang the sketch.
Right, based on @linuxdevel's trick, it's probably running out of RAM, because things are not cleaned up.
I've opened #52 to add a new .end()
API to clean things up, for a nicer way of handling this instead of calling delete
from arduino-bleperipheral.
can you please share your code for changing ble name by the app.
from arduino-bleperipheral.
Related Issues (20)
- Can't detect remote devices
- NRF5: CCCDs aren't persisted for bonded peers
- How to set service name ? HOT 1
- ANCS Implementation canWrite is false
- Speed / baudrate of the BLE connection?
- Numpad key codes, anyone?
- How to send more than 20bytes in each transaction with bleSerial.write()?
- Olimexino-nano + Olimexino-nano-ble freezes after begin()
- Why is my BLE Service not appearing after a successful flash? HOT 2
- [Question] Sending long string BLECharacteristic
- Abandoned project?
- nrf52840 HOT 4
- Freeze on blePeripheral.begin(); HOT 7
- BLE Scan
- softdevice_sys_evt_handler_set()
- RFDuino using BLEPerfipheralObserver to scan for iBeacons - Issue HOT 2
- Update iBeacon broadcast packet after starting
- Setting chip to idle state in between measurements
- nRF52832 Supported?
- UART Rx hangs after a few seconds when BLEPeripheral.begin(); is called on nRF51802
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduino-bleperipheral.