ASF Bluetooth Low Energy (BLE) API - Issue with Get/Set Characteristic

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

 

I am currently using ASF version 3.29 with Atmel Studio 7. I'm working with the BLE API on a SAML21 Xplained Pro with a BTLC1000 add-on card. The BTLC1000 hardware has been modified for the chip enable workaround described in the user guide. I've got two sets of hardware with one executing as a peripheral device and the other as a central device. I've been able to establish a connection between the devices, and the central device is able to discover services and characteristics managed by the peripheral device. However, when I use the API calls for getting and setting the characteristic values I run into a few different issues.

 

When I call at_ble_characteristic_value_get() or at_ble_characteristic_value_set() from the central device after discovering a characteristic, I receive a hardware fault interrupt:

case AT_BLE_CHARACTERISTIC_FOUND:
{
    uint8_t value = 0;
    uint16_t length = 1;
    at_ble_characteristic_found_t* characteristic = (at_ble_characteristic_found_t*)params;
    at_ble_characteristic_value_get(characteristic->value_handle, &value, &length);
}

When I call at_ble_characteristic_value_set() from the peripheral device using the handle obtained from calling at_ble_primary_service_define(), the program hangs in a while loop inside serial_drv.c (see while(ble_txbyte_count) below).

uint16_t serial_drv_send(uint8_t* data, uint16_t len)
{
  system_interrupt_enter_critical_section();
  ble_txbuf_ptr = data;
  ble_txbyte_count = len;
  system_interrupt_leave_critical_section();

  if(ble_txbyte_count)
  {
	  g_txdata = *ble_txbuf_ptr;
	  while(STATUS_OK != usart_write_job(&usart_instance, &g_txdata));
	  if(--ble_txbyte_count)
	  {
		  ++ble_txbuf_ptr;
	  }
  }
  /* Wait for ongoing transmission complete */
  while(ble_txbyte_count);
  return STATUS_OK;
}

 

Any help is much appreciated. 

 

This topic has a solution.

Last Edited: Tue. Jan 19, 2016 - 07:37 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've manged to solve the issue when calling at_ble_characteristic_value_set() from the peripheral device (server). I was making the call from a timer interrupt handler. The solution was to call at_ble_event_user_defined_post() instead to create my own event. Then inside my switch for handling events returned by at_ble_event_get() in my main loop, I made the call to at_ble_characteristic_value_set().

 

Update: I've also solved the issue when calling at_ble_characteristic_value_set() and at_ble_characteristic_value_get() from the central device (client). These API calls must only be for getting and setting characteristic values on the server. To access the characteristics from the client side, I used at_ble_characteristic_write() and at_ble_characteristic_read().

Last Edited: Tue. Jan 19, 2016 - 07:37 PM