mcu_hi3321_watch/tjd/ui/app/phone/phone_service/TjdPhoneService.h
2025-05-26 20:15:20 +08:00

120 lines
3.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*----------------------------------------------------------------------------
* Copyright (c) TJD Technologies Co., Ltd. 2025. All rights reserved.
*
* Description: TjdPhoneService.h
*
* Author: luziquan@ss-tjd.com
*
* Create: 2025-08-16
*--------------------------------------------------------------------------*/
#ifndef PHONE_SERVICE_H
#define PHONE_SERVICE_H
#include "bts_br_gap.h"
#include "bts_hfp_hf.h"
#include "stdint.h"
#ifdef __cplusplus
extern "C"
{
#endif
#define MULTI_CALL_MAX_NUME 5 // 最大多路通话路数
#define CALL_LOG_MAX_NUM 20 // 最多记录20条通话记录超出后删除最老的记录
#define NAME_SIZE 20
#define MAX_PHONE_NUM 20
#define CALL_VOLUME_MAX 15
typedef enum
{
OPERATE_NO_OPE = 0, // 无操作
OPERATE_DIALING, // 呼出,正在拨号中
OPERATE_ALERTING, // 呼出,对方响铃
OPERATE_INCOMING, // 来电呼入
OPERATE_WAITING, // 来电呼入(等待)
OPERATE_WATCH_ACTIVE, // 对方呼入,手表接听
OPERATE_PHONE_ACTIVE, // 对方呼入,手机接听 (手表接收到此操作调用DisconnectSco接口断开SCO连接)
OPERATE_PEER_ACTIVE, // 呼出,对方接听
OPERATE_PHONE_HOLD, // 手机挂起通话
OPERATE_WATCH_REJECT, // 手表拒接来电
OPERATE_WATCH_FINISH, // 手表发起通话结束(挂断通话)
OPERATE_NON_WATCH_FINISH, // 非手表发起通话结束(手机挂断+拒接来电)
} CurOperateType;
/**
* @brief 联系人信息
*/
typedef struct
{
int operate;
int lastStatus;
char name[NAME_SIZE];
unsigned char nameLen;
unsigned char tel[MAX_PHONE_NUM];
unsigned char telLen;
uint64_t activeTime; // 首次电话接通时间点
uint64_t creationTime; // 通话创建时间(不是接通时间)
hfp_hf_calls_info_t unitCalls;
} ContactsInfo;
// 通话失败类型
typedef enum
{
ERROR_BT = 0, // 蓝牙
ERROR_DIAL, // 拨号
} PhoneServiceErrorType;
// 通话结束类型
typedef enum
{
CALL_OUTGOING = 0, // 呼出电话
CALL_INCOMING, // 呼入电话
CALL_MISSED, // 未接来电
} CallLogType;
typedef struct
{
char name[NAME_SIZE];
unsigned char nameLen;
unsigned char tel[MAX_PHONE_NUM];
unsigned char telLen;
CallLogType status;
uint64_t creationTime; // 通话创建时间(不是接通时间)
uint64_t callDurTime; // 通话持续时间
} CallLogInfo;
void TjdPhoneServiceInit(void);
uint32_t GetCallAudioCodec(void);
bd_addr_t *GetHfpBdAddr(void);
// 通话状态改变回调函数
typedef void (*PhoneServiceCallChangedCb)(const ContactsInfo *phoneCall);
// 电话服务失败回调函数
typedef void (*PhoneServiceErrorCb)(PhoneServiceErrorType type, int volume);
// sco连接回调函数状态只有断开和连接两种状态 通话转移会导致sco连接和断连
typedef void (*PhoneServiceScoStatusCb)(hfp_sco_connect_state_t state);
typedef struct
{
PhoneServiceCallChangedCb callChanged;
PhoneServiceErrorCb phoneServiceErrorCb;
PhoneServiceScoStatusCb scoStatusCb;
} PhoneServiceCb;
int RegisterPhoneCallChangedCb(PhoneServiceCb *phoneServiceFun);
int DialCallOut(const unsigned char *number, unsigned char len);
int AnswerCallIn(void);
int RejectCallIn(void);
int DialCallFinish(void);
int GetCurCallNumber(void);
unsigned char GetHFPCallCurrVolume(void);
void SetHFPSpeakerVolume(unsigned char hfpVolume);
#ifdef __cplusplus
}
#endif
#endif // PHONE_SERVICE_H