jwkj / GwellDemo

a demo to use P2P-Core
16 stars 6 forks source link

GwellDemo Build Status Download

1.Demo function List

可开发除配网外所有Yoosee已开发的功能,配网在下面说明中单独列出,对于Demo中的内容,会根据实际情况增加;
以下功能已经完成

2.APK下载地址

3.常见问题

4.SDK说明文档

P2P-Core 使用说明

1.版本记录

64位库更新 (2019.8.27)
0.5.4 (2019.8.21)
改用aar包 (2019.5.25)
0.4.4.9 (2018.12.06)
0.4.4 (2018.03.05)
0.4.3 (2017.07.14)
0.3.8 (2017.04.14)
0.3.7 (2017.04.11)
0.3.6 (2017.04.10)
0.3.3 (2017.03.31)
0.3.1 (2017.03.29)
更多历史版本...

2.集成

不提供Eclipse的集成方式,如有需要可自行寻找解决办法(参考,未经实践,如有成功的小伙伴,可发总结交流文章给作者) 将aar文件拷贝到app/libs目录下并在该module的build.gradle文件中添加对aar文件的依赖:

dependencies {
compile fileTree(dir: 'libs', include: ['*.aar'])
}

3.使用(Web接口P2P接口完整Doc文档)

3.1 在自定义Application中初始化

    public class MyApp extends Application {
        public static MyApp app;
        //这三个参数需要服务器分配(ID token与版本(在同一版本)是固定的,可硬编码在代码中。版本迭代时需要修改版本)
        //连接时需要传入,下面的数据仅供测试使用
        //three parems come frome Gwell , the value below just test
        public final static String APPID="1e9a2c3ead108413e8218a639c540e44";
        public final static String APPToken="7db7b2bff80a025a3dad546a4d5a6c3ee545568d4e0ce9609c0585c71c287d08";
        //前两位是客户APP唯一编号(00.00 由技威分配),后两位是APP版本号(客户自定义),此参数不可省略
        public final static String APPVersion="00.00.00.01";
        @Override
        public void onCreate() {
            super.onCreate();
            app = this;
            initP2P(app);
        }
        private void initP2P(MyApp app) {  
             //ID、TOKEN与APPVersion需要在服务器申请登记
             P2PSpecial.getInstance().init(app,APPID,APPToken,APPVersion);
        }
    }

3.2 设置监控和设备设置项监听给SDK:P2PHandler.getInstance().p2pInit(mContext, new P2PListener(), new SettingListener())(P2PListener与SettingListener两个监听分别实现的是P2P-Core的IP2PISetting):

public class P2PListener implements IP2P {
        ...
        ...
        @Override
        public void vCalling(boolean isOutCall, String threeNumber, int type) {
        //手机被动呼叫
        }

        @Override
        public void vReject(String deviceId, int reason_code) {
            //监控挂断时回调
            Intent intent = new Intent();
            intent.setAction(MonitorActivity.P2P_REJECT);
            intent.putExtra("reason_code", reason_code);
            MyApp.app.sendBroadcast(intent);
        }
        ...
        ...
}

public class SettingListener implements ISetting {
    //所有的ACK回调都会有四个状态result:9996(权限不足(访客))9997(指令发送成功)9998(指令发送失败)9999(密码错误)
    //一般ACK_xxx回调  会有一个  xxx  回调对应 (eg:checkPasswold除外,这个指令只能通过指令是否发送成功来判断密码)
    //ACK_xxx  9997是指令发送成功,但不保证设备执行成功(小概率)
    //xxx这个回调才是设备真实的执行结果会调
    ...
    ...
        @Override
        public void ACK_vRetSetDeviceTime(int msgId, int result) {
        //设置设备时间命令的ACK回调
        }

        @Override
        public void ACK_vRetGetDeviceTime(int msgId, int result) {
        //获取设备时间命令的ACK回调
        }
    ...
    ...
}

3.3 注册SDK;注册需要使用到的一些信息是通过登录接口返回的:

int code1= code1;
int code2 = code2;
String sessionId ="sessionId1";
String SessionId2 ="sessionId2";
int sessionid1=(int)Long.parseLong(sessionId);
int sessionid2=(int)Long.parseLong(SessionId2);
String userId= "userId";
boolean connect = P2PHandler.getInstance().p2pConnect(userId,sessionid1,sessionid2,
        code1, code2,0);
if(connect) {
    Log.i(TAG, "SDK注册成功");
}

3.4 获取设备信息:P2PHandler.getInstance().getFriendStatus(new int[]{设备ID}, P2PConstants.P2P_Server.SERVER_NEW_P2P);

3.5 把设备p2p版本信息设置给SDK:

int[] devIds = new int[]{设备ID};
short[] versions = new short[]{设备版本信息};
MediaPlayer.setP2PLibVersion(devIds, versions, devIds.length());

. . .

3.6 注销SDK:MediaPlayer.getInstance().native_p2p_disconnect();

4.备注

P2P消息简易流程图

5.关于图像

6.技术支持  

7.配网(让摄像头链接网络)  

 配网是是添加摄像头的前期必要步骤,但已联网的设备不需此步骤。配网代码流程相似,基本都是将WiFi信息通过某种方式发给设备,设备连接成功之后通过UDP告知APP自身信息  

8.WebAPI反馈码说明

9.包含的三方库

C/C++

更多历史版本

0.2.8 (2017.03.23)
0.2.7 (2017.03.22)
0.2.6 (2017.03.21)
0.2.3 (Yoosee 15)
0.2.2 (Yoosee 14)