mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 22:20:37 +00:00
ble/gatt-service: emit SCAN_INTERVAL_UPDATE event, add scan parameters service server to CHANGELOG
This commit is contained in:
parent
ffb44729e0
commit
89974af953
@ -20,8 +20,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
- hci_transport: add parity field and pass on to `btstack_uart_t` in h4 and h5
|
||||
- GATT Client: Battery Service Client
|
||||
- GATT Client: Device Information Service Client
|
||||
- GATT Client: Scan Parameters Service Client
|
||||
- GATT Client: HID-over-GATT (HOG) Client, Report and Boot Host
|
||||
- GATT Client: Scan Parameters Service Client
|
||||
- GATT Server: Scan Parameters Service Server
|
||||
- GAP: add `gap_set_page_scan_activity` and `gap_set_page_scan_type`
|
||||
- GAP: support sniff subrating with `gap_sniff_subrating_configure`
|
||||
- AVRCP: new field `button_pressed` in `AVRCP_SUBEVENT_OPERATION`
|
||||
|
@ -29,9 +29,9 @@ BTstack is free for non-commercial use. However, for commercial use, <a href="ma
|
||||
|
||||
**Profiles:** A2DP, AVRCP incl. Browsing, GAP, GATT, HFP, HID, HSP, IOP, SPP, PAN, PBAP Client.
|
||||
|
||||
**GATT Service Servers:** Battery, Cycling Power, Cycling Speed and Cadence, Device Information, Scan Parameters, Heart Rate, HID over GATT (HOG), Mesh Provisioning, Mesh Proxy, Nordic SPP, u-Blox SPP.
|
||||
**GATT Service Servers:** Battery, Cycling Power, Cycling Speed and Cadence, Device Information, Heart Rate, HID over GATT (HOG) Device, Mesh Provisioning, Mesh Proxy, Nordic SPP, Scan Parameters, u-Blox SPP.
|
||||
|
||||
**GATT Service Clients:**: Battery, Device Information, HID-over-GATT (HOG) Host
|
||||
**GATT Service Clients:**: Battery, Device Information, HID-over-GATT (HOG) Host, Scan Parameters.
|
||||
|
||||
GATT Services are in general easy to implement and require short development time. For more GATT Services please contact us, or follow the [implementation guidelines](https://bluekitchen-gmbh.com/btstack/profiles/#gatt-generic-attribute-profile).
|
||||
|
||||
|
@ -60,8 +60,6 @@ static btstack_packet_handler_t scan_parameters_packet_handler;
|
||||
static btstack_context_callback_registration_t scan_parameters_callback;
|
||||
static att_service_handler_t scan_parameters_service;
|
||||
|
||||
static uint16_t scan_interval_window_value;
|
||||
|
||||
static uint16_t scan_interval_window_value_handle;
|
||||
static uint16_t scan_interval_window_value_handle_client_configuration;
|
||||
|
||||
@ -73,6 +71,24 @@ static hci_con_handle_t scan_refresh_value_client_configuration_connection;
|
||||
static uint16_t scan_refresh_value_handle;
|
||||
static uint16_t scan_refresh_value_handle_client_configuration;
|
||||
|
||||
static void scan_parameters_service_emit_state(hci_con_handle_t con_handle, uint16_t max_scan_interval, uint16_t min_scan_window){
|
||||
if (scan_parameters_packet_handler == NULL) return;
|
||||
|
||||
uint8_t event[9];
|
||||
uint16_t pos = 0;
|
||||
event[pos++] = HCI_EVENT_GATTSERVICE_META;
|
||||
event[pos++] = sizeof(event) - 2;
|
||||
event[pos++] = GATTSERVICE_SUBEVENT_SCAN_PARAMETERS_SERVICE_SCAN_INTERVAL_UPDATE;
|
||||
little_endian_store_16(event, pos, (uint16_t) con_handle);
|
||||
pos += 2;
|
||||
little_endian_store_16(event, pos, max_scan_interval);
|
||||
pos += 2;
|
||||
little_endian_store_16(event, pos, min_scan_window);
|
||||
pos += 2;
|
||||
|
||||
(*scan_parameters_packet_handler)(HCI_EVENT_PACKET, 0, event, pos);
|
||||
}
|
||||
|
||||
static uint16_t scan_parameters_service_read_callback(hci_con_handle_t con_handle, uint16_t attribute_handle, uint16_t offset, uint8_t * buffer, uint16_t buffer_size){
|
||||
UNUSED(con_handle);
|
||||
UNUSED(attribute_handle);
|
||||
@ -88,27 +104,34 @@ static int scan_parameters_service_write_callback(hci_con_handle_t con_handle, u
|
||||
UNUSED(buffer_size);
|
||||
|
||||
if (attribute_handle == scan_interval_window_value_handle){
|
||||
if (buffer != NULL){
|
||||
scan_interval_window_value = little_endian_read_16(buffer, 0);
|
||||
if (buffer_size == 4){
|
||||
uint16_t max_scan_interval = little_endian_read_16(buffer, 0);
|
||||
uint16_t min_scan_window = little_endian_read_16(buffer, 2);
|
||||
scan_parameters_service_emit_state(con_handle, max_scan_interval, min_scan_window);
|
||||
return ATT_ERROR_SUCCESS;
|
||||
} else {
|
||||
return ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LENGTH;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (attribute_handle == scan_refresh_value_handle_client_configuration){
|
||||
if (buffer != NULL){
|
||||
if (buffer_size == 2){
|
||||
scan_refresh_value_client_configuration = little_endian_read_16(buffer, 0);
|
||||
scan_refresh_value_client_configuration_connection = con_handle;
|
||||
return ATT_ERROR_SUCCESS;
|
||||
} else {
|
||||
return ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LENGTH;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
|
||||
return ATT_ERROR_UNLIKELY_ERROR;
|
||||
}
|
||||
|
||||
static void scan_parameters_service_refresh_can_send_now(void * context){
|
||||
hci_con_handle_t con_handle = (hci_con_handle_t) (uintptr_t) context;
|
||||
UNUSED(context);
|
||||
uint8_t value[2];
|
||||
little_endian_store_16(value, 0, scan_refresh_value);
|
||||
att_server_notify(con_handle, scan_refresh_value_handle, value, 2);
|
||||
att_server_notify(scan_refresh_value_client_configuration_connection, scan_refresh_value_handle, value, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -145,7 +168,7 @@ void scan_parameters_service_server_set_scan_refresh(uint16_t scan_refresh){
|
||||
scan_refresh_value = scan_refresh;
|
||||
if (scan_refresh_value_client_configuration != 0){
|
||||
scan_parameters_callback.callback = &scan_parameters_service_refresh_can_send_now;
|
||||
scan_parameters_callback.context = (void*) (uintptr_t) scan_refresh_value_client_configuration_connection;
|
||||
scan_parameters_callback.context = NULL;
|
||||
att_server_register_can_send_now_callback(&scan_parameters_callback, scan_refresh_value_client_configuration_connection);
|
||||
}
|
||||
}
|
||||
|
@ -92,6 +92,7 @@
|
||||
#include "ble/gatt-service/hids_client.h"
|
||||
#include "ble/gatt-service/hids_device.h"
|
||||
#include "ble/gatt-service/scan_parameters_service_client.h"
|
||||
#include "ble/gatt-service/scan_parameters_service_server.h"
|
||||
#ifdef ENABLE_MESH
|
||||
#include "ble/gatt-service/mesh_provisioning_service_server.h"
|
||||
#include "ble/gatt-service/mesh_proxy_service_server.h"
|
||||
|
@ -3295,6 +3295,16 @@ typedef uint8_t sm_key_t[16];
|
||||
*/
|
||||
#define GATTSERVICE_SUBEVENT_HID_SERVICE_REPORTS_NOTIFICATION 0x17
|
||||
|
||||
/**
|
||||
* @format 1H22
|
||||
* @param subevent_code
|
||||
* @param con_handle
|
||||
* @param max_scan_interval
|
||||
* @param min_scan_window
|
||||
*/
|
||||
#define GATTSERVICE_SUBEVENT_SCAN_PARAMETERS_SERVICE_SCAN_INTERVAL_UPDATE 0x18
|
||||
|
||||
|
||||
// MAP Meta Event Group
|
||||
|
||||
/**
|
||||
|
@ -9970,6 +9970,34 @@ static inline uint8_t gattservice_subevent_hid_service_reports_notification_get_
|
||||
return event[5];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field con_handle from event GATTSERVICE_SUBEVENT_SCAN_PARAMETERS_SERVICE_SCAN_INTERVAL_UPDATE
|
||||
* @param event packet
|
||||
* @return con_handle
|
||||
* @note: btstack_type H
|
||||
*/
|
||||
static inline hci_con_handle_t gattservice_subevent_scan_parameters_service_scan_interval_update_get_con_handle(const uint8_t * event){
|
||||
return little_endian_read_16(event, 3);
|
||||
}
|
||||
/**
|
||||
* @brief Get field max_scan_interval from event GATTSERVICE_SUBEVENT_SCAN_PARAMETERS_SERVICE_SCAN_INTERVAL_UPDATE
|
||||
* @param event packet
|
||||
* @return max_scan_interval
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t gattservice_subevent_scan_parameters_service_scan_interval_update_get_max_scan_interval(const uint8_t * event){
|
||||
return little_endian_read_16(event, 5);
|
||||
}
|
||||
/**
|
||||
* @brief Get field min_scan_window from event GATTSERVICE_SUBEVENT_SCAN_PARAMETERS_SERVICE_SCAN_INTERVAL_UPDATE
|
||||
* @param event packet
|
||||
* @return min_scan_window
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t gattservice_subevent_scan_parameters_service_scan_interval_update_get_min_scan_window(const uint8_t * event){
|
||||
return little_endian_read_16(event, 7);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field map_cid from event MAP_SUBEVENT_CONNECTION_OPENED
|
||||
* @param event packet
|
||||
|
Loading…
x
Reference in New Issue
Block a user