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