可开发除配网外所有Yoosee已开发的功能,配网在下面说明中单独列出,对于Demo中的内容,会根据实际情况增加;
以下功能已经完成
【修改】p2p库升级为3.0 P2PHandle中大部分方法增加参数:localAreaIp 例:
/**
* @param contactId 联系人ID (联系人类型是设备)
* 如果是局域网用ip,不是局域网用联系人id 如果是AP模式则为"1"
* @param password 联系人监控密码
*/
public void getNpcSettings(String contactId, String password) ;
/**
* @param contactId 联系人ID (联系人类型是设备)
* 一定是设备id
* @param password 联系人监控密码
* @param localAreaIp 局域网int型表示的设备ip地址,ap模式下传真实ip值,外网通信置0
*/
public void getNpcSettings(String contactId, String password, int localAreaIp) ;
【修改】全景全新修改
不提供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的IP2P
与ISetting
):
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();
APPID
,APPTOKEN
,APPVersion
需要提供包名分配APPVersion
建议保证每个新版本都不相同,但前两位保持一致,这样易于排查问题与将来新功能的加入,例如:00.23.00.01
-->00.23.00.02
-->00.23.00.03
-->...RelativeLayout
包裹,且不要在子类中声明(父类已存在)配网是是添加摄像头的前期必要步骤,但已联网的设备不需此步骤。配网代码流程相似,基本都是将WiFi信息通过某种方式发给设备,设备连接成功之后通过UDP告知APP自身信息
HttpErrorCode
引用C/C++