Change device name

Hello Nordic Engineer,

I know that I can modify #define DEVICE_NAME "device001" in sdk_config.h, but it takes a lot of time to compile and flash the program every time. It seems like there should be another way to quickly solve this.

【1】Is it possible to modify it through the iOS nRF Connect app, but with a prerequisite? Do I need to add some code in the 52811 program? (My product uses nRF52811)

【2】Can it be solved through the command line with J-Link? But I've never used the command line before...

【3】Are there any other methods? I just want to solve the problem quickly, and I don't mind how many methods there are.

Thanks

  • Hello Ylvisaker ,

    But I hope that after changing the name, the advertising will use the new name the next time the power is restarted. Do I have to modify the DEVICE_NAME every time I want to change the name and wait for the 1-minute build time?Sob

  • Hello,

    tony55723 said:
    But I hope that after changing the name, the advertising will use the new name the next time the power is restarted. Do I have to modify the DEVICE_NAME every time I want to change the name and wait for the 1-minute build time?

    If you use a variable instead of the compile-time DEVICE_NAME define then the device will start its advertising with whatever name you have provided in that variable, and so you will not have to recompile each time you want to change name, no.

    How you populate that variable name will be up to you - you could have a list of names stored in your FLASH (persistent memory), or you can receive the new name from a BLE connection, or you can push a button to make it go to a predetermined name.

    Best regards,
    Karl

  • Hello Ylvisaker ,

    you could have a list

    const char* DEVICE_NAMES[] = {"Device0001", "Device0002", ....... ,"Device9999"};

    nRF52811 Flash is so small

    I may not design it this way, but it should be achievable using the 'Device+xxx' approach.

    But I have a question, the BLE data reception (NUS), or buttons, and what I consider UART (PCB copper wires), these all belong to external signals, so I still need to store data (Flash), right?

    The next time the device boots up, it will first read from the Flash. For example, if it reads 0x0a, it will advertise as 'Device' + '0x0a', which is 'Device0010', right?

  • tony55723 said:

    const char* DEVICE_NAMES[] = {"Device0001", "Device0002", ....... ,"Device9999"};

    nRF52811 Flash is so small

    I would not recommend this approach if your list of potential names are as long as this, all but one of these entries actually will be useful to the device. In this case I would go with the approach using a single variable stored in flash, which you may later re-write if needed.

    It is not quite clear to me how the number of the device name will be generated or determined, could you elaborate on this?

    tony55723 said:
    But I have a question, the BLE data reception (NUS), or buttons, and what I consider UART (PCB copper wires), these all belong to external signals, so I still need to store data (Flash), right?

    Yes, all of these options would still need to store in flash in order to persist through a reset.

    tony55723 said:
    The next time the device boots up, it will first read from the Flash. For example, if it reads 0x0a, it will advertise as 'Device' + '0x0a', which is 'Device0010', right?

    If you are using a variable for your name which you have stored in flash then this variable will be read upon startup and input as the device name to the GAP function, yes. Please see one of the three FLASH storage examples here as a reference for how you may store your variable in flash.

    Best regards,
    Karl

  • Hello Ylvisaker ,

    The device number is assigned according to the quantity ordered by the customer. For example, if 100 units are ordered today, the numbers will be from 1 to 100. If 200 units are ordered tomorrow, the numbers will be from 101 to 300.

    Thank you very much. In the infocenter you provided, I found examples\peripheral\flash_fstorage. Later, I will try to implement the write flash function.

Related