sdk/modules/bluetooth/bluetooth_le_gatt.c
/****************************************************************************
 * Name: ble_characteristic_notify
 *
 * Description:
 *   BLE Notify Characteristic value
 *   Notify characteristic value to Central (For Peripheral role)
 *
 ****************************************************************************/
ble_characteristic_notify
Description:
BLE Notify Characteristic value
Notify characteristic value to Central (For Peripheral role)
ble_characteristic_notify Description : BLE Notify Characteristic value Notify characteristic value to Central ( For Peripheral role )
int ble_characteristic_notify(struct ble_gatt_char_s *charc, uint8_t *data, int len)
{
  int ret = BT_SUCCESS;
  struct ble_hal_gatt_ops_s *ble_hal_gatt_ops = g_ble_gatt_state.ble_hal_gatt_ops;
  BLE_CHAR_VALUE *value;
  if (!charc)
    {
      _err("%s [BLE][GATT] BLE notify failed(characteristic not created).\n", __func__);
      return BT_FAIL;
    }
  value = &charc->value;
  if (BLE_MAX_CHAR_SIZE <= len)
    {
      _err("%s [BLE][GATT] BLE notify failed(value size is too big).\n", __func__);
      return BT_FAIL;
    }
  if (ble_hal_gatt_ops && ble_hal_gatt_ops->notify)
    {
      memcpy(value->data, data, len);
      value->length = len;
      ret = ble_hal_gatt_ops->notify(charc, g_ble_gatt_state.ble_state->ble_connect_handle);
    }
  else
    {
      _err("%s [BLE][GATT] Notify failed(HAL not registered).\n", __func__);
      return BT_FAIL;
    }
  return ret;
}
int ble_characteristic_notify ( struct ble_gatt_char_s * charc , uint8_t * data , int len ) { int ret = BT_SUCCESS ; struct ble_hal_gatt_ops_s * ble_hal_gatt_ops = g_ble_gatt_state . ble_hal_gatt_ops ; BLE_CHAR_VALUE * value ; if ( ! charc ) { _err ( " \n " , __func__ ) ; return BT_FAIL ; } value = & charc -> value ; if ( BLE_MAX_CHAR_SIZE <= len ) { _err ( " \n " , __func__ ) ; return BT_FAIL ; } if ( ble_hal_gatt_ops && ble_hal_gatt_ops -> notify ) { memcpy ( value -> data , data , len ) ; value -> length = len ; ret = ble_hal_gatt_ops -> notify ( charc , g_ble_gatt_state . ble_state -> ble_connect_handle ) ; } else { _err ( " \n " , __func__ ) ; return BT_FAIL ; } return ret ; }
Name: ble_characteristic_notify
 Description:
   BLE Notify Characteristic value
   Notify characteristic value to Central (For Peripheral role)
Name : ble_characteristic_notify Description : BLE Notify Characteristic value Notify characteristic value to Central ( For Peripheral role )