capacitor-plugin-tjyjwt
v1.0.2
Published
给检务通app对接执法仪设备的,把厂家的SDK集成capacitor的插件
Readme
capacitor-plugin-tjyjwt
给特种检务通app,集成执法仪的SDK能力,通过热点链接远程控制执法仪。
Install
npm install capacitor-plugin-tjyjwt
npx cap syncAPI
connect(...)snap(...)record(...)stopConnecting(...)setParameters(...)ftpConnect(...)ftpListFiles(...)ftpRetrieveFile(...)playRTSP(...)stopRTSP(...)addListener('onParamsListener', ...)addListener('onVideoDismiss', ...)- Interfaces
- Type Aliases
- Enums
connect(...)
connect(options?: { params: string; } | undefined) => Promise<connectResult>连接设备的接口,返回值是异步,需要根据设备响应后信息再返回
| Param | Type | Description |
| ------------- | -------------------------------- | ----------- |
| options | { params: string; } | 无实际作用,作保留用 |
Returns: Promise<connectResult>
snap(...)
snap(options?: { params: string; } | undefined) => Promise<connectResult>调用设备拍照功能,拍照后照片保存在设备。返回值同样是异
| Param | Type | Description |
| ------------- | -------------------------------- | ----------- |
| options | { params: string; } | 无实际作用,作保留用 |
Returns: Promise<connectResult>
record(...)
record(options: { starting: boolean; }) => Promise<connectResult>调用设备录像功能,返回值同样是异步
| Param | Type | Description |
| ------------- | ----------------------------------- | -------------------------------- |
| options | { starting: boolean; } | starting: true表示开始录像,false表示停止录像 |
Returns: Promise<connectResult>
stopConnecting(...)
stopConnecting(options?: { params: string; } | undefined) => Promise<void>断开设备连接
| Param | Type | Description |
| ------------- | -------------------------------- | ----------- |
| options | { params: string; } | 无实际作用,作保留用 |
setParameters(...)
setParameters(options: { params: Partial<FTPParameters>; }) => Promise<void>设置参数到设备 设备在连接的时候会返回初始化的参数,通过onParamsListener监听事件接口回调到前端,参数的字段是zfyParameters
| Param | Type | Description |
| ------------- | ---------------------------------------------------------------------------------------------------------- | --------------------- |
| options | { params: Partial<FTPParameters>; } | params: 设置参数信息,json格式 |
ftpConnect(...)
ftpConnect(options?: { params: string; } | undefined) => Promise<Result>打开FTP连接,一般来说原生在获取设备参数后会自动调用这个方法连接上设备的FTP 账号密码和端口都是通过初始化的设备参数获取。同时开放此方法给前端自由调用
| Param | Type | Description |
| ------------- | -------------------------------- | ----------- |
| options | { params: string; } | 无实际作用,作保留用 |
Returns: Promise<Result>
ftpListFiles(...)
ftpListFiles(options: { type: FTPFileEnum; }) => Promise<FTPListFileResult>获取设备上的文件,目前可查询图片和视频
| Param | Type | Description |
| ------------- | -------------------------------------------------------------- | ----------------------------------------------- |
| options | { type: FTPFileEnum; } | type: PICTURE是图片类型,VIDEO是视频类型。注意枚举对应的值不要修改,用于查询 |
Returns: Promise<FTPListFileResult>
ftpRetrieveFile(...)
ftpRetrieveFile(options: { fileName: string; ftpFilePath: string; }) => Promise<FTPRetrieveFile>下载执法仪的文件到本机
| Param | Type | Description |
| ------------- | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
| options | { fileName: string; ftpFilePath: string; } | fileName: 保存到本地的文件名,注意这个文件名是可以自定义的,最后以前端命名的文件名保存;ftpFilePath: 需要下载的文件的FTP地址,由查询时候返回的FtpFilePath字段带出给前端。 |
Returns: Promise<FTPRetrieveFile>
playRTSP(...)
playRTSP(options?: { params: string; } | undefined) => Promise<void>播放RTSP视频流,注意要连接设备后才能获取RTSP的地址(由原生获取,前端保证在连接后调用即可)
| Param | Type | Description |
| ------------- | -------------------------------- | ----------- |
| options | { params: string; } | 无实际作用,作保留用 |
stopRTSP(...)
stopRTSP(options?: { params: string; } | undefined) => Promise<void>停止播放RTSP,并释放资源,建议在应用退到后台、离开界面的时候释放资源
| Param | Type | Description |
| ------------- | -------------------------------- | ----------- |
| options | { params: string; } | 无实际作用,作保留用 |
addListener('onParamsListener', ...)
addListener(eventName: 'onParamsListener', listenerFunc: (data: { zfyParameters: Partial<FTPParameters>; }) => void) => Promise<PluginListenerHandle> & PluginListenerHandle监听事件名称:onParamsListener,接口将设备参数信息回调给前端,参数的字段是data.zfyParameters
| Param | Type | Description |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------- |
| eventName | 'onParamsListener' | 监听事件的名称 |
| listenerFunc | (data: { zfyParameters: Partial<FTPParameters>; }) => void | zfyParameters: 接口回调的参数信息,json格式 |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
addListener('onVideoDismiss', ...)
addListener(eventName: 'onVideoDismiss', listenerFunc: () => void) => Promise<PluginListenerHandle> & PluginListenerHandle监听事件名称:onVideoDismiss,关闭视频流弹窗时,接口通知前端
| Param | Type | Description |
| ------------------ | ----------------------------- | ----------- |
| eventName | 'onVideoDismiss' | 监听事件的名称 |
| listenerFunc | () => void | 回调方法 |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Interfaces
connectResult
| Prop | Type | Description |
| ----------- | -------------------- | -------------------------------- |
| ret | boolean | 是否成功,注意这个是有执法仪返回,和isSuccess性质不一样 |
| value | string | 由执法仪返回的信息 |
FTPParameters
| Prop | Type | Description |
| -------------------- | ------------------------------------------------------------- | ----------- |
| DevId | string | 设备编号 |
| FtpHttpPort | number | http端口 |
| FtpIp | string | FTP的ip |
| FtpPort | number | FTP端口 |
| FtpPwd | string | 密码 |
| FtpUser | string | 用户名 |
| IndicatorLight | number | 指示灯 |
| InfraredAuto | number | 自动红外 |
| LocationFreq | number | 定位回传频率 |
| NetTransBit | string | 图传设置(中文) |
| NetTransRes | number | 图传设置(编码) |
| PlaybackPwd | string | 设备(回放)密码设置 |
| PostRec | PostRecEnum | 延录 |
| PreRec | 0 | 1 | 预录 |
| ServerIP | string | 服务器IP |
| ServerPort | number | 服务器端口号 |
| SnapRes | number | 拍照分辨率 |
| SnapShot | SnapShotEnum | 连拍张数 |
| SnapShotTime | SnapShotTimeEnum | 定时拍照 |
| User | string | 用户号 |
| VideoQuality | VideoQualityEnum | 视频质量 |
| VideoRes | VideoResEnum | 视频分辨率 |
| VidPtime | VidPtimeEnum | 视频分段 |
| Fbutton | number | 未知 |
| Type | string | 未知 |
Result
| Prop | Type | Description |
| --------------- | -------------------- | ------------------------------------ |
| isSuccess | boolean | 表示操作是否成功 |
| message | string | 插件返回给前端的提示信息,主要用于快速识别异常的原因,面向开发人员的信息 |
FTPListFileResult
| Prop | Type | Description |
| ---------- | ---------------------------- | ----------- |
| data | FTPFileModule[] | 文件的列表 |
FTPFileModule
| Prop | Type | Description |
| ----------------- | ------------------- | ------------------------------- |
| FileName | string | 文件在执法仪上的名字 |
| FileSize | number | 文件的大小 |
| Times | string | 文件的时间 |
| FtpFilePath | string | 文件执法仪上的FTP地址,下载文件需要根据这个地址找到文件下载 |
FTPRetrieveFile
| Prop | Type | Description |
| ------------------- | ------------------- | ------------ |
| localFilePath | string | 文件下载保存到本地的路径 |
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove | () => Promise<void> |
Type Aliases
Partial
Make all properties in T optional
{ [P in keyof T]?: T[P]; }
Enums
PostRecEnum
| Members | Value |
| ------------ | -------------- |
| '关闭' | 0 |
| '10秒' | 1 |
| '30秒' | 2 |
| '1分钟' | 3 |
| '2分钟' | 4 |
| '5分钟' | 5 |
| '10分钟' | 6 |
| '30分钟' | 7 |
SnapShotEnum
| Members | Value |
| ----------- | -------------- |
| '1张' | 0 |
| '3张' | 1 |
| '5张' | 2 |
| '10张' | 3 |
| '20张' | 4 |
| '30张' | 5 |
SnapShotTimeEnum
| Members | Value |
| ----------- | -------------- |
| '关闭' | 0 |
| '30秒' | 1 |
| '1分钟' | 2 |
| '2分钟' | 3 |
| '4分钟' | 4 |
| '5分钟' | 5 |
VideoQualityEnum
| Members | Value |
| --------- | -------------- |
| '高' | 0 |
| '中' | 1 |
| '低' | 2 |
VideoResEnum
| Members | Value |
| ----------------------- | -------------- |
| "1080P 1920*1080" | 0 |
| "720P 1280*720" | 1 |
| "480P 720*480" | 2 |
| "2K" | 3 |
VidPtimeEnum
| Members | Value |
| ------------ | -------------- |
| '自动' | 0 |
| '1分钟' | 1 |
| '3分钟' | 2 |
| '5分钟' | 3 |
| '10分钟' | 4 |
| '20分钟' | 5 |
| '30分钟' | 6 |
FTPFileEnum
| Members | Value | Description |
| ------------- | ----------------------- | ----------- |
| PICTURE | "/PICTURE" | 图片类型 |
| VIDEO | "/MP4" | 视频类型 |
