Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

Smart Bluetooth Forum Discussions

Anonymous
Not applicable

const BLE_PROFILE_CFG dwBaseStation_cfg = {

/*.fine_timer_interval =*/10,// ms -- NOTE: this is bogus, fine timer always ticks off ~78 times per second

/*.default_adv =*/NO_DISCOVERABLE,

/*.button_adv_toggle =*/0, // pairing button make adv toggle (if 1) or always on (if 0)

/*.high_undirect_adv_interval =*/32,   // slots

/*.low_undirect_adv_interval =*/2048, // slots

/*.high_undirect_adv_duration =*/300,   // seconds

/*.low_undirect_adv_duration =*/300,   // seconds

/*.high_direct_adv_interval =*/32,   // seconds

/*.low_direct_adv_interval =*/2048,   // seconds

/*.high_direct_adv_duration =*/300,   // seconds

/*.low_direct_adv_duration =*/300,   // seconds

/*.local_name =*/"TRANSMITTER", // char, maximum length is LOCAL_NAME_LEN_MAX

/*.cod =*/"\x00\x00\x00", // char, Class of Device string, max len is COD_LEN, used mostly by Windows for device icon

/*.ver =*/"0.20", // char, version string, max length is VERSION_LEN.

/*.encr_required =*/0, // (SECURITY_ENABLED | SECURITY_REQUEST),

/*.disc_required =*/0,   // actions on disconnection

/*.test_enable =*/0,   // TEST MODE is enabled when 1

/*.tx_power_level =*/0x04, // dbm

/*.con_idle_timeout =*/120,  // second 0-> no timeout

/*.powersave_timeout =*/0,   // second 0-> no timeout

/*.hdl =*/{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // [HANDLE_NUM_MAX];

/*.serv =*/{ 0x00, 0x00, 0x00, 0x00, 0x00 },

/*.cha =*/{ 0x00, 0x00, 0x00, 0x00, 0x00 },

/*.findme_locator_enable =*/0, // if 1 Find me locator is enable

/*.findme_alert_level =*/0,   // alert level of find me

/*.client_grouptype_enable =*/1, // if 1 grouptype read can be used

/*.linkloss_button_enable =*/0, // if 1 linkloss button is enable

/*.pathloss_check_interval =*/0,   // second

/*.alert_interval =*/0,   // interval of alert

/*.high_alert_num =*/0, // number of alert for each interval

/*.mild_alert_num =*/0, // number of alert for each interval

/*.status_led_enable =*/0,   // if 1 status LED is enable

/*.status_led_interval =*/0,   // second

/*.status_led_con_blink =*/0,   // blink num of connection

/*.status_led_dir_adv_blink =*/0,   // blink num of dir adv

/*.status_led_un_adv_blink =*/0,   // blink num of undir adv

/*.led_on_ms =*/0,   // led blink on duration in ms

/*.led_off_ms =*/0,  // led blink off duration in ms

/*.buz_on_ms =*/0,  // buzzer on duration in ms

/*.button_power_timeout =*/0,   // seconds

/*.button_client_timeout =*/1,   // seconds

/*.button_discover_timeout =*/3,   // seconds

/*.button_filter_timeout =*/10,   // seconds

};

//We want to store the ASCII representation of our transmitter's bluetooth address into the advertisement's .local_name

0 Likes
1 Solution

Be careful with this approach:

1. typically the BLE_PROFILE_CFG variable is const so you would get a compiler warning if you modify it

2. if you modify it within APPLICATION_INIT() then the result of emconinfo_getAddr() is undefined. So you should modify the local_name somewhere else in the code (maybe from within the yourappname_create() function)

Note that address returned by emconinfo_getAddr() is reversed with least significant byte located in offset 0.

Here is a code snippet which would change the local name bluetooth address and updates the local name in the scan result:

#include "emconinfo.h"

static char Bin2Hex(UINT8 inBin)

{

  if (inBin < 10)

       return '0' + inBin;

  else

       return 'A' + inBin - 10;

}

static void FillNameWithMACAddress(char *ioName)

{

  UINT8 *macAddr = emconinfo_getAddr();

  int  i;

  int  len = 0;

  for (i=0;i<6;i++)

  {

       ioName[len++] = Bin2Hex(macAddr >> 4);

       ioName[len++] = Bin2Hex(macAddr & 0x0F);

  }

  ioName[len++] = 0;

}

Later on in your create() function you would call the code like this:

  // -------------------

  // Scan Response Data

  // -------------------

  BLE_ADV_FIELD scanRspData[1];

  FillNameWithMACAddress(bleprofile_p_cfg->local_name);

  ble_trace0("the new local_name is now:");

  ble_trace0(bleprofile_p_cfg->local_name);

  // name

  scanRspData[0].len   = strlen(bleprofile_p_cfg->local_name) + 1;

  scanRspData[0].val   = ADV_LOCAL_NAME_COMP;

  memcpy(scanRspData[0].data, bleprofile_p_cfg->local_name, scanRspData[0].len - 1);

  bleprofile_GenerateScanRspData(scanRspData, 1);

I hope this helps.

View solution in original post

2 Replies
ArvindS_76
Employee
Employee
500 likes received 250 likes received 100 likes received

Get the local address using the method described in Re: How can my application discover my own MAC address?Convert this to ASCII and since you have access to this structure in your app, memcpy the string into the local_name member.

0 Likes

Be careful with this approach:

1. typically the BLE_PROFILE_CFG variable is const so you would get a compiler warning if you modify it

2. if you modify it within APPLICATION_INIT() then the result of emconinfo_getAddr() is undefined. So you should modify the local_name somewhere else in the code (maybe from within the yourappname_create() function)

Note that address returned by emconinfo_getAddr() is reversed with least significant byte located in offset 0.

Here is a code snippet which would change the local name bluetooth address and updates the local name in the scan result:

#include "emconinfo.h"

static char Bin2Hex(UINT8 inBin)

{

  if (inBin < 10)

       return '0' + inBin;

  else

       return 'A' + inBin - 10;

}

static void FillNameWithMACAddress(char *ioName)

{

  UINT8 *macAddr = emconinfo_getAddr();

  int  i;

  int  len = 0;

  for (i=0;i<6;i++)

  {

       ioName[len++] = Bin2Hex(macAddr >> 4);

       ioName[len++] = Bin2Hex(macAddr & 0x0F);

  }

  ioName[len++] = 0;

}

Later on in your create() function you would call the code like this:

  // -------------------

  // Scan Response Data

  // -------------------

  BLE_ADV_FIELD scanRspData[1];

  FillNameWithMACAddress(bleprofile_p_cfg->local_name);

  ble_trace0("the new local_name is now:");

  ble_trace0(bleprofile_p_cfg->local_name);

  // name

  scanRspData[0].len   = strlen(bleprofile_p_cfg->local_name) + 1;

  scanRspData[0].val   = ADV_LOCAL_NAME_COMP;

  memcpy(scanRspData[0].data, bleprofile_p_cfg->local_name, scanRspData[0].len - 1);

  bleprofile_GenerateScanRspData(scanRspData, 1);

I hope this helps.