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

Characteristic ASII format

I need to set HEX value (uint8_t value[7]            = {0x56,0x45,0x52,0x53,0x49,0x4F,0x4E};)  on my custom character to be read by my phone. but the value that is  displayed on my character is not HEX format. even when my phone try to read it as byte it is not the value what i set up on my character

.

static uint32_t rx_char_2_add(ble_nus_t * p_nus, const ble_nus_init_t * p_nus_init)
{
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_t    attr_char_value;
    ble_uuid_t          ble_uuid;
    ble_gatts_attr_md_t attr_md;

    memset(&char_md, 0, sizeof(char_md));

    char_md.char_props.read         = 1;
    char_md.p_char_user_desc         = NULL;
    char_md.p_char_pf                = NULL;
    char_md.p_user_desc_md           = NULL;
    char_md.p_cccd_md                = NULL;
    char_md.p_sccd_md                = NULL;

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

    memset(&attr_md, 0, sizeof(attr_md));

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm);

    attr_md.vloc    = BLE_GATTS_VLOC_USER;
    attr_md.rd_auth = 0;
    attr_md.wr_auth = 0;
    attr_md.vlen    = 1;

    memset(&attr_char_value, 0, sizeof(attr_char_value));

    uint8_t value[7]            = {0x56,0x45,0x52,0x53,0x49,0x4F,0x4E};
    attr_char_value.p_uuid    = &ble_uuid;
    attr_char_value.p_attr_md = &attr_md;
    attr_char_value.init_len  = 7;
    attr_char_value.init_offs = 0;
    attr_char_value.max_len   = BLE_NUS_MAX_RX_CHAR_LEN;
    attr_char_value.p_value   = value;

    return sd_ble_gatts_characteristic_add(p_nus->service_handle,
                                           &char_md,
                                           &attr_char_value,
                                           &p_nus->rx_2_handles);
}

/*--------------------------------------------------------------------------------------------*/

What is displayed on my custom character is 00 00 00 00 D7 7E 02:

so how can i make sure my custom character is displayed the exact bytes.

Parents Reply Children
No Data
Related