cancel
Showing results for 
Search instead for 
Did you mean: 

I am using STEVAL_MKSBOX1V1 and I am trying to advertise my sensor value. Can some one guide me on this.

Snara.21
Senior

I shall see the Ibeacon details in my phone but unable to change the service UUID. If I change and compile it, the changes are not reflected in the Smartphone.

void Device_Init(void) {

uint8_t ret;

uint16_t service_handle;

uint16_t dev_name_char_handle;

uint16_t appearance_char_handle;

/* Set the TX Power to -2 dBm */

ret = aci_hal_set_tx_power_level(1, 4);

if (ret != 0) {

prnt("Error in aci_hal_set_tx_power_level() 0x%04xr\n");//, ret);

while (1)

;

}

/* Init the GATT */

ret = aci_gatt_init();

if (ret != 0)

prnt("Error in aci_gatt_init() 0x%04xr\n");//, ret);

else

prnt("aci_gatt_init() --> SUCCESS\r\n");

/* Init the GAP */

ret = aci_gap_init(0x01, 0x00, 0x08, &service_handle, &dev_name_char_handle, &appearance_char_handle);

if (ret != 0)

prnt("Error in aci_gap_init() 0x%04x\r\n");//, ret);

else

prnt("aci_gap_init() --> SUCCESS\r\n");

}

 void Start_Beaconing(void) {

uint8_t ret = BLE_STATUS_SUCCESS;

#if ENABLE_FLAGS_AD_TYPE_AT_BEGINNING

/* Set AD Type Flags at beginning on Advertising packet */

uint8_t adv_data[] = {

/* Advertising data: Flags AD Type */

0x02, 0x01, 0x06,

/* Advertising data: manufacturer specific data */

26, //len

AD_TYPE_MANUFACTURER_SPECIFIC_DATA, //manufacturer type

0x30, 0x00, //Company identifier code (Default is 0x0030 - STMicroelectronics: To be customized for specific identifier)

0x06,    // ID

0x15,    //Length of the remaining payload

0xE2, 0x0A, 0x39, 0xF4, 0x73, 0xF5, 0x4B, 0xC4, //Location UUID

0xB1, 0x2F, 0x17, 0xD1, 0xBD, 0x07, 0xb9, 0x61, 0x00, 0x00, // Major number

0x00, 0x00, // Minor number

0xC8    //2's complement of the Tx power (-56dB)};

};

#else

uint8_t manuf_data[] = {

26, //len

AD_TYPE_MANUFACTURER_SPECIFIC_DATA,//manufacturer type

0x30, 0x00,//Company identifier code (Default is 0x0030 - STMicroelectronics: To be customized for specific identifier)

0x06,// ID

0x15,//Length of the remaining payload

0xE2, 0x0A, 0x39, 0xF4, 0x73, 0xF5, 0x4B, 0xC4,//Location UUID

//0xA1, 0x2F, 0x17, 0xD1, 0xAD, 0x07, 0xA9, 0x61,

0xB1, 0x2F, 0x17, 0xD1, 0xBD, 0x07, 0xb9, 0x61, 0x00, 0x00, // Major number

0x00, 0x00,// Major number

0x00, 0x00,// Minor number

0xC8//2's complement of the Tx power (-56dB)};

};

#endif

/* disable scan response */

ret = hci_le_set_scan_response_data(0, NULL);

if (ret != BLE_STATUS_SUCCESS) {

prnt("Error in hci_le_set_scan_resp_data() 0x%04x\r\n");//, ret);

return;

} else

prnt("hci_le_set_scan_resp_data() --> SUCCESS\r\n");

/* put device in non connectable mode */

ret = aci_gap_set_discoverable(ADV_NONCONN_IND, 160, 160, PUBLIC_ADDR, NO_WHITE_LIST_USE, 0, NULL, 0, NULL, 0, 0);

if (ret != BLE_STATUS_SUCCESS) {

prnt("Error in aci_gap_set_discoverable() 0x%04x\r\n");//, ret);

return;

} else

prnt("aci_gap_set_discoverable() --> SUCCESS\r\n");

#if ENABLE_FLAGS_AD_TYPE_AT_BEGINNING

/* Set the ADV data with the Flags AD Type at beginning of the

advertsing packet, followed by the beacon manufacturer specific data */

ret = hci_le_set_advertising_data(sizeof(adv_data), adv_data);

if (ret != BLE_STATUS_SUCCESS) {

prnt("Error in hci_le_set_advertising_data() 0x%04x\r\n");//, ret);

return;

} else

prnt("hci_le_set_advertising_data() --> SUCCESS\r\n");

#else

/* Delete the TX power level information */

ret = aci_gap_delete_ad_type(AD_TYPE_TX_POWER_LEVEL);

if (ret != BLE_STATUS_SUCCESS)

{

prnt ("Error in aci_gap_delete_ad_type() 0x%04x\r\n");//, ret);

return;

}

else

prnt ("aci_gap_delete_ad_type() --> SUCCESS\r\n");

/* Update the ADV data with the BEACON manufacturing data */

ret = aci_gap_update_adv_data(27, manuf_data);

if (ret != BLE_STATUS_SUCCESS)

{

prnt ("Error in aci_gap_update_adv_data() 0x%04x\r\n");//, ret);

return;

}

else

prnt ("aci_gap_update_adv_data() --> SUCCESS\r\n");

#endif

}

1 REPLY 1
niccolò
ST Employee

Hi @Snara.2​ ,

let me ask you some question to better understand the situation:

what fw are you starting from?

what did you change?

I don't see the new service UUID in the code, did you add it somewhere else?

what app are you using on the phone?

Niccolò