This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

beacon? Ble? Why do this connection?

According to the following sources.

advertising_init() -> advertising_update() -> advertising_update() -> ....

UUID, Mayjor, Minor is set in the advertising_init(). but UUID, Mayjor, Minor is deleted in the advertising_update()

so, I thought that this device will not connect. but device is connected with SmartPhone APP(Master control Panel)

I don't never understand this situation.

Why is that connection?

What is My device connected?

This is My Source. It is Beacon Source.


static void advertising_init(void){

uint32_t        err_code;
ble_advdata_t   advdata;
uint8_t         flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;

ble_advdata_manuf_data_t manuf_specific_data; 
manuf_specific_data.company_identifier = APP_COMPANY_IDENTIFIER;

#if defined(USE_UICR_FOR_MAJ_MIN_VALUES) 
// If USE_UICR_FOR_MAJ_MIN_VALUES is defined, the major and minor values will be read from the
// UICR instead of using the default values. The major and minor values obtained from the UICR
// are encoded into advertising data in big endian order (MSB First).
// To set the UICR used by this example to a desired value, write to the address 0x10001080
// using the nrfjprog tool. The command to be used is as follows.
// nrfjprog --snr <Segger-chip-Serial-Number> --memwr 0x10001080 --val <your major/minor value>
// For example, for a major value and minor value of 0xabcd and 0x0102 respectively, the
// the following command should be used.
// nrfjprog --snr <Segger-chip-Serial-Number> --memwr 0x10001080 --val 0xabcd0102
uint16_t major_value = ((*(uint32_t *)UICR_ADDRESS) & 0xFFFF0000) >> 16;
uint16_t minor_value = ((*(uint32_t *)UICR_ADDRESS) & 0x0000FFFF);

uint8_t index = MAJ_VAL_OFFSET_IN_BEACON_INFO;

m_beacon_info[index++] = MSB(major_value);
m_beacon_info[index++] = LSB(major_value);

m_beacon_info[index++] = MSB(minor_value);
m_beacon_info[index++] = LSB(minor_value);
#endif

manuf_specific_data.data.p_data        = (uint8_t *) m_beacon_info; 
manuf_specific_data.data.size          = APP_BEACON_INFO_LENGTH;

// Build and set advertising data.
memset(&advdata, 0, sizeof(advdata));

advdata.name_type               = BLE_ADVDATA_NO_NAME;
advdata.flags.size              = sizeof(flags);
advdata.flags.p_data            = &flags;
advdata.p_manuf_specific_data   = &manuf_specific_data;

err_code = ble_advdata_set(&advdata, NULL);
APP_ERROR_CHECK(err_code);

// Initialize advertising parameters (used when starting advertising).
memset(&m_adv_params, 0, sizeof(m_adv_params));

m_adv_params.type        = BLE_GAP_ADV_TYPE_ADV_NONCONN_IND;
m_adv_params.p_peer_addr = NULL;                             // Undirected advertisement.
m_adv_params.fp          = BLE_GAP_ADV_FP_ANY;
m_adv_params.interval    = NON_CONNECTABLE_ADV_INTERVAL;
m_adv_params.timeout     = APP_CFG_NON_CONN_ADV_TIMEOUT;     }

static void advdata_update(void){
uint32_t      err_code;
ble_advdata_t advdata;
uint8_t       flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;

ble_advdata_service_data_t service_data[2];

uint8_t battery_data = battery_level_get();

int8_t exponent = -2;
uint32_t Temp_Value = ((exponent & 0xFF) << 24) | (DTS_L300_V2_Get_Temp(0) & 0x00FFFFFF);

service_data[0].service_uuid = BLE_UUID_BATTERY_SERVICE;
service_data[0].data.size    = sizeof(battery_data);
service_data[0].data.p_data  = &battery_data;

service_data[1].service_uuid = BLE_UUID_HEALTH_THERMOMETER_SERVICE;
service_data[1].data.size = sizeof(Temp_Value);
service_data[1].data.p_data = (uint8_t *) &Temp_Value;


// Build and set advertising data
memset(&advdata, 0, sizeof(advdata));

advdata.name_type            = BLE_ADVDATA_FULL_NAME;
advdata.include_appearance   = false;
advdata.flags.size           = sizeof(flags);
advdata.flags.p_data         = &flags;
advdata.service_data_count   = 2;
advdata.p_service_data_array = service_data;


err_code = ble_advdata_set(&advdata, NULL);
APP_ERROR_CHECK(err_code);          }

void advdata_update_timer_timeout_handler(void * p_context)
 {
       advdata_update();
 }

#Edit 2015-04-27

If the above information as

Advertise data does not include the UUID, Minor, Major value.

image description

I posted a similar question several times.

So what I learned as follows.

Master Control Panel of Smart Phone App search the device address.

And nRF Device has unique device address.

This is why the search.

Related