Merge "cleanup of acquire notification data for stop notify" into tizen
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / hardware / bluetooth.h
1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef ANDROID_INCLUDE_BLUETOOTH_H
18 #define ANDROID_INCLUDE_BLUETOOTH_H
19
20 #include <stdbool.h>
21 #include <stdint.h>
22 #include <sys/cdefs.h>
23 #include <sys/types.h>
24
25 #include <hardware/hardware.h>
26
27 __BEGIN_DECLS
28
29 /**
30  * The Bluetooth Hardware Module ID
31  */
32
33 #define BT_HARDWARE_MODULE_ID "bluetooth"
34 #define BT_STACK_MODULE_ID "bluetooth"
35 #define BT_STACK_TEST_MODULE_ID "bluetooth_test"
36
37
38 /* Bluetooth profile interface IDs */
39
40 #define BT_PROFILE_HANDSFREE_ID "handsfree"
41 #define BT_PROFILE_HANDSFREE_CLIENT_ID "handsfree_client"
42 #define BT_PROFILE_ADVANCED_AUDIO_ID "a2dp"
43 #define BT_PROFILE_ADVANCED_AUDIO_SINK_ID "a2dp_sink"
44 #define BT_PROFILE_HEALTH_ID "health"
45 #define BT_PROFILE_SOCKETS_ID "socket"
46 #define BT_PROFILE_HIDHOST_ID "hidhost"
47 #define BT_PROFILE_PAN_ID "pan"
48 #define BT_PROFILE_MAP_CLIENT_ID "map_client"
49
50 #define BT_PROFILE_GATT_ID "gatt"
51 #define BT_PROFILE_AV_RC_ID "avrcp"
52 #define BT_PROFILE_AV_RC_CTRL_ID "avrcp_ctrl"
53
54 /** Bluetooth Address */
55 typedef struct {
56         uint8_t address[6];
57 } __attribute__((packed))bt_bdaddr_t;
58
59 /** Bluetooth Device Name */
60 typedef struct {
61         uint8_t name[249];
62 } __attribute__((packed))bt_bdname_t;
63
64 /** Bluetooth Adapter Visibility Modes*/
65 typedef enum {
66         BT_SCAN_MODE_NONE,
67         BT_SCAN_MODE_CONNECTABLE,
68         BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE
69 } bt_scan_mode_t;
70
71 /** Bluetooth Adapter State */
72 typedef enum {
73         BT_STATE_OFF,
74         BT_STATE_ON
75 }   bt_state_t;
76
77 /** Bluetooth Error Status */
78 /** We need to build on this */
79
80 typedef enum {
81         BT_STATUS_SUCCESS,
82         BT_STATUS_FAIL,
83         BT_STATUS_NOT_READY,
84         BT_STATUS_NOMEM,
85         BT_STATUS_BUSY,
86         BT_STATUS_DONE,        /* request already completed */
87         BT_STATUS_UNSUPPORTED,
88         BT_STATUS_PARM_INVALID,
89         BT_STATUS_UNHANDLED,
90         BT_STATUS_AUTH_FAILURE,
91         BT_STATUS_RMT_DEV_DOWN,
92 #ifndef TIZEN_BT_HAL
93         BT_STATUS_CONN_TOUT   /* disconnection due to supervision timeout */
94 #else
95         BT_STATUS_CONN_TOUT,   /* disconnection due to supervision timeout */
96         BT_STATUS_AUTH_REJECTED,
97         BT_STATUS_CONN_TERM_LOCAL_HOST,
98         BT_STATUS_CONN_TERM_RMT_HOST
99 #endif
100 } bt_status_t;
101
102 /** Bluetooth PinKey Code */
103 typedef struct {
104         uint8_t pin[16];
105 } __attribute__((packed))bt_pin_code_t;
106
107 typedef struct {
108         uint8_t status;
109         uint8_t ctrl_state;     /* stack reported state */
110         uint64_t tx_time;       /* in ms */
111         uint64_t rx_time;       /* in ms */
112         uint64_t idle_time;     /* in ms */
113         uint64_t energy_used;   /* a product of mA, V and ms */
114 } __attribute__((packed))bt_activity_energy_info;
115
116 /** Bluetooth Adapter Discovery state */
117 typedef enum {
118         BT_DISCOVERY_STOPPED,
119         BT_DISCOVERY_STARTED
120 } bt_discovery_state_t;
121
122 /** Bluetooth ACL connection state */
123 typedef enum {
124         BT_ACL_STATE_CONNECTED,
125         BT_ACL_STATE_DISCONNECTED
126 } bt_acl_state_t;
127
128 /** Remote Device Trusted state */
129 typedef enum {
130         BT_DEVICE_TRUSTED,
131         BT_DEVICE_NOT_TRUSTED
132 } bt_device_trust_state_t;
133
134 /** Bluetooth 128-bit UUID */
135 typedef struct {
136         uint8_t uu[16];
137 } bt_uuid_t;
138
139 /** Bluetooth SDP service record */
140 typedef struct {
141         bt_uuid_t uuid;
142         uint16_t channel;
143         char name[256]; // what's the maximum length
144 } bt_service_record_t;
145
146
147 /** Bluetooth Remote Version info */
148 typedef struct {
149         int version;
150         int sub_ver;
151         int manufacturer;
152 } bt_remote_version_t;
153
154
155 typedef struct {
156         uint16_t version_supported;
157         uint8_t local_privacy_enabled;
158         uint8_t max_adv_instance;
159         uint8_t rpa_offload_supported;
160         uint8_t max_irk_list_size;
161         uint8_t max_adv_filter_supported;
162         uint8_t activity_energy_info_supported;
163         uint16_t scan_result_storage_size;
164         uint16_t total_trackable_advertisers;
165         bool extended_scan_support;
166         bool debug_logging_supported;
167         bool le_2m_phy_supported;
168         bool le_coded_phy_supported;
169         bool le_extended_advertising_supported;
170         bool le_periodic_advertising_supported;
171         uint16_t le_maximum_advertising_data_length;
172 } bt_local_le_features_t;
173
174 /*
175 typedef struct {
176         uint8_t local_privacy_enabled;
177         uint8_t max_adv_instance;
178         uint8_t rpa_offload_supported;
179         uint8_t max_irk_list_size;
180         uint8_t max_adv_filter_supported;
181         uint8_t scan_result_storage_size_lobyte;
182         uint8_t scan_result_storage_size_hibyte;
183         uint8_t activity_energy_info_supported;
184 } bt_local_le_features_t;*/
185
186 /* Bluetooth Adapter and Remote Device property types */
187 typedef enum {
188         /* Properties common to both adapter and remote device */
189         /**
190          * Description - Bluetooth Device Name
191          * Access mode - Adapter name can be GET/SET. Remote device can be GET
192          * Data type   - bt_bdname_t
193          */
194         BT_PROPERTY_BDNAME = 0x1,
195         /**
196          * Description - Bluetooth Device Address
197          * Access mode - Only GET.
198          * Data type   - bt_bdaddr_t
199          */
200         BT_PROPERTY_BDADDR,
201         /**
202          * Description - Bluetooth Service 128-bit UUIDs
203          * Access mode - Only GET.
204          * Data type   - Array of bt_uuid_t (Array size inferred from property length).
205          */
206         BT_PROPERTY_UUIDS,
207         /**
208          * Description - Bluetooth Class of Device as found in Assigned Numbers
209          * Access mode - Only GET.
210          * Data type   - uint32_t.
211          */
212         BT_PROPERTY_CLASS_OF_DEVICE,
213         /**
214          * Description - Device Type - BREDR, BLE or DUAL Mode
215          * Access mode - Only GET.
216          * Data type   - bt_device_type_t
217          */
218         BT_PROPERTY_TYPE_OF_DEVICE,
219         /**
220          * Description - Bluetooth Service Record
221          * Access mode - Only GET.
222          * Data type   - bt_service_record_t
223          */
224         BT_PROPERTY_SERVICE_RECORD,
225
226         /* Properties unique to adapter */
227         /**
228          * Description - Bluetooth Adapter scan mode
229          * Access mode - GET and SET
230          * Data type   - bt_scan_mode_t.
231          */
232         BT_PROPERTY_ADAPTER_SCAN_MODE,
233         /**
234          * Description - List of bonded devices
235          * Access mode - Only GET.
236          * Data type   - Array of bt_bdaddr_t of the bonded remote devices
237          *               (Array size inferred from property length).
238          */
239         BT_PROPERTY_ADAPTER_BONDED_DEVICES,
240         /**
241          * Description - Bluetooth Adapter Discovery timeout (in seconds)
242          * Access mode - GET and SET
243          * Data type   - uint32_t
244          */
245         BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
246
247         /* Properties unique to remote device */
248         /**
249          * Description - User defined friendly name of the remote device
250          * Access mode - GET and SET
251          * Data type   - bt_bdname_t.
252          */
253         BT_PROPERTY_REMOTE_FRIENDLY_NAME,
254         /**
255          * Description - RSSI value of the inquired remote device
256          * Access mode - Only GET.
257          * Data type   - int32_t.
258          */
259         BT_PROPERTY_REMOTE_RSSI,
260         /**
261          * Description - Remote version info
262          * Access mode - SET/GET.
263          * Data type   - bt_remote_version_t.
264          */
265
266         BT_PROPERTY_REMOTE_VERSION_INFO,
267
268         /* Tizen Specific Adapter and Remote Device properties */
269         /**
270          * Description - Remote Device paired Info
271          * Access mode - GET.
272          * Data type   - uint8_t.
273          */
274         BT_PROPERTY_REMOTE_PAIRED,
275
276         /**
277          * Description - Remote Device connected Info
278          * Access mode - GET.
279          * Data type   - unsigned int.
280          */
281         BT_PROPERTY_REMOTE_CONNECTED,
282
283         /**
284          * Description - Remote Device Trusted info
285          * Access mode - GET.
286          * Data type   - uint8_t.
287          */
288         BT_PROPERTY_REMOTE_TRUST,
289
290         /**
291          * Description - Adapter Pairable info
292          * Access mode - GET\SET.
293          * Data type   - uint8_t
294          */
295         BT_PROPERTY_PAIRABLE,
296
297         /**
298          * Description - Adapter pairable Timeout value
299          * Access mode - GET.
300          * Data type   - uint32_t
301          */
302         BT_PROPERTY_PAIRABLE_TIMEOUT,
303
304         /**
305          * Description - Adapter version
306          * Access mode - GET
307          * Data type   - Array of character string
308          */
309         BT_PROPERTY_VERSION,
310
311         /**
312          * Description - Adapter IPSP initialized state info
313          * Access mode - GET
314          * Data type   - uint8_t
315          */
316         BT_PROPERTY_IPSP_INITIALIZED,
317
318         /**
319          * Description - Adapter Modalias info
320          * Access mode - GET
321          * Data type   - Array of character string
322          */
323         BT_PROPERTY_MODALIAS,
324
325         /**
326          * Description - BLE Device manufacturer data length
327          * Access mode - GET
328          * Data type   - uint32_t
329          */
330         BT_PROPERTY_REMOTE_DEVICE_MANUFACTURER_DATA_LEN,
331
332         /**
333          * Description - BLE Device manufacturer data
334          * Access mode - GET
335          * Data type   - Array of character string
336          */
337         BT_PROPERTY_REMOTE_DEVICE_MANUFACTURER_DATA,
338
339         /**
340          * Description - Remote BLE advertising data
341          * Access mode - Only received during device found callback.
342          * Data type   - Array of uint8_t of remote BLE adv data.
343          *               (Array size inferred from property length).
344          */
345         BT_PROPERTY_REMOTE_BLE_ADV_DATA,
346
347         /**
348          * Description - Local LE features
349          * Access mode - GET.
350          * Data type   - bt_local_le_features_t.
351          */
352         BT_PROPERTY_LOCAL_LE_FEATURES,
353
354         /**
355          * Description - Remote device friendly name set?
356          * Access mode - GET.
357          * Data type   - uint8_t
358          */
359         BT_PROPERTY_REMOTE_IS_ALIAS_SET,
360
361         BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP = 0xFF,
362 } bt_property_type_t;
363
364 /** Bluetooth Adapter Property data structure */
365 typedef struct {
366         bt_property_type_t type;
367         int len;
368         void *val;
369 } bt_property_t;
370
371
372 /** Bluetooth Device Type */
373 typedef enum {
374         BT_DEVICE_DEVTYPE_BREDR = 0x1,
375         BT_DEVICE_DEVTYPE_BLE,
376         BT_DEVICE_DEVTYPE_DUAL
377 } bt_device_type_t;
378 /** Bluetooth Bond state */
379 typedef enum {
380         BT_BOND_STATE_NONE,
381         BT_BOND_STATE_BONDING,
382         BT_BOND_STATE_BONDED
383 } bt_bond_state_t;
384
385 /** Bluetooth SSP Bonding Variant */
386 typedef enum {
387         BT_SSP_VARIANT_PASSKEY_CONFIRMATION,
388         BT_SSP_VARIANT_PASSKEY_ENTRY,
389         BT_SSP_VARIANT_CONSENT,
390         BT_SSP_VARIANT_PASSKEY_NOTIFICATION
391 } bt_ssp_variant_t;
392
393 /** Bluetooth Profile Service IDs */
394 typedef enum {
395         BT_RES_SERVICE_ID,              /* Reserved */
396         BT_SPP_SERVICE_ID,              /* Serial port profile. */
397         BT_DUN_SERVICE_ID,              /* Dial-up networking profile. */
398         BT_A2DP_SRC_SERVICE_ID,         /* A2DP Source profile. */
399         BT_LAP_SERVICE_ID,              /* LAN access profile. */
400         BT_HSP_SERVICE_ID,              /* Headset profile. */
401         BT_HFP_SERVICE_ID,              /* Hands-free profile. */
402         BT_OPP_SERVICE_ID,              /* Object push  */
403         BT_FTP_SERVICE_ID,              /* File transfer */
404         BT_AVRCP_CT_SERVICE_ID,         /* AVRC Controller Terminal */
405         BT_ICP_SERVICE_ID,              /* Intercom Terminal */
406         BT_SYNC_SERVICE_ID,             /* Synchronization */
407         BT_BPP_SERVICE_ID,              /* Basic printing profile */
408         BT_BIP_SERVICE_ID,              /* Basic Imaging profile */
409         BT_PANU_SERVICE_ID,             /* PAN User */
410         BT_NAP_SERVICE_ID,              /* PAN Network access point */
411         BT_GN_SERVICE_ID,               /* PAN Group Ad-hoc networks */
412         BT_SAP_SERVICE_ID,              /* SIM Access profile */
413         BT_A2DP_SERVICE_ID,             /* A2DP Sink */
414         BT_AVRCP_SERVICE_ID,            /* A/V remote control */
415         BT_HID_SERVICE_ID,              /* HID */
416         BT_VDP_SERVICE_ID,              /* Video distribution */
417         BT_PBAP_SERVICE_ID,             /* PhoneBook Access Server*/
418         BT_HSP_HS_SERVICE_ID,           /* HFP HS role */
419         BT_HFP_HS_SERVICE_ID,           /* HSP HS role */
420         BT_MAP_SERVICE_ID,              /* Message Access Profile */
421         BT_MN_SERVICE_ID,               /* Message Notification Service */
422         BT_HDP_SERVICE_ID,              /* Health Device Profile */
423         BT_PCE_SERVICE_ID,              /* PhoneBook Access Client*/
424 #ifdef TIZEN_BT_HAL
425         BT_IOTIVITY_SERVICE_ID,         /* Custom IOTIVITY UUID */
426 #endif
427 } bt_service_id_t;
428
429 #define BT_MAX_NUM_UUIDS 32
430
431 #ifdef TIZEN_BT_HAL
432 #define BT_OSP_SERVER_OBEX 0x00
433 /* TODO: Add more types If and when required */
434 #define BT_OSP_SERVER_MAX 0xFF
435
436 /* Tizen BT discovery Types */
437 typedef enum {
438         BT_DISC_ROLE_BREDR = 0x01,
439         BT_DISC_ROLE_LE,
440         BT_DISC_ROLE_DUAL
441 } bt_disc_role_type_t;
442
443 /** Bluetooth Trusted Profiles */
444 typedef enum {
445         BT_TRUSTED_PROFILE_PBAP = 1,
446         BT_TRUSTED_PROFILE_MAP,
447         BT_TRUSTED_PROFILE_SAP,
448         BT_TRUSTED_PROFILE_HFP_HF,
449         BT_TRUSTED_PROFILE_A2DP,
450         BT_TRUSTED_PROFILE_ALL = 0xFFFFFFFF,
451 } bt_trusted_profile_t;
452
453 /** Bluetooth Bonding Authentication Notifications */
454 typedef enum {
455         BT_PASSKEY_CONFIRMATION = 1,
456         BT_PASSKEY_DISPLAY,
457         BT_PASSKEY_ENTRY,
458         BT_PINCODE_ENTRY,
459 } bt_gap_auth_variant_t;
460 #endif
461
462 /** Bluetooth Interface callbacks */
463
464 /** Bluetooth Enable/Disable Callback. */
465 typedef void (*adapter_state_changed_callback)(bt_state_t state);
466
467 #ifdef TIZEN_BT_HAL
468 /** BLE Enable/Disable Callback. */
469 typedef void (*le_state_changed_callback)(bt_state_t state);
470 #endif
471
472 /** GET/SET Adapter Properties callback */
473 /* TODO: For the GET/SET property APIs/callbacks, we may need a session
474  * identifier to associate the call with the callback. This would be needed
475  * whenever more than one simultaneous instance of the same adapter_type
476  * is get/set.
477  *
478  * If this is going to be handled in the Java framework, then we do not need
479  * to manage sessions here.
480  */
481 typedef void (*adapter_properties_callback)(bt_status_t status,
482                 int num_properties,
483                 bt_property_t *properties);
484
485 /** GET/SET Remote Device Properties callback */
486 /** TODO: For remote device properties, do not see a need to get/set
487  * multiple properties - num_properties shall be 1
488  */
489 typedef void (*remote_device_properties_callback)(bt_status_t status,
490                 bt_bdaddr_t *bd_addr,
491                 int num_properties,
492                 bt_property_t *properties);
493
494 /** New device discovered callback */
495 /** If EIR data is not present, then BD_NAME and RSSI shall be NULL and -1
496  * respectively */
497 typedef void (*device_found_callback)(int num_properties,
498                 bt_property_t *properties);
499
500 /** Discovery state changed callback */
501 typedef void (*discovery_state_changed_callback)(bt_discovery_state_t state);
502
503 /** Bluetooth Legacy PinKey Request callback */
504 typedef void (*pin_request_callback)(bt_bdaddr_t *remote_bd_addr,
505                 bt_bdname_t *bd_name, uint32_t cod);
506
507 /** Bluetooth SSP Request callback - Just Works & Numeric Comparison*/
508 /** pass_key - Shall be 0 for BT_SSP_PAIRING_VARIANT_CONSENT &
509  *  BT_SSP_PAIRING_PASSKEY_ENTRY */
510 /* TODO: Passkey request callback shall not be needed for devices with display
511  * capability. We still need support this in the stack for completeness */
512 typedef void (*ssp_request_callback)(bt_bdaddr_t *remote_bd_addr,
513                 bt_bdname_t *bd_name,
514                 uint32_t cod,
515                 bt_ssp_variant_t pairing_variant,
516                 uint32_t pass_key);
517
518 /** Bluetooth Bond state changed callback */
519 /* Invoked in response to create_bond, cancel_bond or remove_bond */
520 typedef void (*bond_state_changed_callback)(bt_status_t status,
521                 bt_bdaddr_t *remote_bd_addr,
522                 bt_bond_state_t state);
523
524 /** Bluetooth ACL connection state changed callback */
525 typedef void (*acl_state_changed_callback)(bt_status_t status, bt_bdaddr_t *remote_bd_addr,
526                 bt_acl_state_t state);
527
528 typedef enum {
529         ASSOCIATE_JVM,
530         DISASSOCIATE_JVM
531 } bt_cb_thread_evt;
532
533 /** Thread Associate/Disassociate JVM Callback */
534 /* Callback that is invoked by the callback thread to allow upper layer to attach/detach to/from
535  * the JVM */
536 typedef void (*callback_thread_event)(bt_cb_thread_evt evt);
537
538 /** Bluetooth Test Mode Callback */
539 /* Receive any HCI event from controller. Must be in DUT Mode for this callback to be received */
540 typedef void (*dut_mode_recv_callback)(uint16_t opcode, uint8_t *buf, uint8_t len);
541
542 /* LE Test mode callbacks
543  * This callback shall be invoked whenever the le_tx_test, le_rx_test or le_test_end is invoked
544  * The num_packets is valid only for le_test_end command */
545 typedef void (*le_test_mode_callback)(bt_status_t status, uint16_t num_packets);
546
547 /** Callback invoked when energy details are obtained */
548 /* Ctrl_state-Current controller state-Active-1,scan-2,or idle-3 state as defined by HCI spec.
549  * If the ctrl_state value is 0, it means the API call failed
550  * Time values-In milliseconds as returned by the controller
551  * Energy used-Value as returned by the controller
552  * Status-Provides the status of the read_energy_info API call */
553 typedef void (*energy_info_callback)(bt_activity_energy_info *energy_info);
554
555 /* Service level Authorization request callback */
556 typedef void (*authorize_request_callback) (bt_bdaddr_t *remote_bd_addr, bt_service_id_t service_d);
557
558 #ifdef TIZEN_BT_HAL
559 /* Service level Authorization request callback */
560 typedef void (*sock_authorize_request_callback) (bt_bdaddr_t *remote_bd_addr, bt_uuid_t *uuid);
561
562 /** Bluetooth ACL connection state */
563 typedef enum {
564         BT_LE_CONN_STATE_CONNECTED,
565         BT_LE_CONN_STATE_DISCONNECTED
566 } bt_le_conn_state_t;
567
568 /** Bluetooth ACL connection state changed callback */
569 typedef void (*le_conn_state_changed_callback)(bt_status_t status, bt_bdaddr_t *remote_bd_addr,
570                 bt_le_conn_state_t state);
571
572 /** Remote device trusted profiles changed callback */
573 typedef void (*device_trusted_profiles_changed_callback)(bt_bdaddr_t *bd_addr, uint32_t trust_val);
574
575 /** Remote device RSSI monitoring state changed callback */
576 typedef void (*rssi_monitor_state_changed_callback)(bt_bdaddr_t *bd_addr, int32_t link_type, uint8_t state);
577
578 /** Remote device RSSI alert callback */
579 typedef void (*rssi_alert_callback)(bt_bdaddr_t *bd_addr, int32_t link_type, int32_t alert_type, int32_t rssi);
580
581 /** Remote device Raw RSSI received callback */
582 typedef void (*raw_rssi_received_callback)(bt_bdaddr_t *bd_addr, int32_t link_type, int32_t rssi);
583 #endif
584
585 /** TODO: Add callbacks for Link Up/Down and other generic
586  *  notifications/callbacks */
587
588 /** Remote Device Trust state changed callback */
589 typedef void (*device_trust_state_changed_callback)(bt_bdaddr_t *remote_bd_addr,
590                 bt_device_trust_state_t trust);
591
592 /** Bluetooth DM callback structure. */
593 typedef struct {
594         /** set to sizeof(bt_callbacks_t) */
595         size_t size;
596         adapter_state_changed_callback adapter_state_changed_cb;
597         adapter_properties_callback adapter_properties_cb;
598         remote_device_properties_callback remote_device_properties_cb;
599         device_found_callback device_found_cb;
600         discovery_state_changed_callback discovery_state_changed_cb;
601         pin_request_callback pin_request_cb;
602         ssp_request_callback ssp_request_cb;
603         bond_state_changed_callback bond_state_changed_cb;
604         acl_state_changed_callback acl_state_changed_cb;
605         callback_thread_event thread_evt_cb;
606         dut_mode_recv_callback dut_mode_recv_cb;
607         le_test_mode_callback le_test_mode_cb;
608         energy_info_callback energy_info_cb;
609         authorize_request_callback authorize_request_cb;
610         device_trust_state_changed_callback device_trust_state_changed_cb;
611 #ifdef TIZEN_BT_HAL
612         sock_authorize_request_callback socket_authorize_request_cb;
613         le_state_changed_callback le_state_changed_cb;
614         le_conn_state_changed_callback le_conn_state_changed_cb;
615         device_trusted_profiles_changed_callback device_trusted_profiles_changed_cb;
616         rssi_monitor_state_changed_callback rssi_monitor_state_changed_cb;
617         rssi_alert_callback rssi_alert_cb;
618         raw_rssi_received_callback raw_rssi_received_cb;
619 #endif
620 } bt_callbacks_t;
621
622 typedef void (*alarm_cb)(void *data);
623 typedef bool (*set_wake_alarm_callout)(uint64_t delay_millis, bool should_wake, alarm_cb cb, void *data);
624 typedef int (*acquire_wake_lock_callout)(const char *lock_name);
625 typedef int (*release_wake_lock_callout)(const char *lock_name);
626
627 /** The set of functions required by bluedroid to set wake alarms and
628  * grab wake locks. This struct is passed into the stack through the
629  * |set_os_callouts| function on |bt_interface_t|.
630  */
631 typedef struct {
632         /* set to sizeof(bt_os_callouts_t) */
633         size_t size;
634
635         set_wake_alarm_callout set_wake_alarm;
636         acquire_wake_lock_callout acquire_wake_lock;
637         release_wake_lock_callout release_wake_lock;
638 } bt_os_callouts_t;
639
640 /** NOTE: By default, no profiles are initialized at the time of init/enable.
641  *  Whenever the application invokes the 'init' API of a profile, then one of
642  *  the following shall occur:
643  *
644  *    1.) If Bluetooth is not enabled, then the Bluetooth core shall mark the
645  *        profile as enabled. Subsequently, when the application invokes the
646  *        Bluetooth 'enable', as part of the enable sequence the profile that were
647  *        marked shall be enabled by calling appropriate stack APIs. The
648  *        'adapter_properties_cb' shall return the list of UUIDs of the
649  *        enabled profiles.
650  *
651  *    2.) If Bluetooth is enabled, then the Bluetooth core shall invoke the stack
652  *        profile API to initialize the profile and trigger a
653  *        'adapter_properties_cb' with the current list of UUIDs including the
654  *        newly added profile's UUID.
655  *
656  *   The reverse shall occur whenever the profile 'cleanup' APIs are invoked
657  */
658
659 /** Represents the standard Bluetooth DM interface. */
660 typedef struct {
661         /** set to sizeof(bt_interface_t) */
662         size_t size;
663         /**
664          * Opens the interface and provides the callback routines
665          * to the implemenation of this interface.
666          */
667         int (*init)(bt_callbacks_t*callbacks);
668
669         /** Enable Bluetooth. */
670         int (*enable)(void);
671
672         /** Disable Bluetooth. */
673         int (*disable)(void);
674
675 #ifdef TIZEN_BT_HAL
676         /** Reset Bluetooth. */
677         int (*reset)(void);
678 #endif
679
680 #ifdef TIZEN_BT_HAL
681         /** Enable LE Bluetooth. */
682         int (*le_enable)(void);
683
684         /** Disable LE Bluetooth. */
685         int (*le_disable)(void);
686
687         int (*le_init)(void);
688
689         void (*le_deinit)(void);
690
691         int (*is_advertising) (void);
692 #endif
693
694         /** Closes the interface. */
695         void (*cleanup)(void);
696
697 #ifdef TIZEN_BT_HAL
698         /** Get Bluetooth Adapter Powered status */
699         int (*get_adapter_powered_status)(uint8_t *status);
700 #endif
701
702         /** Get all Bluetooth Adapter properties at init */
703         int (*get_adapter_properties)(void);
704
705         /** Get Bluetooth Adapter property of 'type' */
706         int (*get_adapter_property)(bt_property_type_t type);
707
708         /** Set Bluetooth Adapter property of 'type' */
709         /* Based on the type, val shall be one of
710          * bt_bdaddr_t or bt_bdname_t or bt_scanmode_t etc
711          */
712         int (*set_adapter_property)(const bt_property_t *property);
713
714         /** Get all Remote Device properties */
715         int (*get_remote_device_properties)(bt_bdaddr_t *remote_addr);
716
717         /** Get Remote Device property of 'type' */
718         int (*get_remote_device_property)(bt_bdaddr_t *remote_addr,
719                         bt_property_type_t type);
720
721         /** Set Remote Device property of 'type' */
722         int (*set_remote_device_property)(bt_bdaddr_t *remote_addr,
723                         const bt_property_t *property);
724
725         /** Get Remote Device's service record  for the given UUID */
726         int (*get_remote_service_record)(bt_bdaddr_t *remote_addr,
727                         bt_uuid_t *uuid);
728
729         /** Start SDP to get remote services */
730         int (*get_remote_services)(bt_bdaddr_t *remote_addr);
731
732         /** Start Discovery */
733         int (*start_discovery)(void);
734
735 #ifdef TIZEN_BT_HAL
736         int (*start_custom_discovery)(bt_disc_role_type_t disc_type);
737 #endif
738
739         /** Cancel Discovery */
740         int (*cancel_discovery)(void);
741
742         /** Create Bluetooth Bonding */
743         int (*create_bond)(const bt_bdaddr_t *bd_addr, int transport);
744
745         /** Remove Bond */
746         int (*remove_bond)(const bt_bdaddr_t *bd_addr);
747
748         /** Cancel Bond */
749         int (*cancel_bond)(const bt_bdaddr_t *bd_addr);
750
751         /**
752          * Get the connection status for a given remote device.
753          * return value of 0 means the device is not connected,
754          * non-zero return status indicates an active connection.
755          */
756         int (*get_connection_state)(const bt_bdaddr_t *bd_addr);
757
758         /** BT Legacy PinKey Reply */
759         /** If accept==FALSE, then pin_len and pin_code shall be 0x0 */
760         int (*pin_reply)(const bt_bdaddr_t *bd_addr, uint8_t accept,
761                         uint8_t pin_len, bt_pin_code_t *pin_code);
762
763         /** BT SSP Reply - Just Works, Numeric Comparison and Passkey
764          * passkey shall be zero for BT_SSP_VARIANT_PASSKEY_COMPARISON &
765          * BT_SSP_VARIANT_CONSENT
766          * For BT_SSP_VARIANT_PASSKEY_ENTRY, if accept==FALSE, then passkey
767          * shall be zero */
768         int (*ssp_reply)(const bt_bdaddr_t *bd_addr, bt_ssp_variant_t variant,
769                         uint8_t accept, uint32_t passkey);
770
771         /** Get Bluetooth profile interface */
772         const void* (*get_profile_interface) (const char *profile_id);
773
774         /** Bluetooth Test Mode APIs - Bluetooth must be enabled for these APIs */
775         /* Configure DUT Mode - Use this mode to enter/exit DUT mode */
776         int (*dut_mode_configure)(uint8_t enable);
777
778         /* Send any test HCI (vendor-specific) command to the controller. Must be in DUT Mode */
779         int (*dut_mode_send)(uint16_t opcode, uint8_t *buf, uint8_t len);
780         /** BLE Test Mode APIs */
781         /* opcode MUST be one of: LE_Receiver_Test, LE_Transmitter_Test, LE_Test_End */
782         int (*le_test_mode)(uint16_t opcode, uint8_t *buf, uint8_t len);
783
784         /* enable or disable bluetooth HCI snoop log */
785         int (*config_hci_snoop_log)(uint8_t enable);
786
787         /** Sets the OS call-out functions that bluedroid needs for alarms and wake locks.
788          * This should be called immediately after a successful |init|.
789          */
790         int (*set_os_callouts)(bt_os_callouts_t *callouts);
791
792         /** Read Energy info details - return value indicates BT_STATUS_SUCCESS or BT_STATUS_NOT_READY
793          * Success indicates that the VSC command was sent to controller
794          */
795         int (*read_energy_info)();
796
797         /* Tizen Specific: Send  service level Authorization response */
798         int (*authorize_response)(const bt_bdaddr_t *bd_addr, bt_service_id_t service_id,
799                         uint8_t authorize, uint8_t save_settings);
800
801         /** Set auto authorization for peer device. Should be a paired device */
802         int (*set_authorization)(bt_bdaddr_t *bd_addr, uint8_t auth);
803 #ifdef TIZEN_BT_HAL
804         /**
805          * get the service connection status for a given remote device.
806          * return value of 0 means the device is not connected,
807          * non-zero return status indicates an active connection.
808          */
809         int (*get_service_connection_state)(const bt_bdaddr_t *bd_addr, bt_service_id_t rem_svc_id);
810
811         /*
812          * Enable/Disable osp server in gap agent.
813          * enable == 0/1 -> Register/Unregister osp server.
814          */
815         int (*set_agent_osp_server)(uint32_t type, uint8_t enable);
816
817         /**
818          * Set profile as trusted for remote device
819          */
820         int (*set_trusted_profile)(bt_bdaddr_t *bd_addr, bt_trusted_profile_t profile, uint8_t trust);
821
822         /**
823          * Get profile trusted status for remote device
824          */
825         int (*get_trusted_profile)(bt_bdaddr_t *bd_addr, bt_trusted_profile_t profile, uint32_t *trusted);
826
827         /**
828          * Get raw RSSI strength of remote device for connected link type
829          * conn_link_type: (0 = BR/EDR link, 1 = LE link, 0xFF = Any (Default))
830          */
831         int (*get_connected_link_rssi_strength)(bt_bdaddr_t *bd_addr, uint32_t conn_link_type);
832
833         /**
834          * Enable RSSI monitoring of remote device for connected link type
835          * conn_link_type: (0 = BR/EDR link, 1 = LE link, 0xFF = Any (Default))
836          * Threshold : (low_threshold, in_range_threshold, high_threshold)
837          */
838         int (*enable_rssi_monitoring)(bt_bdaddr_t *bd_addr, uint32_t conn_link_type,
839                         int low_threshold, int in_range_threshold, int high_threshold);
840         /*
841          * Enable/Disable GAP authentication notification to application
842          * enable == 0/1 -> Enable/Disable notification sending
843          * type == value from bt_gap_auth_variant_t
844          */
845         int (*enable_gap_auth_notifications)(uint32_t type, uint8_t enable);
846
847 #endif
848 } bt_interface_t;
849
850 /** TODO: Need to add APIs for Service Discovery, Service authorization and
851  *       connection management. Also need to add APIs for configuring
852  *       properties of remote bonded devices such as name, UUID etc. */
853
854 typedef struct {
855         struct hw_device_t common;
856         const bt_interface_t* (*get_bluetooth_interface)();
857 } bluetooth_device_t;
858
859 typedef bluetooth_device_t bluetooth_module_t;
860 __END_DECLS
861
862 #endif /* ANDROID_INCLUDE_BLUETOOTH_H */