Tange Cloud for Device
 Rev.355
载入中...
搜索中...
未找到
TgCloudApi.h
浏览该文件的文档.
1/**
2 * @file TgCloudApi.h
3 * @brief 探鸽云SDK接口申明
4 */
5#ifndef __TgCloudApi_h__
6#define __TgCloudApi_h__
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <stdint.h>
13#include <time.h>
14#include "TgCloudConst.h"
15#include "TgCloudCmd.h"
16#include "TgCloudCmdEx.h"
17#include "ec_const.h"
18#include "TgCloudUtil.h"
19
20
21/** \addtogroup api_const
22 * @{*/
23/** sim 卡类型 */
24typedef enum {
25 SIMT_PHY, ///< 物理卡
26 SIMT_ESIM, ///< ESIM
27 SIMT_VSIM ///< vsim卡
29
30/** 低功耗设备的工作模式 */
31typedef enum {
32 PM_ALLON, ///< 常电模式。非低功耗设备的默认模式
33 PM_SLEEPABLE, ///< 系统可休眠(会收到STATUS_IDLE状态回调。这是低功耗设备的默认模式)
34 PM_NETDOWN ///< 主控正常工作,网络模块进入休眠模式
36
37/** 传输内容 */
38typedef enum {
39 TRANS_SERVICE_LIVE_AV = 0,
40 TRANS_SERVICE_AUDIO_PIC = 1,
41 TRANS_SERVICE_PIC_ONLY = 2,
42 TRANS_SERVICE_MAX
44
45/** SDK选项常数 */
46typedef enum {
47 /** 有人观看时禁止上传
48 * 类型: int*
49 * - 1 disable
50 * - 0 Allow parallel operation
51 */
53
54 /** 云存储缓冲文件数.
55 * 类型: int*: 1~6
56 */
58
59 /** 传输内容
60 * 类型: int*:
61 * - 0 live video/audio
62 * - 1 picture+audio
63 * - 2 picture only.
64 * @ref ETRANSSERVICE.
65 */
67
68#if 0
69 /** tcp连接方式
70 * 类型 int*:
71 * - 0 default
72 * - 1 并发
73 */
74 TCOPT_TCP_CONNECTOR = 4,
75#endif
76
77 /** backstore 存储天数
78 * 类型 int*:
79 * - 0 同云服务保存天数
80 * - >0 自定义的存储天数.不超过服务规定的天数
81 */
83
84 /** 最大云存data文件。超出的帧会丢弃.
85 * 类型: int*
86 */
88
89 /** 仅上报AI事件.
90 * 类型: int*
91 */
93
94 /** 用户没有应答不能拉流. 用于楼宇对讲
95 * 类型: int *
96 */
98
99 /** 事件云存预录时间长度, 单位:秒.
100 * 类型: int *
101 * 说明: 默认为5\". 实际长度受云存缓存大小限制。记住录像总时长是不变的.
102 */
104
105 /* Don't genera event&record for wxvoip */
106 TCOPT_NO_WX_EVENT = 10,
107 /* Set by VDP */
108 TCOPT_UNIFORMED_CALL_PROCESS = 11
110
111/** @anchor sdk_state_flags */
112/** @name SDK状态标志
113 * @{*/
114#define TGSS_F_CS_INSERVICE 0x00000001 ///< 云文件正在上传或者新文件正在打包
115#define TGSS_F_P2P_CONNECTED 0x00000002 ///< 有用户连接
116#define TGSS_F_P2P_STREAMING 0x00000004 ///< 用户正在拉流
117#define TGSS_F_P2P_INSETTING 0x00000008 ///< 用户处在设置界面
118#define TGSS_F_BS_UPLOADING 0x00000010 ///< 后备存储正在上传
119#define TGSS_F_CALL_PENDING 0x00000020 ///< 呼叫正在等待处理
120#define TGSS_F_IN_CONVERSATION 0x00000040 ///< 呼叫通话中
121/**@}*/
122
123/**@}*/ //group api_const
124
125/** \defgroup api_structure API数据结构
126 * API接口用到的数据结构
127 * @{*/
128/** 设备基本信息 */
129typedef struct TCIDEVICEINFO {
130 char device_type[16]; ///< Not used
131 char vendor[16]; ///<设备生产厂商 OEM
132 char firmware_id[32]; ///<ota 升级用的固件标识, 平台唯一. 两款设备,如果升级包一样,就有相同的 firmware_id。
133 ///< 可以按 "公司_方案_设备类型_其它信息" 的规则自己定义一个字符串, 例如: "TANGE_HISI_IPC_001".
134 ///< 标识里不能有"."。
135 ///< 平台按字符串比较,不关心具体内容.
136 char firmware_ver[10]; ///< 固件主版本,8个数字组成的字符串。like: "03020201", means 3.2.2.1.
137 char model[32]; ///< 产品型号
139
140/** 云服务信息 */
141typedef struct TCISERVICEINFO {
142 ECSERVICETYPE serviceType; ///< 云服务类型
143 time_t expiration; ///< 过期时间(utc)
144 union {
145 uint32_t sub_type;
146 /**< 当 serviceType = @ref ECGS_TYPE_STORAGE, sub_type 为云存服务子类型:
147 * - EC_SVC_EVENT: 事件录像
148 * - EC_SVC_CONTINUOUS: 全天录像
149 * - EC_SVC_FOR_AI: 仅为ai服务提供短录像,其它事件不录像
150 * - EC_SVC_IMAGE_N: 保存N张图片
151 */
152
153 char *objects;
154 /**< 当 serviceType = @ref ECGS_TYPE_AI, objects 为
155 * '\0'结尾并以一个额外 '\0'结束的允许检测的ai对象列表。例如: "body\0car\0cry\0"
156 */
157 };
159
160/** p2p连接句柄. A opaque pointer */
161typedef void *p2phandle_t;
162/** 命令回调类型 */
163typedef int (*TGCMDHANDLER)(p2phandle_t handle, int cmd, const void *data, int len);
164
165/*
166typedef uint64_t feature_map_t;
167void FEATURE_ZERO(feature_map_t *fm);
168int FEATURE_SET(feature_map_t *fm, feature_t f);
169int HAS_FEATURE(const feature_map_t *fm, feature_t f);
170*/
171
172/** P2P发送统计数据结构 */
174 short id; ///< 用户(连接)标识
175 short vchannel; ///< 视频通道
176 short vstream; ///< 码流
177 short is_igop; ///< 1:统计间隔为一个I帧间隔; 0:周期约为~1s
178 int nBytesInBuff; ///< 位于发送缓冲区的字节数
179 int nBytesSent; ///< 已经发送的字节数
180 int nBytesTotal; ///< 总共收到的字节数
181 int nBytesThrow; ///< 丢掉的字节数。丢包会持续到到一个I帧,这期间即使网络恢复也会丢,所以其值只能作为参考, 不能用于计算网速
182 int msStatInterval; ///< 统计周期(单位: ms)
183};
184
185/** sdk 回调函数结构 */
186struct TciCB {
187 /** 获取设备基本信息 */
188 int (*get_info)(TCIDEVICEINFO *info);
189
190 //int (*on_get_features)(feature_map_t *features);
191
192/** 设备能力. 参见 @ref DeviceFeatures
193 \param key 能力名
194 \param buf 返回能力描述的缓冲区
195 \param size 缓冲区大小
196 \retval 0 ok
197 \retval <0 failed(not recognize)
198*/
199 int (*get_feature)(const char *key, char *buf, int size);
200
201 /** 取设备当前状态或初始默认设置.
202 *
203 * \param key 状态名
204 * \li \c CVideoQuality 云录像清晰度. 格式: <tt>stream:channel</tt>
205 * \li \c streamQuality 实时视频默认码流. 格式: <tt>stream:channel</tt>
206 * - \c stream 码流: 0-高清; 1-标清
207 * - \c channel 视频通道号: 0, 1, ...
208 *
209 * \li \c mac 设备mac地址, null结尾的12个十六进制字符
210 * \li \c versions 版本号的json数组。格式: ["main_ver", "sub_ver1", ...]. 版本号为8个数字级成的字符串如"01000208"(=1.0.2.8)
211 *
212 * \param buf 返回值缓冲区
213 * \param size 缓冲区大小
214 *
215 */
216 int (*get_state)(const char *key, char *buf, int size);
217
218 /** 直连模式下用户登录帐号检查
219 * \param user 用户名, 目前未使用
220 * \param key 用户密码加密
221 * \retval 1 验证成功
222 * \retval 0 失败
223 */
224 int (*on_apmode_login)(const char *user, const char *key);
225
226/**
227 * @name OTA接口
228 * @{
229 */
230 /** OTA升级开始
231 * \param new_version 升级包版本
232 * \param size 升级包大小
233 * \return 0 升级继续; -1 升级中止
234 */
235 int (*on_ota_download_start)(const char *new_version, unsigned int size);
236
237 /** 升级包数据
238 * 升级包下载过程中,sdk调用此回调将数据传给应用层
239 * \param buff 数据
240 * \param size 数据长度
241 * \return 0 继续; -1 传输中止
242 */
243 int (*on_ota_download_data)(const uint8_t *buff, int size);
244
245 /** 升级包下载结束
246 * \param status 完成状态: 0-ok, 可以执行升级; 1-下载中断; 2-数据校验错
247 * \retval -1 应用中止升级过程
248 * \retval 0 如果应用可以立即执行升级,可以返回0表示升级成功
249 * \retval 1 如果应用要退出进程再升级,返回1通知APP等待.
250 * @note 因为返回0/1后应用会退出,不保证APP端一定能收到应答
251 */
252 int (*on_ota_download_finished)(int status);
253/**@}*/
254
255
256/**
257 * @name 二维码扫描
258 * @{
259 */
260 /** 二维码扫描开始
261 * 应用层在此开启取Y数据的通道
262 * \return 0 ok; -1 failed
263 */
264 int (*qrcode_start)(void);
265
266 /** 获取Y图片
267 * \param[in,out] ppYBuff
268 * \param[out] width 返回图片宽度
269 * \param[out] height 返回图片高度
270 * \return 0 ok; -1 停止扫描
271 * @note 第一次调用时 *ppYBuff为NULL. 应用层在此分配一个缓冲区, 填入Y数据,并把缓冲区指针保存到*ppYBuff.
272 * 之后的调用 *ppYBuff为之前设置的值
273 */
274 int (*qrcode_get_y_data)(uint8_t **ppYBuff, int *width, int *height);
275
276 /** 结束二维码扫描
277 * \param ppYBuff *ppYBuff中为最后一次在on_get_y_data中返回的值
278 * @note 应用层在此释放前面分配的内存(free(*ppYBuff)), 关闭Y通道
279 */
280 void (*qrcode_end)(uint8_t *pYBuff);
281/**@}*/
282
283 /** 抓取图片. 目前只支持jpeg格式
284 * \param type @ref pic_type "图片类型" in TciCloudConst.h
285 * \param ppJgp *ppJpg为图片地址或用于返回图片的址.见note
286 * \param size 返回时*size为图片字节数
287 * \return 0 ok; @ref TCE_BUFFER_TOO_SMALL; -1 其它错误
288 * @note 如果*ppJpg为NULL,应用层分配图片空间, 空间指针和图片大小分别保存在*ppJpg和*size. sdk内部负责释放空间。
289 * 如果*ppJpg为非空,*ppJpg为SDK内分配的空间地址,*size为空间大小。返回时*size为实际图片大小
290 */
291 int (*snapshot)(int type, uint8_t **ppJpg, int *size); //??
292
293 /** 设置wifi参数
294 * \param is_switching 0:配网; 1:添加成功后修改wifi
295 * \return 0 配置ok; -1 配置不对
296 * \note 返回时, wifi处在station模式
297 */
298 int (*set_wifi)(int is_switching, const char *ssid, const char *key);
299
300 /** 设置时区
301 * \param tzs 时区字符串. Refer to man page of tzset().
302 */
303 int (*set_timezone)(const char *tzs);
304
305 /** 设置时间
306 * \param time utc 时间
307 */
308 int (*set_time)(time_t time);
309
310 /** sdk内部状态
311 * \param status 状态. Refer to @ref ESTATUSCODE in TgCloudConst.h
312 * \param pData 状态相关数据
313 * \return 返回值同event的值有关. 请查看 @ref ESTATUSCODE。默认返回0
314 */
315 int (*on_status)(int event, const void *pData, int len);
316
317
318/**
319 * @name 对讲
320 * @{
321 */
322 /** 开始对讲
323 * \return 0 ok; -1 中断
324 */
325 int (*on_talkback_start)(void);
326
327 /** 对讲数据回调
328 * 格式在前面已经协商过
329 * \return 0 if played
330 */
331 int (*talkback)(TCMEDIA at, const uint8_t *audio, int len);
332
333 /** 结束对讲 */
334 void (*on_talkback_stop)(void);
335/**@}*/
336
337 /** @deprecated
338 * 请求I帧. 请使用 request_iframe_ex
339 * \param vstream 视频流. 0-主码流; 1-辅码流
340 * \return 0
341 */
342 int (*request_iframe)(int vstream);
343
344 /** 当AI识别成功,通过本回调通知应用. (本回调未使用,设为NULL)
345 * \param type \ref pic_type "图片类别指示"
346 * \param pJpg 正识别图片
347 * \param len 图片长度
348 */
349 void (*ai_result)(int type, const uint8_t* pJpg, int len);
350
351 /** 在平台端采集设备日志
352 * \param action
353 * - 0-开始长日志采集;
354 * - 1-停止长日志采集;
355 * - 2-获取日志文件用于上传云端. 文件路径不能有空格
356 * - 102-获取日志文件用于传给app。文件只支持文本格式, 路径不能有空格
357 *
358 * \param logfile 同action有关。
359 * - action为0或1时, logfile为NULL
360 * - 当action为2时, logfile用于应用层返回日志文件路径. 多个路径用';'分隔,总长不超过256
361 *
362 * \return 0:ok; -1:failed
363 *
364 * \note 上传会对文件内容作校验,所以上传期间不能修改日志文件内容,应用需要把要上传的文件 \n
365 * 分离出来, 或者在收到上传回调后的一段时间不要更新日志文件内容.
366 */
367 int (*log)(int action, char *logfile);
368
369 /** 请求指定图像通道的I帧
370 * \param channel 图像通道
371 * \param vstream 视频流. 0-主码流; 1-辅码流
372 * \return 0
373 */
374 int (*request_iframe_ex)(int channel, int vstream);
375
376 /** 网络传输统计回调 */
377 void (*trans_stat)(const struct TransStatUser *_stat);
378
379 /** 切换图像质量
380 * @param channel 图像通道。目前为0
381 * @param stream 码流 0,1,..., 在"Resolutions"能力中返回
382 * @param qstr 质量描述串, 例如 HD/SD/FHD/..., 在"Resolutions"能力中返回.
383 */
384 void (*switch_quality)(int channel, int stream, const char *qstr);
385
386 /** 对讲数据回调.
387 * @param mt 数据类型 @ref TCMEDIA
388 * @param ts 时间戳
389 * @param data 媒体帧
390 * @param len 帧长度
391 * @param uFrameFlags 参见 TciSendFrameEx()
392 */
393 void (*talkback_ex)(int mt, unsigned int ts, const void *data, int len, unsigned int uFrameFlags);
394};
395
396/** IPv4 地址表示(网络字节顺序) */
397typedef struct Ipv4Addr {
398 unsigned int ip; ///< ip, network byte-order
399 unsigned short port; ///< port, network byte-order
400} Ipv4Addr;
401
402/** Simple Buffer */
403typedef struct SIMPLEBUFFER {
404 uint8_t *data; ///< 数据缓冲区指针
405 int size; ///< 缓冲区大小
406 int len; ///< 数据长度
408
409/** 参数文件读写函数据指针结构 */
411 /** 分配缓冲区,并读出参数文件.
412 * @param buff 缓冲区结构指针. 由实现填充结构成员。缓冲区大小为参数文件大小加上 cbExtra
413 * @param cbExtra 额外分配的字节数
414 * @retval 1 ok
415 * @retval 0 failed
416 */
417 int (*alloc_and_readall)(SIMPLEBUFFER *buff, int cbExtra);
418
419 /** 写参数文件
420 * @param buff 参数缓冲区指针
421 * @retval 1 ok
422 * @retval 0 failed
423 */
424 int (*save_buff)(const SIMPLEBUFFER *buff);
425
426 /** 释放参数缓冲区 */
427 void (*free_buff)(SIMPLEBUFFER *buff);
428
429 /** 删除参数文件(或者清空参数文件)。下一次读出时 len为0 */
430 void (*remove)(void);
431};
432
433/** 用户文件下载目的地.
434 * @ref TciGetUserFile() */
435union TgfDest {
436 /** 数据下载到文件 */
437 struct to_file {
438 char *path; ///< IN: file path
439 } file;
440 /** 数据下载到内存 */
441 struct to_mem {
442 void *mem; ///< OUT: 指向sdk分配的内存
443 int size; ///< OUT: 数据长度
444 } mem;
445};
446
447/** 设备升级包信息 */
448typedef struct DEVICEOTAINFO {
449 int size; ///< 升级包大小
450 char ver[16]; ///< 升级包版本
451 char md5[36]; ///< md5 检验字符串
452 char url[256]; ///< 下载地址
454
455/** 4G 设备信息 */
456typedef struct TG4GINFO {
457 char imei[24]; ///< 4g模块标识
458 char iccid[24]; ///< sim卡号
459 SIMCARDTYPE sim_type; ///< sim卡类型
460} TG4GINFO;
461
462
463/**@}*///{group api_structure}
464
465/** \defgroup api_reference API参考
466 * @{*/
467
468/** \name 核心API
469 * @{*/
470
471/** 获取SDK版本号
472 * TciInit()之后调用
473 * \return SDK版本号字符串。如:"rev. nn"
474 */
475const char *TciGetVersion(void);
476
477/** 配置基本参数
478 * 在TciStart()之前调用
479 * \param path 用于保存sdk私有数据的目录, 需要有读写权限
480 * \param uuid 设备id. 新的id参数为 \"<i>uuid</i>,<i>key</i>\" 的形式, 烧号时由服务器分配
481 * \return 0
482 */
483int TciInit(const char *path, const char *uuid);
484
485/** 启动服务
486 * @pre 调用本接口前需要保证网络已经配置好
487 * 本调用阻塞直到内部完成初始化或操作失败
488 * \param isBound 设备本地记录的绑定状态. 复位或在TciCB::on_status()里 @ref STATUS_DELETED 时清除。收到 @ref STATUS_LOGON 时设置并保存
489 * \param uCloudBuffSize 云存储缓冲区大小(单位:字节). 要求能缓存3~5秒音视频数据, 为0会禁用云存
490 * \retval 0 启动成功
491 * \retval others. Refer to @ref error_code "错误码"
492 * @ref TgCloudConst.h
493 */
494int TciStart(int isBound, unsigned int uCloudBuffSize);
495
496/** 启动服务.
497 * @param uuid 设备id. 新的id参数为 \"<i><uuid></i>,<i><key></i>" 的形式, 烧号时由服务器分配
498 * @note
499 * 这个接口用于 TciInit() 没有传 uuid 参数的情形. 例如工厂生产测试烧号后立即 \n
500 * 启动服务。烧号前调用TciInit()时uuid为NULL, 烧号后可以在这里传入uuid。
501 * 其它参数和返回值同 TciStart()
502 */
503int TciStart2(int isBound, unsigned int uCloudBuffSize, const char *uuid);
504
505
506/** 停止服务
507 * @pre TciStart() 返回0
508 * @return 0(成功), 或 @ref TCE_SERVER_IS_DOWN, @ref TCE_INVALID_UUID
509 * @ref TgCloudConst.h
510 */
511int TciStop(void);
512
513/** 释放资源
514 * @pre TciStop()
515 * @return Always return 0
516 */
517int TciCleanup(void);
518
519/** 注册回调 -- sdk内部事件
520 * \param cb 非局部TciCB结构指针
521 * \return 0
522 * @note 在 TciInit() 前调用
523 */
524int TciSetCallback(const struct TciCB *cb);
525
526/** 注册通用命令回调
527 * 在回调里处理APP发来的命令请求
528 * @note 在 TciInit() 前调用
529 */
531
532/** 绑定应用私有数据指针到p2p handle
533 * @param[in] handle P2P句柄, 来自命令回调
534 * @param[in] pUser 应用私有数据指针
535 */
536void TciSetSessionUserData(p2phandle_t handle, void *pUser);
537
538/** 返回由TciSetSessionUserData()设置的应用私有数据指针
539 * @param[in] handle P2P句柄
540 * @retval 返回P2P句柄绑定的应用私有数据,没有则返回NULL
541 */
543
544/** 控制日志输出. 应该在TciInit()前调用
545 * @param b_output_to_console 是否输出到控制台
546 * @param log_path log文件路径。应该是一个全局或静态的字符串指针. 为NULL时不创建日志文件
547 * @param max_log_size 日志文件最大尺寸(单位:byte)
548 */
549void TciSetLogOption(int b_output_to_console, const char *log_path, int max_log_size);
550
551/** 设置SDK日志输出等级.
552 * @param level 3:Information(default); 5:verbose; 6:debug
553 */
554void TciSetLogLevel(int level);
555
556/** 设置云存储录像通道的码流
557 * @param channel 视频通道
558 * @param stream 码流: 0-主; 1-辅
559 * @note 本接口拟用于画中画设备. \n
560 * 当收到 @ref TCI_CMD_SET_PRIMARY_VIEW 命令时,设备可能希望云录像通道与实时画面一致,就可以调用此接口. \n
561 * 非此情形,用户可以通过App发送 @ref TCI_CMD_SET_CLOUD_VIDEO_QUALITY_REQ 来显式设置云录像通道和码流。这一命令在sdk内部处理, 不会回调给应用层.
562 */
563void TciSetCloudStream(int channel, int stream);
564
565/** 通用sdk工作选项设置接口.
566 * @param opt 选项名. @ref TCSYSOPTION
567 * @param pVal 传入选项值
568 * @return >=0:ok; <0:错误
569 */
570int TciSetSysOption(TCSYSOPTION opt, const void *pVal);
571
572/** 通用sdk工作选项获取接口.
573 * @param opt 选项名. @ref TCSYSOPTION
574 * @param pVal 返回选项的值
575 * @return >=0:ok; <0:错误
576 */
577int TciGetSysOption(TCSYSOPTION opt, void *pVal);
578
579/** 开启p2p功能,进入厂测状态.
580 * @param key_path key 文件路径
581 * @retval 0 ok
582 * @retval -1 failed
583 */
584int TciStartInTestMode(const char *key_path);
585
586/**@}*/ //name 核心API
587
588/** \name 上报事件/状态/其它数据到平台
589 * @{*/
590/** 上报事件。本版本允许附带事件特定参数.
591 * @param evtp 事件参数指针
592 * @return 0:事件已经排队等待发送; non-zeor:错误码
593 * @note 本操作是异步的,返回0后要求evtp->jpg_pic仍然有效。 \n
594 * 如果evtp->evtp_flags 最低位非0, 上传结束后sdk会释放空间. \n
595 * evtp->evtp_flags最低位为0,用于jpg_pic为全局空间的情形. \n
596 * 返回非0时,调用者要自己释放图片空间.
597 */
599
600/** 停止事件, 仅少数事件才有意义.
601 * @param evt ECEVENT_DOORBELL 为取消呼叫.
602 * @note 取消呼叫时, sdk内部自动取呼叫的时间
603 */
605
606/** 门锁事件上报。图片和录像都在内部处理了.
607 * 参数见外部文档
608 */
609int TciSetLockEvent(int cls, int msg, int usrtyp, int usrid);
610
611/** 包装了门铃事件 */
613
614/** @deprecated
615 * 上报4G设备信息. 请使用 TciReport4GInfoEx()
616 * @param imei
617 * @param iccid
618 * @param state G4STATE_xxx
619 * @return 0:成功; <0:错误码
620 */
621int TciReport4GInfo(const char *imei, const char *iccid, ECG4STATE state);
622
623/** 上报4G设备信息,代替 TciReport4GInfo()
624 * @param info 指向4G信息结构
625 * @param state 4G联网状态
626 * @return 0:成功; <0:错误码
627 */
628int TciReport4GInfoEx(const TG4GINFO *info, ECG4STATE state);
629
630/** 上报GPS信息
631 * @param time 当前时间
632 * @param longitude 当前经度值(单位:度). >0 东经,<0 西经
633 * @param latitude 当前纬度值(单位:度). >0 北纬,<0 南纬
634 * @param speed 速度 km/h
635 * @param angle 对正北方向的夹角: 0~359
636 * @param signal_strength 0:未知(忽略); 1:弱; 2:中; 3:强
637 * @return 0:ok; non-zero: error code
638*/
639int TciReportGpsInfo(const unsigned int time, const double longitude, const double latitude,
640 double speed, int angle , int signal_strength);
641
642/** 上报电池状态
643 * @param qoe 电池电量百分比(0~100); -1:未知
644 * @param qoe_low
645 * - 1: 电量低;
646 * - 0: 电量正常;
647 * - -1:未知
648 * @param charging 1-正在充电; 0-放电状态
649 * @return 0-成功; 非0-错误码
650 */
651int TciReportBatteryStatus(int qoe, int qoe_low, int charging);
652
653/** 报告系统运行时状态
654 @param state 状态名. @ref ENUMRTSTATE
655 * @param pData state 相关参数。具体见
656 */
657void TciSetRtState(ENUMRTSTATE state, void *pData);
658
659/** 发送用户自定义数据到第三方平台.
660 * 需要平台间对接
661 */
662int TciSendUserData(const unsigned char *data, int len);
663
664/**@}*/ //name 上报事件
665
666/** \name 发送音视频和消息
667 * 这个数据通过p2p通道传给App。或者,如果有服务,音视频会上传云端
668 * @{*/
669
670/** 发送p2p命令请求
671 * @param handle 连接句柄,由 TciSetCmdHandler()设置的回调被调用时会收到此句柄
672 * @param cmd 命令标识
673 * @param data 指向命令参数
674 * @param dataSize 参数长度
675 * @return 0 或 \ref error_code "错误码"
676 */
677int TciSendCmd(p2phandle_t handle, unsigned int cmd, const void *data, int dataSize);
678
679/** 发送p2p命令应答
680 * @param handle 连接句柄,由 TciSetCmdHandler()设置的回调被调用时会收到此句柄
681 * @param cmd 命令标识
682 * @param data 指向命令参数
683 * @param dataSize 参数长度
684 * @return 0 或 \ref error_code "错误码"
685 */
686int TciSendCmdResp(p2phandle_t handle, unsigned int cmd, const void *data, int dataSize);
687
688/** 发送一个 Tcis_ErrorResp 结构作应答.
689 * 这个应答用于只需要简单地通知客户端命令执行成功或失败的情形.
690 * @param handle P2P句柄
691 * @param cmd 命令标识
692 * @param status @ref TCI_OK 或 TCI_E_xxx, 参见 @ref generic_err_code "通用错误码"
693 * @return 0 或 \ref error_code "错误码"
694 */
695int TciSendCmdRespStatus(p2phandle_t handle, unsigned int cmd, unsigned int status);
696
697/** 回放时发送数据帧.
698 * @param handle 连接句柄
699 * @param id_mt 低16位:媒体数据类型 @ref TCMEDIA ; 高16位:视频通道号(0~N-1)
700 * @param frame 帧数据指针
701 * @param len 帧数据长度
702 * @param timestamp 帧的时间戳
703 * @param uFrameFlags 视频:关键帧标志(1:关键帧;0:非关键帧); 音频: @ref audio_sample_fmt "音频采样格式"
704 * @retval >0 ok
705 * @retval 0 当前为回放暂停状态。
706 * @retval TCE_NETWORK_BUSY @ref TCE_NETWORK_BUSY :网络拥堵,应用层要延迟一会儿(例如300ms)后重新发送
707 * @retval -1 其它错误,通常意味着连接无效
708 * @note 每次设备在文件内或文件间重新定位, 或者自动跳到下一个文件,要通过 TciSendPbSyncFrame 先发一个绝对时间同步帧.
709 *
710 * @see TciSendPbSyncFrame
711 */
712int TciSendPbFrame(p2phandle_t handle, uint32_t id_mt, const uint8_t *frame, int len, uint32_t timestamp, int uFrameFlags);
713
714/** 在回放流中插入消息.
715 * @param handle p2p连接句柄。
716 * @param type 消息类型
717 * @param data1 @ref RTMSGHEAD_t::data1
718 * @param data2 @ref RTMSGHEAD_t::data2
719 * @param data_len 额外数据长度 @ref RTMSGHEAD_t::frame_size
720 * @param data 指向额外数据
721 */
722int TciSendPbMessage(p2phandle_t handle, RTMTYPE type, unsigned int data1, unsigned int data2, const void *data, int data_len);
723
724/** \def TciSendPbSyncFrame
725 * 发送回放时间同步帧.
726 * @param handle p2p 连接句柄
727 * @param utc_time 下一帧的生成时间(utc, 单位s)
728 * @param is_response_to_PLAY_START 1:响应 @ref TCI_CMD_RECORD_PLAYCONTROL; 0:自动跳到下一个文件
729 */
730#define TciSendPbSyncFrame(handle, utc_time, is_response_to_PLAY_START) TciSendPbMessage(handle, is_response_to_PLAY_START?RTM_SYNCTIME_RESPONSE_TO_USER:RTM_SYNCTIME, 0, utc_time, NULL, 0)
731
732/** \def TciSendPbTimelapseFlag
733 * 发送缩时录像回放标志。在进入和退出时发送.
734 * @param handle p2p 连接句柄
735 * @param flag 1:进入缩时回放; 0:退出缩时回放
736 */
737#define TciSendPbTimelapseFlag(handle, flag) TciSendPbMessage(handle, RTM_TIME_LAPSED, flag, 0, NULL, 0)
738
739/** \def TciSendPbEndOfEvent
740 * 在事件回放结束时发送此标志通知App.
741 */
742#define TciSendPbEndOfEvent(handle) TciSendPbMessage(handle, RTM_END_OF_EVENT, 0, 0, NULL, 0)
743
744
745/** 发送实时音视频帧, SDK内部会将数据分发到云端和APP.
746 * @param channel 视频通道号: 0|1|...
747 * @param stream 视频码流. 0: 高清; 1: 标清
748 * @param mt 媒体类型 @ref TCMEDIA
749 * @param pFrame 指向数据帧。视频要带4个前导字节 00 00 00 01
750 * @param length 数据帧长度
751 * @param ts timestamp. 单位为ms
752 * @param uFrameFlags 帧标志(低16位)
753 * - 视频: 0或 @ref video_frame_flags "FF_KEYFRAME/FF_TIMELAPSE/..." 的组合
754 * - 音频: @ref audio_sample_fmt "音频采样格式" (0(默认)或2: 8k16bmono; 10:16k16bmono)
755 *
756 * @note 该操作不会阻塞调用。如果没有消费者(没有云服务,没有人访问),实际不会做任何事情
757 */
758int TciSendFrameEx(int channel, int stream, TCMEDIA mt, const uint8_t *pFrame, int length, uint32_t ts, int uFrameFlags);
759
760/* @deprecated */
761//#define TciSendFrame(stream_, mt, pFrame, length, ts, uFrameFlags) TciSendFrameEx(0, stream_, mt, pFrame, length, ts, uFrameFlags)
762
763/** 发送实时流消息.
764 * @param channel 通道。为-1时在全部通道上发送
765 * @param stream 码流。为-1时在全部码流上发送
766 * @param type 消息类型. 参见 @ref RTMTYPE
767 * @param data1 消息相关数据
768 * @param data2 消息相关数据
769 * @param data_len 额外数据长度 @ref RTMSGHEAD_t::frame_size
770 * @param data 指向额外数据
771 */
772int TciSendLiveMessage(int channel, int stream, RTMTYPE type, unsigned int data1, unsigned int data2, const void *data, int data_len);
773
774/** \def TciSendLiveMsg_ReachPsp
775 * 发送预置位到位通知. */
776#define TciSendLiveMsg_ReachPsp(channel, psp_num) TciSendLiveMessage(channel, -1, RTM_REACH_PSP, channel, psp_num, NULL, 0)
777
778/** \def TciSendLiveMsg_LensSwitch
779 * 多目摄像机镜头切换时发送的标志帧, 要求在新镜头的第一帧前发送. */
780#define TciSendLiveMsg_LensSwitch(channel, stream) TciSendLiveMessage(channel, stream, RTM_LENS_SWITCH, channel, stream, NULL, 0)
781
782/** @deprecated
783 * \def TciSendLensSwitchFlag
784 * 发送镜头切换通知, 旧的名字. */
785#define TciSendLensSwitchFlag(channel, stream) TciSendLiveMsg_LensSwitch(channel, stream)
786
787/** 在命令通道上发送通知.
788 * @param handle 指定连接。如果为NULL,则发广播.
789 * @param type 消息类型
790 * @param type 消息类型. 参见 @ref RTMTYPE
791 * @param data1 消息相关数据
792 * @param data2 消息相关数据
793 * @param extra_data 指向额外数据, 可以为NULL
794 * @param extra_len 额外数据长度
795 */
796int TciSendRtMsg(p2phandle_t handle, RTMTYPE type, unsigned int data1, unsigned data2, const void *extra_data, int extra_len);
797
798/**@}*/ //name 发送数据
799
800
801/** @name 配网和注册
802 * @{*/
803
804/** 开始配置WIFI.
805 * 支持AP热点或设备扫描手机上的二维码的方式配置WIFI. AP热点名称为 \"<b>AICAM_</b><I>uuid</I>\" 的形式. \n
806 * 该调用会一直阻塞直到获得了正确的wifi配置.
807 * \param mode 配网方式. @ref GWM_QRCODE, @ref GWM_AP 的组合。
808 */
809int TciConfigWifi(int mode);
810
811/** 开始配置WIFI.
812 * 同 TciConfigWifi(), 但不会复位SDK. 用于在设备绑定后重新配置wifi. \n
813 * 配网成功后调用TcuIpChanged()加快设备重新上线速度.
814 */
816
817/** 在sdk外部扫二维码. 调用此接口验证
818 * @return 有效时返回SA_TRUE, 否则返回 SA_FALSE
819 */
820int TciCheckRegString(const char *s);
821
822/** 中止配网.
823 * \param mode 要中止的配网方式. @ref GWM_QRCODE: 只中止qrcode; @ref GWM_AP 会中止全部配网方式。
824 */
825int TciStopConfigWifi(int mode);
826
827/** 保存wifi注册信息.
828 * 用于wifi模块从AP模式切换到STA模式必须重启的情形。 \n
829 * @return 要保存的数据的地址。 *len 为要保存的数据的长度
830 *
831 * @note 在 TciConfigWifi()返回后调用 TciGetRegisterConfiguration() 操作并且保存返回的数据。\n
832 * 重启后不调用 TciConfigWifi(), 而是用保存的内容调用 TciSetRegisterConfiguration()。
833 * 然后执行 TciStart() 完成注册过程。
834 */
835const void *TciGetRegisterConfiguration(int *len);
836
837/** 恢复wifi注册信息.
838 * \return 非0表示成功
839 */
840SA_BOOL TciSetRegisterConfiguration(const void *data, int len);
841
842/** @deprecated 设置p2p信息.
843 * @param sss 从平台获取的p2p信息字符串
844 * @return 0:ok; -1:内容错误
845 * @note 在 TciStart()前调用
846 */
847int TciSetP2pInfo(const char *sss);
848
849/** 处理从蓝牙收到的注册数据
850 * @param data 命令0x8006的数据
851 * @note 参看《蓝牙的应用层协议.md》文档
852 * */
853int TciProcessRegInfo(const void *data);
854
855/** 手动处理注册信息
856 * @param s 另一台设备通过 STATUS_GOT_REGINFO 获取到的注册信息
857 */
858int TciSetRegInfo(const char *s);
859
860/**@}*/ //name 配网和注册
861
862
863/** @name 低功耗相关
864 * @{*/
865/** 预分配云存储帧缓存空间.
866 * 本功能用于对上传时间敏感的事件唤醒类设备录像。
867 * 可以在网络初始化前就调用本接口,之后调用 TciSendFrameEx()就会向缓冲写入帧。
868 * 设备TciStart()成功后调用TciSetEventEx(),已经缓存的帧得以上传。
869 *
870 * 不调用本接口,TciStart()内部会在设备注册成功后执行同样功能.
871 *
872 * \param uCloudBuffSize 云存储缓冲区大小(单位:字节),最小1M
873 *
874 * @return 内存不足时返回-1, 否则返回0
875 *
876 * @note TciStart()会通过回调修改系统时间,设备要保证 TciStart()前后帧的时间戳时连续的。 \n
877 * * 要在 TciInit() 之后调用
878 * * 要在调用前从RTC恢复系统时间和设置时区
879 */
880int TciAllocCloudBuffer(unsigned int uCloudBuffSize);
881
882/** 等待录像缓冲区中的所有数据被消耗掉.
883 * @note 本功能用在缩时录像时缓存周期结束时通知sdk结束打包并立即上传. \n
884 * 操作会阻塞直到打包上传完成. 操作期间不要向sdk送入新的帧.
885 */
887
888/** 告诉SDK下一个视频关键帧的实际发生时间(UTC).
889 * @param channel/stream 云存的通道和码流
890 * @param t 下一个关键帧的发生时间
891 * @note 默认情况下SDK以调用 TciSendFrameEx()时的时间作为帧的产生时间, 这个时间用于确定云 \n
892 * 存储的开始时间和回放定位.
893 * 当应用层存在缓存行为(帧在时间 T0 时产生, 但在n秒后的 T0+n 时发送), 需要调用本接口 \n
894 * 告诉SDK传入的时间(T0)才是帧的实际发生时间。\n
895 * 调用本接口后,下一次事件时间如果等于或早于T0, 录像从缓冲区中的第一帧开始; 否则执行 \n
896 * 普通的5秒预录。\n
897 * 这种情形一般发生在低功耗设备.
898 */
899int TciSetKeyVideoTime(int channel, int stream, time_t t);
900
901/** 准备休眠
902 * 本api建立到唤醒服务器的tcp连接,并且返回连接数.
903 * 调用者对返回的socket调用getpeername()/getsockname()取得与唤醒服务器的连接信息,
904 * 并使用此信息配置wifi模组,然后对主芯片下电。在模组里每50\"向唤醒
905 * 服务器发送64字节的心跳包,包内容任意。
906 *
907 * 注意: 设备如果要进入休眠,应用层不能关闭返回的socket.
908 *
909 * @param socks 接收连接socket
910 * @param size socks数组大小
911 * @retval >=0 number of sockets connected to wakeup-servers
912 * @retval <0 failed
913 */
914int TciPrepareHiberation(int *socks, int size);
915
916/** 获取唤醒服务器ip地址
917 * @param servers 接收服务器地址。最多返回3个地址
918 * @return 服务器个数
919 */
921
922/** 生成唤醒服务器登录命令.
923 * 本接口用于到唤醒服务器的tcp连接不由主机创建的情形.
924 *
925 * @param randKey 服务器生成的随机串
926 * @param len_of_authstring 登录命令长度
927 * @return 登录字节串指针。如果失败返回 NULL
928 *
929 * @note 应用要按以下步骤建立到唤醒服务器的有效连接:
930 * 1. 应用调用 TciGetWakeupServers() 获取唤醒服务器的地址
931 * 2. 通信模块建立到唤醒服务器的连接, 接收由服务器返回的randkey
932 * 3. 应用使用此randkey调用本接口
933 * 4. 通信模块向服务器发送本接口生成的认证字符串
934 * 6. 主控下电. 通信模块每50\"向服务器发送64字节的心跳包,包内容任意。
935 */
936const uint8_t *TciPrepareAuthString(const char *randKey, int *len_of_authstring);
937
938/** 设置低功耗设备的工作模式.
939 *
940 * @note 需要在TciStart()之后调用. 调用逻辑一定参看文档 @ref a21_ManuallyPowerManagement
941 */
943
944/** 从NETDOWN模式下恢复网络后,调用本api使p2p快速上线 */
946
947/** 设置低功耗设备唤醒原因, 设备进入休眠时会上报给服务器.
948 * @param t_wakeup 唤醒时间
949 * @param r <0:异常唤醒; 0:远程唤醒; >0:唤醒事件类型(ECEVENT)
950 * @param user_reason 当r=ECEVENT_USER_DEFINED, user_reason为用户定义的唤醒理由字符串,长度不超过15个字符. \n
951 * 其它情形下传NULL
952 * @param sig_lvl wifi或4G信号强度: 0~100. 传负数时由用户自己解释
953 * @param sdc_rec SD卡录像长度
954 * @note 要在 STATUS_IDLE 返回0的时候调用,因为随此上报的还有别的信息。
955 */
956void TciSetWakeupReason(time_t t_wakeup, int r, const char *user_reason, int sig_lvl, int sdc_rec);
957
958
959/** 设备端准备强制休眠.
960 * 本操作会先通知实时用户(app端收到通知后要停止视频),然后停止云上传、退出p2p、断开长连接等. \n
961 * 返回后设备可以立即下电。
962 * @param bDiscardFilesInQueue 是否放弃上传队列中未处理的文件. \n
963 * 如果为 SA_FALSE, 会尝试上传队列中的所有文件. \n
964 * 建议在开启了后备存储并且存储路径有效时 SA_TRUE,这样在网络不好,队列中文件多时可以加速返回. \n
965 * 其它情况下的设置由应用自行载定.
966 */
967int TciForceSleeping(SA_BOOL bDiscardFilesInQueue);
968/**@}*/
969
970/** @name 云存储自动补录
971 * @{*/
972/** 设置云存储后备存储目录和缓存策略.
973 * 当设置后备存储目录后,SDK会利用此目录暂存上传失败的录像和图片,
974 * 并在合适的时机重传. \n
975 * 本功能要在 TciStart() 前调用
976 * @param sd_path 用于后备存储的目录
977 * @param buffer_hint 内存缓存策略.
978 * @retval 0
979 * @note 缓存策略影响用于云存储的内存大小。参看 @ref ECBUFFERHINT 的说明
980 */
981int TciSetBackStore(const char *sd_path, ECBUFFERHINT buffer_hint);
982
983/** 允许或禁止后备上传.
984 * @param en 1:enable; 0:disable
985 * @note 默认由sdk根据网络情况决定上传时间。如果应用层要临时禁止上传,可调用此接口
986 */
988
989/** 这个接口用于sd卡格式化前释放backstore, 和格式化后重新开启后备存储
990 * @param en 0-释放; 非0-重新打开
991 */
993/**@}*/
994
995
996/** @name 用户定义云上传
997 * @{*/
998/** 开始一个用户定义上传.
999 * 自定义上传主要用于sdk本身预录时间不足或不能录像,要从SD卡录像上传的情形. \n
1000 * 必须在 TciStart() 成功后调用
1001 *
1002 * @param evt 事件类型. @ref ECEVENT (作为参数传入时要强传为 const char *型), 或长度小于16的字符串。 \n
1003 * 目前仅支持行车记录仪的事件(@ref ECEVENT_DR_BEGIN ~ @ref ECEVENT_DR_END) \n
1004 * 或者 TciCB::on_status(@ref STATUS_SDER, SDER *, ...) 回调的平台定义事件( SDER::event )
1005 * @param tRecordStart 录像起始时间
1006 * @param jpg_pic 图片数据(如果有的话)指针(SDK不会take图片缓冲区的所有权)
1007 * @param pic_len 图片数据长度
1008 * @return 如果允许上传,返回一个用户上传句柄。否则返回NULL
1009 * @note 用户自定义上传只能是事件上传,长度限制在30秒内. \n
1010 * 自定义上传的是事后发觉的事件,这个时候录像已经保存到sd卡了。\n
1011 * 自定义上传的时间范围不能与TciSetEvent 的时间重叠,也不能与另一个自定义事件的时间范围重叠
1012 */
1013void *TciUduBegin2(const char *evt, time_t tRecordStart, const char *jpg_pic, int pic_len);
1014#define TciUduBegin(evt, tRecordStart) TciUduBegin2(evt, tRecordStart, NULL, 0)
1015
1016/** 自定义上传过程,写入帧.
1017 * @param hUdu TciUduBegin() 返回的上传句柄
1018 * @param mt 媒体类型. 参见 TciSendPbFrame() 的 id_mt 参数
1019 * @param ts 时间戳
1020 * @param pFrame 帧数据指针
1021 * @param size 帧数据大小
1022 * @param uFrameFlags 视频:关键帧标志(1:关键帧;0:非关键帧); 音频: @ref audio_sample_fmt "音频采样格式"
1023 * @return 0:ok; 非0:录像长度超限,用户要调用 TciUduEnd()
1024 */
1025int TciUduPutFrame(void *hUdu, TCMEDIA mt, uint32_t ts, const uint8_t *pFrame, int size, int uFrameFlags);
1026
1027/** 结束自定义上传
1028 * @param hUdu TciUduBegin() 返回的上传句柄
1029 */
1030void TciUduEnd(void *hUdu);
1031/**@}*///name 用户定义云上传
1032
1033/** 上报错误 */
1034int TciReportError(const char *name, const char *detail);
1035
1036/** 用于选择调试环境
1037 * @param env 1:测试环境; 0:正式环境
1038 * @note 在 TciStart() 之前调用
1039 */
1041
1042typedef void (*TCIONLIVEFRAMECB)(int channel, int stream, TCMEDIA mt, const uint8_t *pFrame, uint32_t size, uint32_t ts, int uFrameFlags);
1043void TciRegisterLiveFrameCB(TCIONLIVEFRAMECB cb);
1044void TciUnregisterLiveFrameCB(TCIONLIVEFRAMECB cb);
1045
1046/** 设置参数文件操作指针.
1047 * SDK会保存工作参数到flash. 小系统设备在flash上没有标准文件I/O支持时,需要提供载入和写参数的操作。本操作要在 TciInit() 之前调用 \n
1048 * linux和有文件系统的liteos不需要设置
1049 * @param ops 参数文件操作结构指针
1050 */
1052
1053/** 设置最大p2p连接数.
1054 * @param num 要设置的最大连接数
1055 * @return 最大连接数有效值
1056 * @note 只能在 TciStart()和TciConfigWifi()前调用
1057 */
1059
1060char *TciGetDeviceInfoString(void);
1061
1062/** \name 手动OTA&文件上传下载
1063 * @{*/
1064/** 下载升级包
1065 * @param subdev NULL或子设备id. 用于选择相应的固件
1066 * @return 0:ok; <0:error code
1067 */
1068int TciUpgradeOnTheAir(const char *subdev);
1069
1070
1071/** 查询升级包.
1072 * @param uuid
1073 * @param ota 返回升级包信息
1074 * @note 先要调用 TciStart()
1075 */
1076int TciQueryForOTA(const char *uuid, DEVICEOTAINFO *ota);
1077
1078/** 查询第三方升级包.
1079 * @param fw_id 第三方设备的 firmware id
1080 * @param fw_ver 第三方设备的当前版本号。版本号在平台上是以8位数字("01010101")的方式记录. \n
1081 * 如果第三方固件的版本有不同表示方式,需要在上传固件时自行维护一个映射关系.
1082 * @param ota 返回升级包信息
1083 * @return 0:查询成功, 是否有可用升级包看 *ota 内容; <0:错误码
1084 * @note 先要调用 TciStart()
1085 */
1086int TciQueryForOta2(const char *fw_id, const char *fw_ver, DEVICEOTAINFO *ota);
1087
1088/** 执行下载过程,会调用回调里的 ota 接口.
1089 * @return 0:下载完成; -1:没有设置回调; 其它<0:通信错误
1090 */
1092/**@}*/ //手动OTA
1093
1094
1095/** \name 下载用户文件
1096 * @{*/
1097/** 查询并下载用户文件.
1098 * @param name 文件上传到服务器端时确定的文件标识
1099 * @param bToFile 1:下载到文件; 0:下载到内存
1100 * @param dest 下载到文件时,设置 dest->file.path 为本地文件路径; 下载到内存时,内容在dest->mem中返回
1101 * @param timeout 超时设置。单位: 秒
1102 */
1103int TciGetUserFile(const char *name, SA_BOOL bToFile, union TgfDest *dest, int timeout/*s*/);
1104
1105/** 获取用户文件的下载地址.
1106 * @param name 文件上传到服务器端时确定的文件标识
1107 * @param flnk 成功时返回文件信息
1108 * @return 0:成功; 非0:错误码
1109 */
1110int TciQueryUserFile(const char *name, EcFileLink *flnk);
1111
1112/** 下载用户文件.
1113 * @param flink 用户文件信息
1114 * @param bToFile 1:下载到文件; 0:下载到内存
1115 * @param dest 下载到文件时,设置 dest->file.path 为本地文件路径; 下载到内存时,内容在dest->mem中返回
1116 * @param timeout 超时值。单位:秒
1117 * @return 0:成功; 非0:错误码
1118 */
1119int TciDownloadUserFile(const EcFileLink *flink, SA_BOOL bToFile, union TgfDest *dest, int timeout);
1120/**@}*/
1121
1122/** \name 日志上传工具
1123 * 以查询的方式上传日志,主要用于低功耗设备.
1124 * @{*/
1125/** 查询日志上传请求
1126 * @param uuid
1127 * @param model_id may be NULL
1128 * @param ppUrl 如果有请求,返回上传地址
1129 * @return 0:ok; none-zero: error code
1130 * @note 如果有请求,用返回的地址调用 TgPostMultiparts()
1131 */
1132int TgQueryUploadReq(const char* uuid, const char *model_id, char **ppUrl);
1133
1134/** 传日志文件
1135 * @param url TgQueryUploadReq() 返回的上传地址
1136 * @param uuid
1137 * @param path 本地文件名
1138 * @param timeout 超时值(ms)
1139 * @return 0:ok; otherwise error
1140 */
1141int TgPostLogFile(const char *url, const char *uuid, const char *path, int timeout);
1142
1143/** 上传内存中的日志
1144 * @param url TgQueryUploadReq() 返回的上传地址
1145 * @param uuid
1146 * @param mem 内存地址
1147 * @param size 数据长度
1148 * @param name 保存为文件名name
1149 * @param timeout 超时值(ms)
1150 * @return 0:ok; otherwise error
1151 */
1152int TgPostLogMem(const char *url, const char *uuid, const void *mem, int size, const char *name, int timeout);
1153
1154/**@}*/ //name 上传下载
1155
1156/** \name MCU配网api
1157 * 低功耗设备在MCU端进行配网.
1158 * @{*/
1159/** 获取设备属性字符串。调用者把该字符串传给MCU,用于在MCU端激活设备.
1160 * 调用者要 free() 返回的字符串.
1161 */
1163
1164/** 返回要同步到MCU的数据.
1165 \param pLen 用于返回数据长度.
1166 \return 要同步到MCU的数据缓冲区地址。调用者要负责释放(free())
1167 */
1168unsigned char *TciGetPlatConfig(int *pLen);
1169
1170/** 同步从MCU来的数据.
1171 \param pData 从MCU收到的同步数据
1172 \param len 数据长度
1173 \return 0:成功; <0:失败
1174 */
1175int TciSyncPlatConfig(const unsigned char *pData, int len);
1176/**@}*/// name register_in_mcu
1177
1178
1179/** \name 其它功能
1180 * @{*/
1181/** 设备上线后IP发生变化时通知SDK, 用于立即更新长连接 */
1183
1184typedef struct _IceConfig {
1185 char *ip;
1186 int port;
1187 char *username;
1188 char *password;
1189 int is_turn;
1190} ICECONFIG;
1191
1192/** 开启本地工作模式.
1193 * 该模式用于仅在局域网工作的设备. 有需要先要同我们联系.
1194 * @param url
1195 * @param cfg webrtc 服务配置数组
1196 * @param size 数组大小
1197 * @return 0:成功; <0:错误码
1198 * @note 函数内部会复制cfg信息, 返回后用户可以释放cfg引用或间接引用的空间
1199 */
1200int TciLocalStart(const char *url, const ICECONFIG *cfg, int size);
1201
1202/** 获取SDK内部状态.
1203 * @return 0 或 @ref sdk_state_flags "SDK状态标志" 的组合
1204 * @note 本函数只是用来告诉用户当前用什么事件在处理. \n
1205 * 不能用来代替 STATUS_IDLE 状态回调.
1206 */
1207unsigned int TciGetSdkState(void);
1208
1209
1210/** 设置用户定义低功耗设备的事件云录像时长.
1211 * @param erl 录像时长,可取值 -1/10/20/30. <=0时录像时长由sdk决定.
1212 * @note 非低功耗设备该设置无效. 在TciInit()后调用.
1213 * @return 0(ok) 或 TCI_E_NOT_ALLOWED
1214 */
1216/**@}*/ //misc
1217
1218/** \name 呼入处理
1219 * @{*/
1220/** 接听.
1221 * @param flavor 通话类型 @ref VIDEO_CALL 或 @ref VOICE_CALL
1222 * @return 0:成功; 非0为错误码。如果呼叫来自微信小程序, 错误码定义在 wx_err.h
1223 * @note flavor是对从@ref STATUS_INCALL2 收到的@ref INCALLINFO::flavor 的响应, \n
1224 * 不得高于请求的值. \n
1225 * 不要在回调中调用本接口。
1226 */
1228
1229/** 拒接.
1230 * @return 0:成功; 非0为错误码。如果呼叫来自微信小程序, 错误码定义在 wx_err.h
1231 */
1233
1234/** 挂断当前通话 */
1235int TciHangup(void);
1236/**@}*/ //name 呼入
1237
1238/**@}*/ //api_reference
1239
1240#ifdef __cplusplus
1241}
1242#endif
1243
1244#endif
P2p Commands and Structures
P2p Commands and Structures
ENUMRTSTATE
运行时状态
探鸽云SDK常数定义
常数和错误码定义
ECBUFFERHINT
云上传文件队列长度.
PMODE
低功耗设备的工作模式
ECEVENT
上报事件类型.
ECALLFLAVOR
通话类型
SIMCARDTYPE
sim 卡类型
RTMTYPE
插入到媒体流(实时或回放)或命令通道中的消息类型.
ECG4STATE
4G状态
ECSERVICETYPE
云服务类型
TCMEDIA
媒体类型枚举常数
ETRANSSERVICE
传输内容
TCSYSOPTION
SDK选项常数
@ PM_ALLON
常电模式。非低功耗设备的默认模式
@ PM_NETDOWN
主控正常工作,网络模块进入休眠模式
@ PM_SLEEPABLE
系统可休眠(会收到STATUS_IDLE状态回调。这是低功耗设备的默认模式)
@ SIMT_ESIM
ESIM
@ SIMT_VSIM
vsim卡
@ SIMT_PHY
物理卡
@ TCOPT_PRERECORD_LENGTH
事件云存预录时间长度, 单位:秒.
@ TCOPT_MAX_DATAFILE_SIZE
最大云存data文件。超出的帧会丢弃.
@ TCOPT_ONLY_REPORT_AI_EVENT
仅上报AI事件.
@ TCOPT_NO_STREAMING_WITHOUT_ACCEPTING_CALL
用户没有应答不能拉流.
@ TCOPT_TRANS_MEDIA_TYPE
传输内容 类型: int*:
@ TCOPT_DISABLE_UPLOAD_WHEN_VIEWING
有人观看时禁止上传 类型: int*
@ TCOPT_BUFFER_QUEUE_SIZE
云存储缓冲文件数.
@ TCOPT_BACKSTORE_SAVEDAYS
backstore 存储天数 类型 int*:
int TciCheckRegString(const char *s)
在sdk外部扫二维码.
int TciRejectInCall2()
拒接.
int TciSendCmdResp(p2phandle_t handle, unsigned int cmd, const void *data, int dataSize)
发送p2p命令应答
void TciBackStoreEnableUpload(int en)
允许或禁止后备上传.
int TciProcessRegInfo(const void *data)
处理从蓝牙收到的注册数据
unsigned int TciGetSdkState(void)
获取SDK内部状态.
int TciInit(const char *path, const char *uuid)
配置基本参数 在TciStart()之前调用
void * TciGetSessionUserData(p2phandle_t handle)
返回由TciSetSessionUserData()设置的应用私有数据指针
int TciSetKeyVideoTime(int channel, int stream, time_t t)
告诉SDK下一个视频关键帧的实际发生时间(UTC).
const void * TciGetRegisterConfiguration(int *len)
保存wifi注册信息.
void TciBackStoreEnable(int en)
这个接口用于sd卡格式化前释放backstore, 和格式化后重新开启后备存储
int TciSetCallback(const struct TciCB *cb)
注册回调 – sdk内部事件
int TciSetLockEvent(int cls, int msg, int usrtyp, int usrid)
门锁事件上报。图片和录像都在内部处理了.
void TciSetSessionUserData(p2phandle_t handle, void *pUser)
绑定应用私有数据指针到p2p handle
int TciQueryForOta2(const char *fw_id, const char *fw_ver, DEVICEOTAINFO *ota)
查询第三方升级包.
int TciGetWakeupServers(Ipv4Addr servers[3])
获取唤醒服务器ip地址
void TciSetLogOption(int b_output_to_console, const char *log_path, int max_log_size)
控制日志输出.
void TciSelectEnvironment(int env)
用于选择调试环境
int TciStart(int isBound, unsigned int uCloudBuffSize)
启动服务
char * TciGetActivationAttrs(void)
获取设备属性字符串。调用者把该字符串传给MCU,用于在MCU端激活设备.
int TciReport4GInfo(const char *imei, const char *iccid, ECG4STATE state)
int TciSetMaxP2pClientsNum(int num)
设置最大p2p连接数.
int TciDownloadUserFile(const EcFileLink *flink, SA_BOOL bToFile, union TgfDest *dest, int timeout)
下载用户文件.
int TciPrepareHiberation(int *socks, int size)
准备休眠 本api建立到唤醒服务器的tcp连接,并且返回连接数.
void TciSetLogLevel(int level)
设置SDK日志输出等级.
int TciQueryForOTA(const char *uuid, DEVICEOTAINFO *ota)
查询升级包.
void TciSetPowerMode(PMODE mode)
设置低功耗设备的工作模式.
int TciReportBatteryStatus(int qoe, int qoe_low, int charging)
上报电池状态
int TciStopEvent(ECEVENT evt)
停止事件, 仅少数事件才有意义.
int TciSendPbMessage(p2phandle_t handle, RTMTYPE type, unsigned int data1, unsigned int data2, const void *data, int data_len)
在回放流中插入消息.
int TciStopConfigWifi(int mode)
中止配网.
int TciSetEventRecordLength(int erl)
设置用户定义低功耗设备的事件云录像时长.
int TciSendPbFrame(p2phandle_t handle, uint32_t id_mt, const uint8_t *frame, int len, uint32_t timestamp, int uFrameFlags)
回放时发送数据帧.
int TciGetSysOption(TCSYSOPTION opt, void *pVal)
通用sdk工作选项获取接口.
const uint8_t * TciPrepareAuthString(const char *randKey, int *len_of_authstring)
生成唤醒服务器登录命令.
int TciConfigWifi(int mode)
开始配置WIFI.
int TciSendLiveMessage(int channel, int stream, RTMTYPE type, unsigned int data1, unsigned int data2, const void *data, int data_len)
发送实时流消息.
int TciLocalStart(const char *url, const ICECONFIG *cfg, int size)
开启本地工作模式.
int TciUduPutFrame(void *hUdu, TCMEDIA mt, uint32_t ts, const uint8_t *pFrame, int size, int uFrameFlags)
自定义上传过程,写入帧.
int TciReport4GInfoEx(const TG4GINFO *info, ECG4STATE state)
上报4G设备信息,代替 TciReport4GInfo()
int TciSetSysOption(TCSYSOPTION opt, const void *pVal)
通用sdk工作选项设置接口.
int TciSetP2pInfo(const char *sss)
int TciStartInTestMode(const char *key_path)
开启p2p功能,进入厂测状态.
int TciUpgradeOnTheAir(const char *subdev)
下载升级包
int TciConfigWifiWithoutReset(int mode)
开始配置WIFI.
int TciSendFrameEx(int channel, int stream, TCMEDIA mt, const uint8_t *pFrame, int length, uint32_t ts, int uFrameFlags)
发送实时音视频帧, SDK内部会将数据分发到云端和APP.
int TciSetEventEx(EVENTPARAM *evtp)
上报事件。本版本允许附带事件特定参数.
int TciForceSleeping(SA_BOOL bDiscardFilesInQueue)
设备端准备强制休眠.
void * TciUduBegin2(const char *evt, time_t tRecordStart, const char *jpg_pic, int pic_len)
开始一个用户定义上传.
int TciStart2(int isBound, unsigned int uCloudBuffSize, const char *uuid)
启动服务.
int TciSendUserData(const unsigned char *data, int len)
发送用户自定义数据到第三方平台.
void TciSetCloudStream(int channel, int stream)
设置云存储录像通道的码流
void TciSetRtState(ENUMRTSTATE state, void *pData)
报告系统运行时状态
void TciUduEnd(void *hUdu)
结束自定义上传
void TciSetParamFileOps(struct paramf_ops *ops)
设置参数文件操作指针.
unsigned char * TciGetPlatConfig(int *pLen)
返回要同步到MCU的数据.
int TciSendCmd(p2phandle_t handle, unsigned int cmd, const void *data, int dataSize)
发送p2p命令请求
int TciSetCmdHandler(const TGCMDHANDLER cb)
注册通用命令回调 在回调里处理APP发来的命令请求
int TciSetRegInfo(const char *s)
手动处理注册信息
int TciPerformOTA(DEVICEOTAINFO *ota)
执行下载过程,会调用回调里的 ota 接口.
int TgQueryUploadReq(const char *uuid, const char *model_id, char **ppUrl)
查询日志上传请求
int TciAllocCloudBuffer(unsigned int uCloudBuffSize)
预分配云存储帧缓存空间.
int TciSendRtMsg(p2phandle_t handle, RTMTYPE type, unsigned int data1, unsigned data2, const void *extra_data, int extra_len)
在命令通道上发送通知.
int TgPostLogFile(const char *url, const char *uuid, const char *path, int timeout)
传日志文件
int TciCleanup(void)
释放资源
const char * TciGetVersion(void)
获取SDK版本号 TciInit()之后调用
int TciSendCmdRespStatus(p2phandle_t handle, unsigned int cmd, unsigned int status)
发送一个 Tcis_ErrorResp 结构作应答.
int TciReportError(const char *name, const char *detail)
上报错误
void TcnIpChanged()
设备上线后IP发生变化时通知SDK, 用于立即更新长连接
int TciReportGpsInfo(const unsigned int time, const double longitude, const double latitude, double speed, int angle, int signal_strength)
上报GPS信息
int TgPostLogMem(const char *url, const char *uuid, const void *mem, int size, const char *name, int timeout)
上传内存中的日志
void TciFlushCsCache()
等待录像缓冲区中的所有数据被消耗掉.
void TciSetWakeupReason(time_t t_wakeup, int r, const char *user_reason, int sig_lvl, int sdc_rec)
设置低功耗设备唤醒原因, 设备进入休眠时会上报给服务器.
int TciStop(void)
停止服务
int TciSyncPlatConfig(const unsigned char *pData, int len)
同步从MCU来的数据.
int TciQueryUserFile(const char *name, EcFileLink *flnk)
获取用户文件的下载地址.
int TciGetUserFile(const char *name, SA_BOOL bToFile, union TgfDest *dest, int timeout)
查询并下载用户文件.
int TciHangup(void)
挂断当前通话
int TciSetDoorbellEvent()
包装了门铃事件
void TciFastRecoverP2p(void)
从NETDOWN模式下恢复网络后,调用本api使p2p快速上线
int TciAcceptInCall2(ECALLFLAVOR flavor)
接听.
SA_BOOL TciSetRegisterConfiguration(const void *data, int len)
恢复wifi注册信息.
int TciSetBackStore(const char *sd_path, ECBUFFERHINT buffer_hint)
设置云存储后备存储目录和缓存策略.
int(* on_ota_download_finished)(int status)
升级包下载结束
short id
用户(连接)标识
int(* snapshot)(int type, uint8_t **ppJpg, int *size)
抓取图片.
unsigned short port
port, network byte-order
char ver[16]
升级包版本
int size
升级包大小
void(* trans_stat)(const struct TransStatUser *_stat)
网络传输统计回调
int msStatInterval
统计周期(单位: ms)
int(* get_feature)(const char *key, char *buf, int size)
设备能力.
void(* on_talkback_stop)(void)
结束对讲
short vstream
码流
unsigned int ip
ip, network byte-order
int(* set_time)(time_t time)
设置时间
int(* qrcode_get_y_data)(uint8_t **ppYBuff, int *width, int *height)
获取Y图片
int(* request_iframe_ex)(int channel, int vstream)
请求指定图像通道的I帧
int nBytesInBuff
位于发送缓冲区的字节数
int(* on_talkback_start)(void)
开始对讲
int(* log)(int action, char *logfile)
在平台端采集设备日志
int(* qrcode_start)(void)
二维码扫描开始 应用层在此开启取Y数据的通道
int(* talkback)(TCMEDIA at, const uint8_t *audio, int len)
对讲数据回调 格式在前面已经协商过
int(* on_ota_download_start)(const char *new_version, unsigned int size)
OTA升级开始
int(* set_wifi)(int is_switching, const char *ssid, const char *key)
设置wifi参数
char firmware_ver[10]
固件主版本,8个数字组成的字符串。like: "03020201", means 3.2.2.1.
int(* on_status)(int event, const void *pData, int len)
sdk内部状态
char * path
IN: file path
char md5[36]
md5 检验字符串
void(* talkback_ex)(int mt, unsigned int ts, const void *data, int len, unsigned int uFrameFlags)
对讲数据回调.
void * mem
OUT: 指向sdk分配的内存
uint8_t * data
数据缓冲区指针
char url[256]
下载地址
void(* free_buff)(SIMPLEBUFFER *buff)
释放参数缓冲区
time_t expiration
过期时间(utc)
int size
OUT: 数据长度
int(* on_ota_download_data)(const uint8_t *buff, int size)
升级包数据 升级包下载过程中,sdk调用此回调将数据传给应用层
int len
数据长度
int nBytesSent
已经发送的字节数
char iccid[24]
sim卡号
short is_igop
1:统计间隔为一个I帧间隔; 0:周期约为~1s
SIMCARDTYPE sim_type
sim卡类型
int nBytesTotal
总共收到的字节数
char imei[24]
4g模块标识
int size
缓冲区大小
int(* get_state)(const char *key, char *buf, int size)
取设备当前状态或初始默认设置.
int(* request_iframe)(int vstream)
char vendor[16]
设备生产厂商 OEM
char device_type[16]
Not used
short vchannel
视频通道
int(* save_buff)(const SIMPLEBUFFER *buff)
写参数文件
ECSERVICETYPE serviceType
云服务类型
int(* set_timezone)(const char *tzs)
设置时区
void(* switch_quality)(int channel, int stream, const char *qstr)
切换图像质量
void(* remove)(void)
删除参数文件(或者清空参数文件)。下一次读出时 len为0
int(* alloc_and_readall)(SIMPLEBUFFER *buff, int cbExtra)
分配缓冲区,并读出参数文件.
void(* qrcode_end)(uint8_t *pYBuff)
结束二维码扫描
char firmware_id[32]
ota 升级用的固件标识, 平台唯一.
char model[32]
产品型号
void(* ai_result)(int type, const uint8_t *pJpg, int len)
当AI识别成功,通过本回调通知应用.
int(* on_apmode_login)(const char *user, const char *key)
直连模式下用户登录帐号检查
int(* get_info)(TCIDEVICEINFO *info)
获取设备基本信息
int nBytesThrow
丢掉的字节数。丢包会持续到到一个I帧,这期间即使网络恢复也会丢,所以其值只能作为参考, 不能用于计算网速
void * p2phandle_t
p2p连接句柄.
int(* TGCMDHANDLER)(p2phandle_t handle, int cmd, const void *data, int len)
命令回调类型
设备升级包信息
事件上报参数.
IPv4 地址表示(网络字节顺序)
Simple Buffer
设备基本信息
云服务信息
4G 设备信息
sdk 回调函数结构
数据下载到文件
数据下载到内存
P2P发送统计数据结构
参数文件读写函数据指针结构
用户文件下载目的地.