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

How could Nordic received large byte from phone

Hi there,

How could I receive a large data from phone, example 120 bytes from a characteristic. So far I was able to receive 20 bytes.

From the working code of 20 bytes, I modified it so that it would receive a maximum data of sizeof(uint8_t) and change the location from stack to user(BLE_GATTS_VLOC_USER) but its not working. It seems that i haven't receive anything from the BLE GATT WRITE EVENT.

If Characteristic wont able to received a large amount of data, will you please tell me on how to transfer a large amount of data to Nordic.

I am using S310 softdevice and nRF51422 chip. Thanks

below is my code.

static uint32_t add_char_command_type(ble_myplbs * p_lbs, const ble_lbs_init_t * p_lbs_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.p_char_user_desc = (uint8_t *)CHAR_NAME_COMMAND_TYPE;
char_md.char_user_desc_max_size = 12;
char_md.char_user_desc_size = 12;
	
char_md.char_props.read   = 1; 
char_md.char_props.write  = 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_lbs->uuid_type;
ble_uuid.uuid = SAL_UUID_CHAR_COMMAND_TYPE;

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       = 0;

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

attr_char_value.p_uuid       = &ble_uuid;
attr_char_value.p_attr_md    = &attr_md;
attr_char_value.init_len     = sizeof(uint8_t); 
attr_char_value.init_offs    = 0;
attr_char_value.max_len      = sizeof(uint8_t); 
attr_char_value.p_value      = ble_buffer_write; 

return sd_ble_gatts_characteristic_add(p_lbs->service_handle, &char_md,
                                           &attr_char_value,
                                           &p_lbs->command_type_char_handle);
Parents
  • You can use long writes to write to characteristics that are larger than 20 bytes, please see this post and the documentation of sd_ble_gattc_write

    This Message Sequence Chart(MSG) may also be helpful.

    -Bjørn

    UPDATE:

    Modified version of SDK v9.0 where the ble_app_hrs example has been modified to support long writes to the heart rate measurement characteristic.

    nRF51_SDK_v9_0.zip

  • Hi Bjorn,

    Thank you for following me.

    In this stage, I want to read the 120 bytes that the phone or the MCP for windows writes to the Nordic chip. After I press the Write long from MCP I receive the BLE_EVT_USER_MEM_REQUEST and the BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST. Till then, I don't know where to place the sd_ble_gattc_read().

    I tried to place it on the BLE_GATTS_OP_PREP_WRITE_REQ and/or the BLE_GATTS_OP_EXEC_WRITE_REQ_NOW under the BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST and MCP will terminate because of BTLE_CONNECTION_TIMEOUT.

    Will you please elaborate further on of how I get the data using as what you suggested.

    Thanks, -mc

Reply
  • Hi Bjorn,

    Thank you for following me.

    In this stage, I want to read the 120 bytes that the phone or the MCP for windows writes to the Nordic chip. After I press the Write long from MCP I receive the BLE_EVT_USER_MEM_REQUEST and the BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST. Till then, I don't know where to place the sd_ble_gattc_read().

    I tried to place it on the BLE_GATTS_OP_PREP_WRITE_REQ and/or the BLE_GATTS_OP_EXEC_WRITE_REQ_NOW under the BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST and MCP will terminate because of BTLE_CONNECTION_TIMEOUT.

    Will you please elaborate further on of how I get the data using as what you suggested.

    Thanks, -mc

Children
No Data
Related