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

Advertising problem after changing UUID.

Hello .

I want send BLE data of sensor value.

So, I am using the central module(HM-10) And peripheral is nRF52832 of custom module.

Connection and data communication with the smartphone are good, but communication between modules is not possible.

I changed UUID of nRF52 by below.

#define BLE_UUID_NUS_SERVICE 0xFFE0 /**< The UUID of the Nordic UART Service. */

#define OPCODE_LENGTH 1
#define HANDLE_LENGTH 2

.

.

#define BLE_UUID_NUS_TX_CHARACTERISTIC 0xFFE1 /**< The UUID of the TX Characteristic. */

#define BLE_NUS_MAX_RX_CHAR_LEN BLE_NUS_MAX_DATA_LEN /**< Maximum length of the RX Characteristic (in bytes). */
#define BLE_NUS_MAX_TX_CHAR_LEN BLE_NUS_MAX_DATA_LEN /**< Maximum length of the TX Characteristic (in bytes). */


#define NUS_BASE_UUID {{0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}} /**< Used vendor specific UUID. */

.

.


uint32_t ble_nus_init(ble_nus_t * p_nus, ble_nus_init_t const * p_nus_init)
{
ret_code_t err_code;
ble_uuid_t ble_uuid;
ble_uuid128_t nus_base_uuid = NUS_BASE_UUID;
ble_add_char_params_t add_char_params;

VERIFY_PARAM_NOT_NULL(p_nus);
VERIFY_PARAM_NOT_NULL(p_nus_init);

// Initialize the service structure.
p_nus->data_handler = p_nus_init->data_handler;

/**@snippet [Adding proprietary Service to the SoftDevice] */
// Add a custom base UUID.
err_code = sd_ble_uuid_vs_add(&nus_base_uuid, &p_nus->uuid_type);
VERIFY_SUCCESS(err_code);

ble_uuid.type = p_nus->uuid_type;
ble_uuid.uuid = BLE_UUID_NUS_SERVICE;

// Add the service.
err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
&ble_uuid,
&p_nus->service_handle);
/**@snippet [Adding proprietary Service to the SoftDevice] */
VERIFY_SUCCESS(err_code);


// Add the TX Characteristic.
/**@snippet [Adding proprietary characteristic to the SoftDevice] */
memset(&add_char_params, 0, sizeof(add_char_params));
add_char_params.uuid = BLE_UUID_NUS_TX_CHARACTERISTIC;
add_char_params.uuid_type = p_nus->uuid_type;
add_char_params.max_len = BLE_NUS_MAX_TX_CHAR_LEN;
add_char_params.init_len = sizeof(uint8_t);
add_char_params.is_var_len = true;
add_char_params.char_props.notify = 1;
add_char_params.char_props.write = 1;
add_char_params.char_props.indicate = 1;
add_char_params.char_props.read = 1;
add_char_params.char_props.write_wo_resp = 1;

add_char_params.read_access = SEC_OPEN;
add_char_params.write_access = SEC_OPEN;
add_char_params.cccd_write_access = SEC_OPEN;

return characteristic_add(p_nus->service_handle, &add_char_params, &p_nus->tx_handles);
/**@snippet [Adding proprietary characteristic to the SoftDevice] */
}

.

.However, By changing the UUID, advertising does not work and communication does not work.

The advertising side is as follows.

//Advertising initialization function
//structure
static ble_advertising_init_t adv_params;
static ble_uuid_t uuids[1];
memset(&adv_params, 0, sizeof(adv_params));

//advertising data packet setting
int8_t tx_power = 4;
adv_params.advdata.name_type = BLE_ADVDATA_FULL_NAME;
adv_params.advdata.include_appearance = false;
adv_params.advdata.p_tx_power_level = &tx_power;
adv_params.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;

//Scan Response Data Setting
//UUID setting
uuids[0].type = BLE_UUID_TYPE_VENDOR_BEGIN;
uuids[0].uuid = BLE_UUID_NUS_SERVICE;
adv_params.srdata.uuids_complete.uuid_cnt = 1;
adv_params.srdata.uuids_complete.p_uuids = uuids;

//Advertising parameters setting about connection
adv_params.config.ble_adv_whitelist_enabled = true;
adv_params.config.ble_adv_fast_enabled = true;
adv_params.config.ble_adv_fast_interval = 64;
adv_params.config.ble_adv_fast_timeout = 12000;
adv_params.evt_handler = on_adv_evt;

//Advertising initialization
err_code = ble_advertising_init(&advertising, &adv_params);

//connection setting renewal
ble_advertising_conn_cfg_tag_set(&advertising, CONN_CFG_TAG);

I'm not sure where the problem is. Where should I fix it?

I would appreciate it if you check.

Thank you.

Regards.

