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

Long write error, GATT INVALID ATTR LEN

Good evening,

I am trying to implement queued write (long write) into ble_app_uart example. I am using s110_v7.1, nrf51822(pca10028), can not find version of sdk it is one of the older ones, probably sdk6.

This is how BLE events ar handled:

 case BLE_EVT_USER_MEM_REQUEST:
        
        mem_block.len = QUEUED_WRITE_BUFFER_SIZE;
        mem_block.p_mem = &queued_write_buffer[0];
        err_code = sd_ble_user_mem_reply(m_conn_handle, &mem_block);
					//simple_uart_putstring("User mem request \r\n");
						if (err_code != NRF_SUCCESS)
						{
							sprintf((char*)debug_string11,"ERROR USER_MEM_REQ\r\n");
							simple_uart_putstring(debug_string11);
						}
						else
						{
							sprintf((char*)debug_string11,"USER_MEM_REQUEST OK\r\n");
							simple_uart_putstring(debug_string11);
						}
        break;
			
     case BLE_EVT_USER_MEM_RELEASE:
					
        if ((p_ble_evt->evt.common_evt.params.user_mem_release.mem_block.p_mem == mem_block.p_mem)&&(p_ble_evt->evt.common_evt.params.user_mem_release.mem_block.len == mem_block.len))
        {
            //memory released do nothing. 
							//simple_uart_putstring("User mem released \r\n");
						sprintf((char*)debug_string13,"USER_MEM_REQUEST OK\r\n");
						simple_uart_putstring(debug_string13);
        }
					break;
					
   case BLE_GATTS_EVT_WRITE:
							//simple_uart_putstring("Evt Write \r\n");
			sprintf((char*)debug_string10,"BLE_GATTS_EVT_WRITE\r\n");
								simple_uart_putstring(debug_string10);
        break;

These are passed to the events:

#define QUEUED_WRITE_BUFFER_SIZE        350
static uint8_t queued_write_buffer[QUEUED_WRITE_BUFFER_SIZE];
static ble_user_mem_block_t mem_block;

This is what I receive in nrf sniffer:

image description

This is from nrf connect app in my tablet:

image description

Could not find what is the problem of error in dev zone, nor in the net. If there is lack of information let me know. Thank you.

-------------------------------------------------------UPDATE-----------------------------------------

Have found that I havent changed where I am puttin characteristics in tx_char_add and rx_char_add. I have them changed to:

//MODIFIED************************************************************************
attr_md.vloc              = BLE_GATTS_VLOC_USER;//BLE_GATTS_VLOC_STACK;
//********************************************************************************

//MODIFIED************************************************************************
   attr_char_value.max_len   = QUEUED_WRITE_BUFFER_SIZE;//BLE_NUS_MAX_RX_CHAR_LEN
 //********************************************************************************

Now I see that characteristics <20 and >20 size of bytes are sent without error. Unfortunately, if I receive something from pca10028 tablet do not recognise symbols. In addition to this, in nus service I have made that every received characteristic will be replied with somekind of response. Right now I do not receive any response from pca10028 if received characteristic exceeds 20 bytes. here are screenshot of tablet:

image description

this is my logg in UART:

image description

sniff of long write: was it successful???

image description

what are your oppinions why I do I receive those "? ? ? ?" instead of my reply? why I do not receive response in table exceeding 20 bytes?

Parents
  • You should know which SoftDevice and SDK version you are using, please try to find out.

    Ok. So if I understand you correctly. The first problem you need to solve is how nus_data_handler() will handle the long write, it was not written to handle long writes so you have to modify it. Have you done any modifications?

    In S110 it is not possible to send notifications longer than 20 bytes.

Reply
  • You should know which SoftDevice and SDK version you are using, please try to find out.

    Ok. So if I understand you correctly. The first problem you need to solve is how nus_data_handler() will handle the long write, it was not written to handle long writes so you have to modify it. Have you done any modifications?

    In S110 it is not possible to send notifications longer than 20 bytes.

Children
No Data
Related