#ifdef __cplusplus
extern "C" {
#endif
+#include <unistd.h>
+#include <dlog.h>
+#include <stdio.h>
+#include <signal.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <sys/socket.h>
#undef LOG_TAG
#define LOG_TAG "BLUETOOTH_HF_AGENT"
#define ERR_C(fmt, arg...) \
SLOGI_IF(TRUE, LOG_COLOR_RED" "fmt" "LOG_COLOR_RESET, ##arg)
-
-#include <unistd.h>
-#include <dlog.h>
-#include <stdio.h>
-#include <signal.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <inttypes.h>
-#include <sys/socket.h>
+#define retv_if(expr, val) \
+ do { \
+ if (expr) { \
+ ERR("(%s) return", #expr); \
+ return (val); \
+ } \
+ } while (0)
#define BTPROTO_SCO 2
-
#define BT_HF_DATA_BUF_SIZE 1024
#define BT_HF_CMD_BUF_SIZE 32
#define BT_HF_INDICATOR_DESCR_SIZE 20
#define BT_HF_CALLER_NUM_SIZE 64 /* size of number + type */
#define BT_HF_FMT_STR_SIZE 32
+#define BT_ADDRESS_LENGTH_MAX 6
+#define BT_ADAPTER_OBJECT_PATH_MAX 50
+#define AT_CMD_BUFF_SIZE 500
+#define BT_MAX_TEL_NUM_STR 100
#define BT_HF_AGENT_ERROR (__bt_hf_agent_error_quark())
#define BT_ERROR_ALREADY_EXIST "AlreadyExists"
#define BT_ERROR_ALREADY_CONNECTED "Already Connected"
#define BT_ERROR_NO_MEMORY "No memory"
+#define BT_ERROR_NO_DATA "No data"
#define BT_ERROR_I_O_ERROR "I/O error"
#define BT_ERROR_OPERATION_NOT_AVAILABLE "Operation currently not available"
#define BT_ERROR_OPERATION_NOT_ALLOWED "Operation not allowed"
#define BT_ERROR_OPERATION_NOT_SUPPORTED "Operation not supported"
#define BT_ERROR_INVALID_FILE_DESCRIPTOR "Invalid File Descriptor"
+#define BT_HF_OK_RESPONSE "\r\nOK\r\n"
+#define BT_HF_ERROR_RESPONSE "ERROR"
+#define BT_HF_SEC_ERROR_RESPONSE "SERR"
+
+/* dbus interfaces */
+#define BT_HF_SERVICE_NAME "org.bluez.hf_agent"
+#define BT_HF_AGENT_OBJECT_PATH "/org/bluez/handsfree_agent"
+#define BT_HF_SERVICE_INTERFACE "org.tizen.HfApp"
+#define BT_HF_BLUEZ_OBJECT_PATH "/org/tizen/handsfree"
+#define BT_HF_BLUEZ_INTERFACE "org.bluez.HandsfreeAgent"
+#define BLUEZ_SERVICE_NAME "org.bluez"
+#define BLUEZ_HF_INTERFACE_NAME "org.bluez.HandsfreeGateway"
+#define BLUEZ_PROFILE_MGMT_INTERFACE "org.bluez.ProfileManager1"
+#define BT_MANAGER_INTERFACE "org.freedesktop.DBus.ObjectManager"
+#define BT_ADAPTER_INTERFACE "org.bluez.Adapter1"
+
+#define BT_INTERFACES_ADDED "InterfacesAdded"
+#define BT_INTERFACES_REMOVED "InterfacesRemoved"
+
+/* Handsfree features */
+#define BT_HF_FEATURE_EC_ANDOR_NR 0x0001
+#define BT_HF_FEATURE_CALL_WAITING_AND_3WAY 0x0002
+#define BT_HF_FEATURE_CLI_PRESENTATION 0x0004
+#define BT_HF_FEATURE_VOICE_RECOGNITION 0x0008
+#define BT_HF_FEATURE_REMOTE_VOLUME_CONTROL 0x0010
+#define BT_HF_FEATURE_ENHANCED_CALL_STATUS 0x0020
+#define BT_HF_FEATURE_ENHANCED_CALL_CONTROL 0x0040
+#define BT_HF_FEATURE_CODEC_NEGOTIATION 0x0080
+
+/* Audio Gateway features */
+#define BT_AG_FEATURE_3WAY 0x1
+#define BT_AG_FEATURE_NREC 0x0002
+#define BT_AG_FEATURE_VOICE_RECOGNITION 0x0004
+#define BT_AG_FEATURE_INBAND_RINGTONE 0x0008
+#define BT_AG_FEATURE_VOICE_TAG 0x0010
+#define BT_AG_FEATURE_REJECT_CALL 0x0020
+#define BT_AG_FEATURE_ENHANCED_CALL_STATUS 0x0040
+#define BT_AG_FEATURE_ENHANCED_CALL_CONTROL 0x0080
+#define BT_AG_FEATURE_EXTENDED_RES_CODE 0x100
+#define BT_AG_FEATURE_CODEC_NEGOTIATION 0x0200
+
+/* SCO Codec types */
+#define BT_HF_CODEC_ID_CVSD 1
+#define BT_HF_CODEC_ID_MSBC 2
+
+/* AT commands */
+#define BT_HF_FEATURES "AT+BRSF=%d\r" /* = 0x7F = All features supported */
+#define BT_HF_INDICATORS_SUPP "AT+CIND=?\r"
+#define BT_HF_INDICATORS_VAL "AT+CIND?\r"
+#define BT_HF_INDICATORS_ENABLE "AT+CMER=3,0,0,1\r"
+#define BT_HF_HOLD_MPTY_SUPP "AT+CHLD=?\r"
+#define BT_HF_CALLER_IDENT_ENABLE "AT+CLIP=1\r"
+#define BT_HF_CARRIER_FORMAT "AT+COPS=3,0\r"
+#define BT_HF_EXTENDED_RESULT_CODE "AT+CMEE=1\r"
+#define BT_HF_INDICATORS_ACTIVATION "AT+BIA="
+#define BT_HF_ANSWER_CALL "ATA\r"
+#define BT_HF_END_CALL "AT+CHUP\r"
+#define BT_HF_REDIAL "AT+BLDN\r"
+#define BT_HF_DIAL_NO "ATD%.100s;\r"
+#define BT_HF_VOICE_RECOGNITION "AT+BVRA=%d\r"
+#define BT_HF_XSAT "AT+XSAT=00,TY,WA\r"
+#define BT_HF_BSSF "AT+BSSF=8\r"
+#define BT_HF_CALLLIST "AT+CLCC\r"
+#define BT_HF_AVAILABLE_CODEC "AT+BAC=%d,%d\r"
+#define BT_HF_CODEC_SELECT "AT+BCS=%d\r"
+#define BT_HF_SPEAKER_GAIN "AT+VGS=%d\r"
+#define BT_HF_DTMF "AT+VTS=%s\r"
+#define BT_HF_NREC "AT+NREC=0\r"
+#define BT_HF_CALLWAIT_NOTI_ENABLE "AT+CCWA=1\r"
+#define BT_HF_RELEASE_ALL "AT+CHLD=0\r"
+#define BT_HF_RELEASE_AND_ACCEPT "AT+CHLD=1\r"
+#define BT_HF_ACCEPT_AND_HOLD "AT+CHLD=2\r"
+#define BT_HF_JOIN_CALL "AT+CHLD=3\r"
+
+#define BT_HF_MAX_SPEAKER_GAIN 15
+#define BT_HF_MIN_SPEAKER_GAIN 0
+
+/* Hold and multipary services on AG */
+#define BT_HF_CHLD_0 0x01 /* Releases all held calls or sets User Busy for a waiting call */
+#define BT_HF_CHLD_1 0x02 /* Releases all active calls and accept others */
+#define BT_HF_CHLD_1x 0x04 /* Releases specified active call only (<idx>) */
+#define BT_HF_CHLD_2 0x08 /* Places all active calls on hold and accepts others */
+#define BT_HF_CHLD_2x 0x10 /* Place all calls on hold EXCEPT the call indicated by <idx> */
+#define BT_HF_CHLD_3 0x20 /* Adds a held call to the conversation */
+#define BT_HF_CHLD_4 0x40 /* Explicit Call Transfer */
+
+enum hfp_version {
+ HFP_VERSION_1_5 = 0x0105,
+ HFP_VERSION_1_6 = 0x0106,
+ HFP_VERSION_LATEST = HFP_VERSION_1_6,
+};
+
typedef enum {
BT_HF_AGENT_ERROR_NONE,
BT_HF_AGENT_ERROR_INTERNAL,
BT_HF_AGENT_ERROR_ALREADY_EXIST,
BT_HF_AGENT_ERROR_ALREADY_CONNECTED,
BT_HF_AGENT_ERROR_NO_MEMORY,
+ BT_HF_AGENT_ERROR_NO_DATA,
BT_HF_AGENT_ERROR_I_O_ERROR,
BT_HF_AGENT_ERROR_APPLICATION,
BT_HF_AGENT_ERROR_NOT_ALLOWED,
} bt_ag_cme_error_t;
typedef enum {
+ BT_HF_STATE_DISCONNECTED,
+ BT_HF_STATE_CONNECTED
+} bt_hf_state_t;
+
+typedef enum {
+ BT_HF_AUDIO_DISCONNECTED,
+ BT_HF_AUDIO_CONNECTED
+} bt_hf_sco_state_t;
+
+typedef enum {
BT_HF_CALL_DIR_OUTGOING,
BT_HF_CALL_DIR_INCOMING,
} bt_hf_call_direction_t;
-/* Call status as per spec */
typedef enum {
BT_HF_CALL_STAT_ACTIVE,
BT_HF_CALL_STAT_HELD,
BT_HF_CALL_STAT_WAITING,
} bt_hf_call_status_t;
-enum hfp_version {
- HFP_VERSION_1_5 = 0x0105,
- HFP_VERSION_1_6 = 0x0106,
- HFP_VERSION_LATEST = HFP_VERSION_1_6,
-};
-
-/*Handsfree supported features*/
-#define BT_HF_FEATURE_EC_ANDOR_NR 0x0001
-#define BT_HF_FEATURE_CALL_WAITING_AND_3WAY 0x0002
-#define BT_HF_FEATURE_CLI_PRESENTATION 0x0004
-#define BT_HF_FEATURE_VOICE_RECOGNITION 0x0008
-#define BT_HF_FEATURE_REMOTE_VOLUME_CONTROL 0x0010
-#define BT_HF_FEATURE_ENHANCED_CALL_STATUS 0x0020
-#define BT_HF_FEATURE_ENHANCED_CALL_CONTROL 0x0040
-#define BT_HF_FEATURE_CODEC_NEGOTIATION 0x0080
-
-/*AG suported feature*/
-#define BT_AG_FEATURE_3WAY 0x1
-#define BT_AG_FEATURE_NREC 0x0002
-#define BT_AG_FEATURE_EXTENDED_RES_CODE 0x100
-#define BT_AG_FEATURE_CODEC_NEGOTIATION 0x0200
-
-#define BT_HF_CODEC_ID_CVSD 1
-#define BT_HF_CODEC_ID_MSBC 2
-
-#define BT_HF_AUDIO_DISCONNECTED 0
-#define BT_HF_AUDIO_CONNECTED 1
-
-#define BT_MAX_TEL_NUM_STR 100
-
-#define BT_HF_FEATURES "AT+BRSF=%d\r" /* = 0x7F = All features supported */
-#define BT_HF_INDICATORS_SUPP "AT+CIND=?\r"
-#define BT_HF_INDICATORS_VAL "AT+CIND?\r"
-#define BT_HF_INDICATORS_ENABLE "AT+CMER=3,0,0,1\r"
-#define BT_HF_HOLD_MPTY_SUPP "AT+CHLD=?\r"
-#define BT_HF_CALLER_IDENT_ENABLE "AT+CLIP=1\r"
-#define BT_HF_CARRIER_FORMAT "AT+COPS=3,0\r"
-#define BT_HF_EXTENDED_RESULT_CODE "AT+CMEE=1\r"
-#define BT_HF_INDICATORS_ACTIVATION "AT+BIA="
-#define BT_HF_ANSWER_CALL "ATA\r"
-#define BT_HF_END_CALL "AT+CHUP\r"
-#define BT_HF_REDIAL "AT+BLDN\r"
-#define BT_HF_DIAL_NO "ATD%.100s;\r"
-#define BT_HF_VOICE_RECOGNITION "AT+BVRA=%d\r"
-#define BT_HF_XSAT "AT+XSAT=00,TY,WA\r"
-#define BT_HF_BSSF "AT+BSSF=8\r"
-#define BT_HF_CALLLIST "AT+CLCC\r"
-#define BT_HF_AVAILABLE_CODEC "AT+BAC=%d,%d\r"
-#define BT_HF_CODEC_SELECT "AT+BCS=%d\r"
-#define BT_HF_SPEAKER_GAIN "AT+VGS=%d\r"
-#define BT_HF_DTMF "AT+VTS=%s\r"
-#define BT_HF_NREC "AT+NREC=0\r"
-#define BT_HF_CALLWAIT_NOTI_ENABLE "AT+CCWA=1\r"
-#define BT_HF_RELEASE_ALL "AT+CHLD=0\r"
-#define BT_HF_RELEASE_AND_ACCEPT "AT+CHLD=1\r"
-#define BT_HF_ACCEPT_AND_HOLD "AT+CHLD=2\r"
-#define BT_HF_JOIN_CALL "AT+CHLD=3\r"
-
-#define BT_MAX_EVENT_STR_LENGTH 50
-#define BT_AGENT_SYSPOPUP_TIMEOUT_FOR_MULTIPLE_POPUPS 200
-
-#define BT_HF_MAX_SPEAKER_GAIN 15
-#define BT_HF_MIN_SPEAKER_GAIN 0
-
-
-typedef enum {
- BT_AGENT_EVENT_HANDSFREE_CONNECT = 0x1100,
- BT_AGENT_EVENT_HANDSFREE_DISCONNECT = 0x1200,
-} bt_hfp_agent_event_type_t;
-
-/* Hold and multipary AG features.
- * Comments below are copied from hands-free spec for reference */
-/* Releases all held calls or sets User Determined User Busy (UDUB)
- * for a waiting call */
-#define BT_HF_CHLD_0 0x01
-/* Releases all active calls (if any exist) and accepts the other
- * (held or waiting) call */
-#define BT_HF_CHLD_1 0x02
-/* Releases specified active call only <x> */
-#define BT_HF_CHLD_1x 0x04
-/* Places all active calls (if any exist) on hold and accepts the other
- * (held or waiting) call */
-#define BT_HF_CHLD_2 0x08
-/* Request private consultation mode with specified call <x> (Place all
- * calls on hold EXCEPT the call <x>) */
-#define BT_HF_CHLD_2x 0x10
-/* Adds a held call to the conversation */
-#define BT_HF_CHLD_3 0x20
-/* Connects the two calls and disconnects the subscriber from both calls
- * (Explicit Call Transfer). Support for this value and its associated
- * functionality is optional for the HF. */
-#define BT_HF_CHLD_4 0x40
-
-#define BT_HF_OK_RESPONSE "\r\nOK\r\n"
-#define BT_HF_ERROR_RESPONSE "ERROR"
-#define BT_HF_SEC_ERROR_RESPONSE "SERR"
-
-#define BT_HF_SERVICE_NAME "org.bluez.hf_agent"
-#define BT_HF_AGENT_OBJECT_PATH "/org/bluez/handsfree_agent"
-#define BT_HF_SERVICE_INTERFACE "org.tizen.HfApp"
-
-#define BT_HF_BLUEZ_OBJECT_PATH "/org/tizen/handsfree"
-#define BT_HF_BLUEZ_INTERFACE "org.bluez.HandsfreeAgent"
-
-#define BLUEZ_SERVICE_NAME "org.bluez"
-#define BLUEZ_HF_INTERFACE_NAME "org.bluez.HandsfreeGateway"
-
-#define PM_SERVICE_NAME "org.tizen.system.deviced"
-#define PM_OBJECT_PATH "/Org/Tizen/System/DeviceD/Display"
-#define PM_INTERFACE_NAME "org.tizen.system.deviced.display"
-#define AT_CMD_BUFF_SIZE 500
-#define BLUEZ_PROFILE_MGMT_INTERFACE "org.bluez.ProfileManager1"
-#define BT_MANAGER_INTERFACE "org.freedesktop.DBus.ObjectManager"
-#define BT_ADAPTER_INTERFACE "org.bluez.Adapter1"
-
-#define BT_INTERFACES_ADDED "InterfacesAdded"
-#define BT_INTERFACES_REMOVED "InterfacesRemoved"
-
-#define retv_if(expr, val) \
- do { \
- if (expr) { \
- ERR("(%s) return", #expr); \
- return (val); \
- } \
- } while (0)
-
-typedef enum {
- BT_HF_STATE_DISCONNECTED,
- BT_HF_STATE_CONNECTED
-} bt_hf_state_t;
-
typedef struct {
guint32 fd;
gint sco_fd;
gboolean is_dialing;
gboolean call_active;
+ gboolean inband_ringtone_support;
+ gboolean is_companion_dev;
guint ciev_call_status;
guint ciev_call_setup_status;
int timer_id;
} bt_hf_agent_send_at_info;
-struct hf_event {
+typedef struct {
const char *cmd;
int (*callback) (bt_hf_agent_info_t *bt_hf_info, const char *buf);
-};
+} bt_hf_event;
typedef struct {
unsigned char b[6];