Parents
  • Hi.

    Have you tried debugging the device to see if you get any error codes or similar?

  • Hi, Thank you for reply.

    Yes, I did try to debugging and nothing error.

    Currently, I found modify the UUID. However, I didn't find that exactly matching method between HM-10 and nRF52832,yet.

    Can i get the more information?

    Regards.

  • Did you remember to change the UUID on both the central and the peripheral as well?

  • I don't know what the question means exactly, but the nRF52832 uses central mode and only modified the code of nRF52832.

    The code was roughly modified as follows.

    Where should I modify it?

    //ble_nus.c file------------------------------------
    
    #define NUS_BASE_UUID                  {{0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x00, 0x00, 0x40, 0x6E}}
    #define NUS_BASE_UUID_HM                  {{0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}} /**< Used vendor specific UUID. */
    .
    .
    .
    uint32_t ble_nus_init(ble_nus_t * p_nus, ble_nus_init_t const * p_nus_init)
    {
        ret_code_t            err_code;
        ble_uuid_t            ble_uuid;
        ble_uuid128_t         nus_base_uuid = NUS_BASE_UUID;
        ble_uuid128_t         nus_base_uuidHm10 = NUS_BASE_UUID_HM;
        ble_add_char_params_t add_char_params;
    
        VERIFY_PARAM_NOT_NULL(p_nus);
        VERIFY_PARAM_NOT_NULL(p_nus_init);
    
        // Initialize the service structure.
        p_nus->data_handler = p_nus_init->data_handler;
    
        /**@snippet [Adding proprietary Service to the SoftDevice] */
        // Add a custom base UUID.
        err_code = sd_ble_uuid_vs_add(&nus_base_uuid, &p_nus->uuid_type);
        VERIFY_SUCCESS(err_code);
    
        ble_uuid.type = p_nus->uuid_type;
        ble_uuid.uuid = BLE_UUID_NUS_SERVICE;
    
        // Add the service.
        err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_SECONDARY,
                                            &ble_uuid,
                                            &p_nus->service_handle);
        /**@snippet [Adding proprietary Service to the SoftDevice] */
        VERIFY_SUCCESS(err_code);
    
    
        err_code = sd_ble_uuid_vs_add(&nus_base_uuidHm10, &p_nus->uuid_type);
        VERIFY_SUCCESS(err_code);
    
        ble_uuid.type = p_nus->uuid_type;
        ble_uuid.uuid = BLE_UUID_NUS_SERVICE;
    
        // Add the service.
        err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
                                            &ble_uuid,
                                            &p_nus->service_handle);
        /**@snippet [Adding proprietary Service to the SoftDevice] */
        VERIFY_SUCCESS(err_code);
    
    
        // Add the TX Characteristic.
        /**@snippet [Adding proprietary characteristic to the SoftDevice] */
        memset(&add_char_params, 0, sizeof(add_char_params));
        add_char_params.uuid              = BLE_UUID_NUS_TX_CHARACTERISTIC;
        add_char_params.uuid_type         = p_nus->uuid_type;
        add_char_params.max_len           = BLE_NUS_MAX_TX_CHAR_LEN;
        add_char_params.init_len          = sizeof(uint8_t);
        add_char_params.is_var_len        = true;
        add_char_params.char_props.notify = 1;
        add_char_params.char_props.write  = 1;
        add_char_params.char_props.indicate  = 1;
        add_char_params.char_props.read  = 1;
        add_char_params.char_props.write_wo_resp  = 1;
    
        add_char_params.read_access       = SEC_OPEN;
        add_char_params.write_access      = SEC_OPEN;
        add_char_params.cccd_write_access = SEC_OPEN;
    
        return characteristic_add(p_nus->service_handle, &add_char_params, &p_nus->tx_handles);
       /**@snippet [Adding proprietary characteristic to the SoftDevice] */
    }
    
    
    //Main setting------------------------------------
      //Scan Response Data Setting
      //UUID setting
      uuids[0].type = BLE_UUID_TYPE_VENDOR_BEGIN;
      uuids[0].uuid = BLE_UUID_NUS_SERVICE;
      adv_params.srdata.uuids_complete.uuid_cnt = 1;
      adv_params.srdata.uuids_complete.p_uuids = uuids;
      
      

    Thank you.

    Regards.

  • What I meant was that you will probably need to change the UUID on both the peripheral and the central here, depending on what changes you have made to the example.

    In the BLE UART examples, the central will scan with a UUID filter. The central will connect to the peripheral with the matching UUID. If you change the UUID on the peripheral, you will have to change it on the central device as well.

    Br,
    Joakim

Reply
  • What I meant was that you will probably need to change the UUID on both the peripheral and the central here, depending on what changes you have made to the example.

    In the BLE UART examples, the central will scan with a UUID filter. The central will connect to the peripheral with the matching UUID. If you change the UUID on the peripheral, you will have to change it on the central device as well.

    Br,
    Joakim

Children
No Data
Related