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