3 Replies Latest reply on Jul 21, 2014 10:23 PM by JaHu_1711326

    To change the device's name dynamically

    JaHu_1711326

      In general, the device's name is defined in the field "local_name" of the data structure BLE_PROFILE_CFG and launched by the function "bleapp_set_cfg".

      If I will identify the different device's name in the same firmware, how to change the device's name by function call?

       

      Thanks!

      Jack Huang

        • 1. Re: To change the device's name dynamically
          ArvindS_76

          See hello_sensor sample app, in particular:

           

          ...

              else

              {

                  // total length should be less than 31 bytes

                  BLE_ADV_FIELD adv[3];

           

                  // flags

                  adv[0].len     = 1 + 1;

                  adv[0].val     = ADV_FLAGS;

                  adv[0].data[0] = LE_LIMITED_DISCOVERABLE | BR_EDR_NOT_SUPPORTED;

           

                  adv[1].len     = 16 + 1;

                  adv[1].val     = ADV_SERVICE_UUID128_COMP;

                  memcpy(adv[1].data, db_pdu.pdu, 16);

           

                  // name

                  adv[2].len      = strlen(bleprofile_p_cfg->local_name) + 1;

                  adv[2].val      = ADV_LOCAL_NAME_COMP;

                  memcpy(adv[2].data, bleprofile_p_cfg->local_name, adv[2].len - 1);

           

                  bleprofile_GenerateADVData(adv, 3);

              }

           

          you can use your own string instead of bleprofile_p_cfg->local_name. And you may want to write the same string to the local name characteristic too.

          1 of 1 people found this helpful
          • 2. Re: To change the device's name dynamically
            JaHu_1711326

            I had tried this way to set the device's name.

            But, the result is still the original value of the declared config table, bleprofile_p_cfg->local_name.

            • 3. Re: To change the device's name dynamically
              JaHu_1711326

              Sorry, I forgot to write back the value to bleprofile_p_cfg->local_name.

              This method works well.

               

              Thanks!