Giter Site home page Giter Site logo

Comments (7)

sandeepmistry avatar sandeepmistry commented on July 30, 2024

@dakoner

  1. 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.

  1. Call begin once
  2. Get local address
  3. Set local name based on address
  4. Call begin again.
  1. 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.

dakoner avatar dakoner commented on July 30, 2024

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.

  1. in our own begin() routine, we setup aci_state and call lib_aci_init
  2. in the Poll loop, for ACI_EVT_DEVICE_STARTED, mode=ACI_SETUP, we set setup_required=true
  3. 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
  4. 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,
  5. 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
  6. 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.

dakoner avatar dakoner commented on July 30, 2024

I confirmed: calling begin() twice definitely seems to hang the sketch.

from arduino-bleperipheral.

linuxdevel avatar linuxdevel commented on July 30, 2024

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.

dakoner avatar dakoner commented on July 30, 2024

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.

sandeepmistry avatar sandeepmistry commented on July 30, 2024

@dakoner

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.

jaymishra01 avatar jaymishra01 commented on July 30, 2024

can you please share your code for changing ble name by the app.

from arduino-bleperipheral.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.