att_server.c (7907f06931c075b55e3402fa469abbe35eebee25) | att_server.c (5611a760af48d1ce1beea59c7908be73bd2393f1) |
---|---|
1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 86 unchanged lines hidden (view full) --- 95static btstack_packet_handler_t att_client_packet_handler = NULL; 96 97static void att_handle_value_indication_notify_client(uint8_t status, uint16_t client_handle, uint16_t attribute_handle){ 98 99 if (!att_client_packet_handler) return; 100 101 uint8_t event[7]; 102 int pos = 0; | 1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 86 unchanged lines hidden (view full) --- 95static btstack_packet_handler_t att_client_packet_handler = NULL; 96 97static void att_handle_value_indication_notify_client(uint8_t status, uint16_t client_handle, uint16_t attribute_handle){ 98 99 if (!att_client_packet_handler) return; 100 101 uint8_t event[7]; 102 int pos = 0; |
103 event[pos++] = ATT_HANDLE_VALUE_INDICATION_COMPLETE; | 103 event[pos++] = ATT_EVENT_HANDLE_VALUE_INDICATION_COMPLETE; |
104 event[pos++] = sizeof(event) - 2; 105 event[pos++] = status; 106 bt_store_16(event, pos, client_handle); 107 pos += 2; 108 bt_store_16(event, pos, attribute_handle); 109 pos += 2; 110 (*att_client_packet_handler)(HCI_EVENT_PACKET, 0, &event[0], sizeof(event)); 111} 112 113static void att_emit_mtu_event(uint16_t handle, uint16_t mtu){ 114 115 if (!att_client_packet_handler) return; 116 117 uint8_t event[6]; 118 int pos = 0; | 104 event[pos++] = sizeof(event) - 2; 105 event[pos++] = status; 106 bt_store_16(event, pos, client_handle); 107 pos += 2; 108 bt_store_16(event, pos, attribute_handle); 109 pos += 2; 110 (*att_client_packet_handler)(HCI_EVENT_PACKET, 0, &event[0], sizeof(event)); 111} 112 113static void att_emit_mtu_event(uint16_t handle, uint16_t mtu){ 114 115 if (!att_client_packet_handler) return; 116 117 uint8_t event[6]; 118 int pos = 0; |
119 event[pos++] = ATT_MTU_EXCHANGE_COMPLETE; | 119 event[pos++] = ATT_EVENT_MTU_EXCHANGE_COMPLETE; |
120 event[pos++] = sizeof(event) - 2; 121 bt_store_16(event, pos, handle); 122 pos += 2; 123 bt_store_16(event, pos, mtu); 124 pos += 2; 125 (*att_client_packet_handler)(HCI_EVENT_PACKET, 0, &event[0], sizeof(event)); 126} 127 --- 49 unchanged lines hidden (view full) --- 177 att_clear_transaction_queue(&att_connection); 178 att_connection.con_handle = 0; 179 att_handle_value_indication_handle = 0; // reset error state 180 // restart advertising if we have been connected before 181 // -> avoid sending advertise enable a second time before command complete was received 182 att_server_state = ATT_SERVER_IDLE; 183 break; 184 | 120 event[pos++] = sizeof(event) - 2; 121 bt_store_16(event, pos, handle); 122 pos += 2; 123 bt_store_16(event, pos, mtu); 124 pos += 2; 125 (*att_client_packet_handler)(HCI_EVENT_PACKET, 0, &event[0], sizeof(event)); 126} 127 --- 49 unchanged lines hidden (view full) --- 177 att_clear_transaction_queue(&att_connection); 178 att_connection.con_handle = 0; 179 att_handle_value_indication_handle = 0; // reset error state 180 // restart advertising if we have been connected before 181 // -> avoid sending advertise enable a second time before command complete was received 182 att_server_state = ATT_SERVER_IDLE; 183 break; 184 |
185 case SM_IDENTITY_RESOLVING_STARTED: 186 log_info("SM_IDENTITY_RESOLVING_STARTED"); | 185 case SM_EVENT_IDENTITY_RESOLVING_STARTED: 186 log_info("SM_EVENT_IDENTITY_RESOLVING_STARTED"); |
187 att_ir_lookup_active = 1; 188 break; | 187 att_ir_lookup_active = 1; 188 break; |
189 case SM_IDENTITY_RESOLVING_SUCCEEDED: | 189 case SM_EVENT_IDENTITY_RESOLVING_SUCCEEDED: |
190 att_ir_lookup_active = 0; 191 att_ir_le_device_db_index = READ_BT_16(packet, 11); | 190 att_ir_lookup_active = 0; 191 att_ir_le_device_db_index = READ_BT_16(packet, 11); |
192 log_info("SM_IDENTITY_RESOLVING_SUCCEEDED id %u", att_ir_le_device_db_index); | 192 log_info("SM_EVENT_IDENTITY_RESOLVING_SUCCEEDED id %u", att_ir_le_device_db_index); |
193 att_run(); 194 break; | 193 att_run(); 194 break; |
195 case SM_IDENTITY_RESOLVING_FAILED: 196 log_info("SM_IDENTITY_RESOLVING_FAILED"); | 195 case SM_EVENT_IDENTITY_RESOLVING_FAILED: 196 log_info("SM_EVENT_IDENTITY_RESOLVING_FAILED"); |
197 att_ir_lookup_active = 0; 198 att_ir_le_device_db_index = -1; 199 att_run(); 200 break; 201 | 197 att_ir_lookup_active = 0; 198 att_ir_le_device_db_index = -1; 199 att_run(); 200 break; 201 |
202 case SM_AUTHORIZATION_RESULT: { | 202 case SM_EVENT_AUTHORIZATION_RESULT: { |
203 if (packet[4] != att_client_addr_type) break; 204 bt_flip_addr(event_address, &packet[5]); 205 if (memcmp(event_address, att_client_address, 6) != 0) break; 206 att_connection.authorized = packet[11]; 207 att_run(); 208 break; 209 } 210 --- 194 unchanged lines hidden --- | 203 if (packet[4] != att_client_addr_type) break; 204 bt_flip_addr(event_address, &packet[5]); 205 if (memcmp(event_address, att_client_address, 6) != 0) break; 206 att_connection.authorized = packet[11]; 207 att_run(); 208 break; 209 } 210 --- 194 unchanged lines hidden --- |