Hi there,
I'm confused with the meaning of the 'vloc' variable in the attribute meta data. In the example code ble_bps.c of "ble_app_bps_pca10040_s132" , in the function bps_measurement_char_add(), as below:
/**@brief Function for adding Blood Pressure Measurement characteristics.
*
* @param[in] p_bps Blood Pressure Service structure.
* @param[in] p_bps_init Information needed to initialize the service.
*
* @return NRF_SUCCESS on success, otherwise an error code.
*/
static uint32_t bps_measurement_char_add(ble_bps_t * p_bps, ble_bps_init_t const * p_bps_init)
{
ble_gatts_char_md_t char_md;
ble_gatts_attr_md_t cccd_md;
ble_gatts_attr_t attr_char_value;
ble_uuid_t ble_uuid;
ble_gatts_attr_md_t attr_md;
ble_bps_meas_t initial_bpm;
uint8_t encoded_bpm[MAX_BPM_LEN];
memset(&cccd_md, 0, sizeof(cccd_md));
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm);
cccd_md.vloc = BLE_GATTS_VLOC_STACK;
cccd_md.write_perm = p_bps_init->bps_meas_attr_md.cccd_write_perm;
memset(&char_md, 0, sizeof(char_md));
char_md.char_props.indicate = 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 = &cccd_md;
char_md.p_sccd_md = NULL;
BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_BLOOD_PRESSURE_MEASUREMENT_CHAR);
memset(&attr_md, 0, sizeof(attr_md));
attr_md.vloc = BLE_GATTS_VLOC_STACK;
attr_md.read_perm = p_bps_init->bps_meas_attr_md.read_perm;
attr_md.write_perm = p_bps_init->bps_meas_attr_md.write_perm;
attr_md.rd_auth = 0;
attr_md.wr_auth = 0;
attr_md.vlen = 1;
memset(&attr_char_value, 0, sizeof(attr_char_value));
memset(&initial_bpm, 0, sizeof(initial_bpm));
attr_char_value.p_uuid = &ble_uuid;
attr_char_value.p_attr_md = &attr_md;
attr_char_value.init_len = bps_measurement_encode(p_bps, &initial_bpm, encoded_bpm);
attr_char_value.init_offs = 0;
attr_char_value.max_len = MAX_BPM_LEN;
attr_char_value.p_value = encoded_bpm;
return sd_ble_gatts_characteristic_add(p_bps->service_handle,
&char_md,
&attr_char_value,
&p_bps->meas_handles);
}
in the comments of its definition it says 'vloc' is "Value location", in this code, the attribute value is apparently in the user memory ( encoded_bpm[] ), then why the 'vloc' is set to BLE_GATTS_VLOC_STACK ?
Thank you for any comments.