mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-03 07:13:51 +00:00
example/sm_pairing_peripheral: unix line endings, constant value in characteristic
This commit is contained in:
parent
d7ee901afc
commit
fd30bf16b2
@ -35,8 +35,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -69,7 +69,6 @@
|
||||
static int le_notification_enabled;
|
||||
static btstack_timer_source_t heartbeat;
|
||||
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
||||
static btstack_packet_callback_registration_t sm_event_callback_registration;
|
||||
static hci_con_handle_t con_handle;
|
||||
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
@ -99,15 +98,6 @@ static void le_counter_setup(void){
|
||||
|
||||
// setup SM: Display only
|
||||
sm_init();
|
||||
sm_event_callback_registration.callback = &packet_handler;
|
||||
sm_add_event_handler(&sm_event_callback_registration);
|
||||
// Numeric Comparison
|
||||
sm_set_io_capabilities(IO_CAPABILITY_DISPLAY_YES_NO);
|
||||
// Passkey entry initiator enter, responder displays
|
||||
// sm_set_io_capabilities(IO_CAPABILITY_DISPLAY_ONLY);
|
||||
#ifdef ENABLE_LE_SECURE_CONNECTIONS
|
||||
sm_set_authentication_requirements(SM_AUTHREQ_SECURE_CONNECTION|SM_AUTHREQ_MITM_PROTECTION);
|
||||
#endif
|
||||
|
||||
// setup ATT server
|
||||
att_server_init(profile_data, att_read_callback, att_write_callback);
|
||||
@ -180,14 +170,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
case ATT_EVENT_CAN_SEND_NOW:
|
||||
att_server_notify(con_handle, ATT_CHARACTERISTIC_0000FF11_0000_1000_8000_00805F9B34FB_01_VALUE_HANDLE, (uint8_t*) counter_string, counter_string_len);
|
||||
break;
|
||||
case SM_EVENT_NUMERIC_COMPARISON_REQUEST:
|
||||
printf("Confirming numeric comparison: %u\n", sm_event_numeric_comparison_request_get_passkey(packet));
|
||||
sm_numeric_comparison_confirm(sm_event_passkey_display_number_get_handle(packet));
|
||||
break;
|
||||
case SM_EVENT_PASSKEY_DISPLAY_NUMBER:
|
||||
printf("Display Passkey: %u\n", sm_event_passkey_display_number_get_passkey(packet));
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -217,18 +200,6 @@ static uint16_t att_read_callback(hci_con_handle_t connection_handle, uint16_t a
|
||||
return counter_string_len;
|
||||
}
|
||||
}
|
||||
if (att_handle == ATT_CHARACTERISTIC_0000FF12_0000_1000_8000_00805F9B34FB_01_VALUE_HANDLE){
|
||||
if (buffer){
|
||||
memcpy(buffer, &counter_string[offset], counter_string_len - offset);
|
||||
}
|
||||
return counter_string_len - offset;
|
||||
}
|
||||
if (att_handle == ATT_CHARACTERISTIC_0000FF12_0000_1000_8000_00805F9B34FB_01_VALUE_HANDLE){
|
||||
if (buffer){
|
||||
memcpy(buffer, &counter_string[offset], counter_string_len - offset);
|
||||
}
|
||||
return counter_string_len - offset;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/* LISTING_END */
|
||||
|
@ -8,7 +8,5 @@ CHARACTERISTIC, GATT_SERVICE_CHANGED, READ,
|
||||
PRIMARY_SERVICE, 0000FF10-0000-1000-8000-00805F9B34FB
|
||||
// Counter Characteristic, with read and notify
|
||||
CHARACTERISTIC, 0000FF11-0000-1000-8000-00805F9B34FB, READ | NOTIFY | DYNAMIC,
|
||||
// Counter Characteristic, with read and notify + authentication
|
||||
CHARACTERISTIC, 0000FF12-0000-1000-8000-00805F9B34FB, READ | NOTIFY | DYNAMIC | ENCRYPTION_KEY_SIZE_16,
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
PRIMARY_SERVICE, GAP_SERVICE
|
||||
CHARACTERISTIC, GAP_DEVICE_NAME, READ, "SM Pairing Peripheral"
|
||||
|
||||
PRIMARY_SERVICE, GATT_SERVICE
|
||||
CHARACTERISTIC, GATT_SERVICE_CHANGED, READ,
|
||||
|
||||
// Dummy Service
|
||||
PRIMARY_SERVICE, 0000FF10-0000-1000-8000-00805F9B34FB
|
||||
// Dummy Service, Characteristic, with read and notify + authentication
|
||||
CHARACTERISTIC, 0000FF12-0000-1000-8000-00805F9B34FB, READ | NOTIFY | DYNAMIC | ENCRYPTION_KEY_SIZE_16,
|
||||
|
||||
|
||||
PRIMARY_SERVICE, GAP_SERVICE
|
||||
CHARACTERISTIC, GAP_DEVICE_NAME, READ, "SM Pairing Peripheral"
|
||||
|
||||
PRIMARY_SERVICE, GATT_SERVICE
|
||||
CHARACTERISTIC, GATT_SERVICE_CHANGED, READ,
|
||||
|
||||
// Dummy Service
|
||||
PRIMARY_SERVICE, 0000FF10-0000-1000-8000-00805F9B34FB
|
||||
// Dummy Service, Characteristic, with read and notify + authentication
|
||||
CHARACTERISTIC, 0000FF12-0000-1000-8000-00805F9B34FB, READ | ENCRYPTION_KEY_SIZE_16, "Secure :)"
|
||||
|
Loading…
x
Reference in New Issue
Block a user