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