Giter VIP home page Giter VIP logo

tuya_p2p_new_demo's Introduction

P2P SDK说明

p2p sdk集成了iot功能与p2p功能

P2pJniApi 说明

初始化sdk

 /**
 * sdk初始化
 * @param pid 产品id
 * @param uid  uid
 * @param key key
 * @param path  存储路径,类似"/sdcard/"
 * @param version  版本名
 * @param netcardName 网卡名
 * @return 0 成功
 *         非0 失败
 */
    external fun initSdk(
            pid: String, uid: String, key: String, path: String,
            version: String, netcardName: String
            ): Int

初始化p2p

    /**
     * 初始化p2p
     * @return 0 成功
     *         非0 失败
     */
    external fun initTransP2p(): Int

关闭p2p连接

    /**
     * 关闭p2p连接
     */
    external fun closeTransP2p()

多个dp上传接口

 	/**
     * 多个dp上传接口
     * @param hasTime 是否使用时间戳
     * @param events  上传dp数组
     * @return 0 成功
     *        非0 失败
     */
    external fun do_report(hasTime: Boolean, events: Array<DPEvent>): Int

上传单个dp

	/**
     * 上传单个dp
     * @param dpi dip
     * @param type dp类型
     * @param value dp数据
     * @param time 时间戳
     * @return 0 成功
     *         非0 失败
     */
    external fun do_report(dpid: Int, type: Int, value: Any?, time: Int): Int

监听的mq协议类型

	 /**
     * 监听的mq协议类型
     * @param protocol  协议类型
     * @return 0 成功
     *        非0 失败
     */
    external fun regist_mqtt_msg(protocol: Int): Int

上传mq message

/**
     * 上传mq message
     * @param protocol 协议类型
     * @param msg 消息
     * @return 0 成功
     *        非0 失败
     */
    external fun send_mqtt_msg(protocol: Int, msg: String): Int

Http请求

	/**
     * Http请求
     * @param apiName  
     * @param  apiVersion
     * @param jsonMsg 
     */
    external fun http_request(apiName: String, apiVersion: String, jsonMsg: String): HttpResponse

获取 deviceId

	/**
     * get deviceId
     * @return
     */
    external fun getDeviceId(): String

###重置设备

 	/**
     * unreset device
     * @return ret
     */
    external fun unActive(): Int

p2p sdk回调

interface P2pCallBack {
    /**
     * 云端解绑设备回调
     * @param type 0 GW_LOCAL_RESET_FACTORY
     *             1 GW_REMOTE_UNACTIVE
     *             2 GW_LOCAL_UNACTIVE
     *             3 GW_REMOTE_RESET_FACTORY
     *             4 GW_RESET_DATA_FACTORY
     */
    fun onReset(type: Int)

    //
    /**
     * 收到配网二维码短链
     * @param url 二维码连接
     */
    fun onShorturl(url: String?)

    //接收到的图视频数据
    fun recvVideData(
            sessionId: Int,
            status: RecvStatus,
            buf: ByteArray,
            len: Int,
            downloadAlbumHead: Download_Album_Head,
            c2cCmdIoCtrlAlbumDownloadStart: C2C_CMD_IO_CTRL_ALBUM_DOWNLOAD_START
    )

    /**
     * mq网络状态变化
     * @param
     */
    fun onNetStauts(status: Int)

    /**
     * mqtt消息回调
     * @param protocol 协议号
     * @param msgObj 消息
     */
    fun onMqttMsg(protocol: Int, msgObj: JSONObject?)

    /**
     * dp事件接收
     *
     * @param event 事件类型
     * DPEvent.Type.PROP_BOOL
     * DPEvent.Type.PROP_VALUE
     * DPEvent.Type.PROP_STR
     * DPEvent.Type.PROP_ENUM
     * DPEvent.Type.PROP_BITMAP
     * DPEvent.Type.PROP_RAW
     */
    fun onDpEvent(event: DPEvent)
}

p2p sdk升级回调

interface UpgradeEventCallback {

    /**
     * sdk 接收到后端的升级推送的时候,会触发此接口 附带升级信息
     * @param version
     */
    void onUpgradeInfo(String version);

    /**
     * 升级文件开始下载
     */
    void onUpgradeDownloadStart();

    /**
     * 升级文件下载进度
     */
    void onUpgradeDownloadUpdate(int progress);

    /**
     * sdk 下载升级文件下载完成触发此接口
     */
    void upgradeFileDownloadFinished(int resultCode, String file);
}
···

        ### 发送多个dp事件
        ```java
        /**
         * 发送多个dp事件
         *
         * @param events 多个dp类型
         * @return 0 成功
         *         非0 失败 
         */
        fun sendDP(events: List<DPEvent>): Int

开始升级

/**
 * start upgrade download
 * @return 0 sucess
 *         not 0 failed
 */
    external fun start_upgradeDownload():Int

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.