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

Can only write two bytes when length says 7 bytes

I'm trying to write 7 bytes (0x01 02 03 04 05 06 07) to my nrf51 Dongle with my own custom service running based on the Battery Service.

The problem is that I can only access the first two bytes 0x01 and 0x02 in the memory. But the length when I read p_evt_write->len is 7. I can read all the 7 bytes of my characteristic but I cannot write 7 bytes.

Is their maybe a MAX WRITE LENGTH I forgot?

This is my on_write function:

static void on_write(ble_sens_t * p_sens, ble_evt_t * p_ble_evt)
{		
   ble_gatts_evt_write_t * p_evt_write = &p_ble_evt->evt.gatts_evt.params.write;   

    if ((p_evt_write->handle == p_sens->config_handle.value_handle) && (p_sens->evt_handler != NULL))
    {
        p_sens->evt_handler(p_sens, *p_evt_write);
    }
}

This is my write handler: I already tried doing it with pointers and so on with the info from the other questions around this topic.

	 else if (p_evt_write.handle == p_sens->config_handle.value_handle && p_evt_write.len == 7)
   {		 
			m_config.toggle_settings = p_evt_write.data[0];
		 	m_config.seconds = p_evt_write.data[1];
		 	m_config.minutes = p_evt_write.data[2];
		 	m_config.hours = p_evt_write.data[3];
		 	m_config.day = p_evt_write.data[4];
		 	m_config.month = p_evt_write.data[5];
		 	m_config.year = p_evt_write.data[6];		 
	 }	

Thank you!

Parents
  • p_evt_write in on_write() is already pointer and you are passing pointer of the pointer to p_sens->evt_handler(). It is difficult to see from second part of the code how p_evt_write defined. If you call p_sens->evt_handler(p_sens, p_evt_write); without *, then inside the handler data can be accessible p_evt_write->data[0] but need to define p_evt_write correctly as well

Reply
  • p_evt_write in on_write() is already pointer and you are passing pointer of the pointer to p_sens->evt_handler(). It is difficult to see from second part of the code how p_evt_write defined. If you call p_sens->evt_handler(p_sens, p_evt_write); without *, then inside the handler data can be accessible p_evt_write->data[0] but need to define p_evt_write correctly as well

Children
No Data
Related