| | |
| | | import com.hdl.sdk.common.utils.SPUtils; |
| | | import com.hdl.sdk.common.utils.gson.GsonConvert; |
| | | import com.hdl.sdk.connect.HDLLink; |
| | | import com.hdl.sdk.connect.bean.LinkFunctionInfo; |
| | | import com.hdl.sdk.connect.bean.LinkResponse; |
| | | import com.hdl.sdk.connect.bean.request.AttributesRequest; |
| | | import com.hdl.sdk.connect.bean.request.AuthenticateRequest; |
| | |
| | | import com.hdl.sdk.connect.bean.response.UpdateInfo; |
| | | import com.hdl.sdk.connect.callback.HDLLinkCallBack; |
| | | import com.hdl.sdk.connect.callback.HDLLinkResponseCallBack; |
| | | import com.hdl.sdk.connect.callback.HDLLinkTCallBack; |
| | | import com.hdl.sdk.connect.cloud.CallBackListener; |
| | | import com.hdl.sdk.connect.cloud.CheckAppVersionListener; |
| | | import com.hdl.sdk.connect.cloud.HDLException; |
| | |
| | | import com.hdl.sdk.connect.cloud.bean.AiLoginInfo; |
| | | import com.hdl.sdk.connect.config.HDLLinkConfig; |
| | | import com.hdl.sdk.connect.socket.HDLAuthSocket; |
| | | import com.hdl.sdk.connect.socket.HDLSocket; |
| | | import com.hdl.sdk.sourceos.utils.SPKey; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | |
| | | private EventListener allTopicsListener; |
| | | private String testLightSid = "020101A19B485D02020100010101"; |
| | | private String secret = ""; |
| | | private List<FunctionBean> devicesList = new ArrayList<>(); |
| | | private List<FunctionBean> roomDevicesList = new ArrayList<>(); |
| | | private List<LinkFunctionInfo> devicesList = new ArrayList<>(); |
| | | private List<LinkFunctionInfo> roomDevicesList = new ArrayList<>(); |
| | | private List<SceneBean> sceneList = new ArrayList<>(); |
| | | private List<SceneDetailBean> sceneDetailList = new ArrayList<>(); |
| | | private List<SceneDetailBean> roomSceneList = new ArrayList<>(); |
| | |
| | | responseTv.setText(""); |
| | | |
| | | String supplier = "JINMAOYUN";//厂商 |
| | | // String mac = "AA00000000000100";//设备唯一MAC地址 |
| | | String mac = editText.getText().toString(); |
| | | String mac = "f2c5d8bad48f";//设备唯一MAC地址 |
| | | // String mac = editText.getText().toString(); |
| | | String spk = "screen.touch";//产品spk |
| | | |
| | | if (TextUtils.isEmpty(mac)) { |
| | |
| | | |
| | | selectnetwork(); |
| | | checkIfCertified(); |
| | | //initDeviceInfo();//不走从机入网的方式不需要初始化 |
| | | initDeviceInfo();//不走从机入网的方式不需要初始化,走从机入网则需要初始化 |
| | | registerAllTopicsListener(); |
| | | HDLLink.getInstance().setDeleteNetworkListener(new DeleteNetworkListener() { |
| | | @Override |
| | |
| | | public void onMessage(Object msg) { |
| | | LinkResponse response = (LinkResponse) msg; |
| | | Log.i("onMessage", "response.getTopic():" + response.getTopic()); |
| | | String topic = String.format(TopicConstant.GATEWAY_LOGIN, |
| | | HDLLinkConfig.getInstance().getGatewayId()) + "_reply"; |
| | | ; |
| | | |
| | | if ("/user/all/custom/gateway/broadcast_reply".equals(response.getTopic())) { |
| | | localSecret.setText("密钥:" + HDLLinkConfig.getInstance().getLocalSecret()); |
| | | |
| | | } else if (topic.equals(response.getTopic())) { |
| | | //tcp连接成功,处理业务逻辑 |
| | | } |
| | | } |
| | | }; |
| | |
| | | infoBean.setDeviceName("魔镜");//设备名字 |
| | | infoBean.setDeviceModel("HDLSDK");//设备型号 |
| | | infoBean.setAccessMode("WIFI"); |
| | | infoBean.setIPGateway("192.168.31.1"); |
| | | infoBean.setIPAddress("192.168.31.103"); |
| | | infoBean.setIPGateway("192.168.1.1"); |
| | | infoBean.setIPAddress("192.168.1.103"); |
| | | infoBean.setGateway_type("screen.touch"); |
| | | infoBean.setHw_version("HW2.0"); |
| | | infoBean.setFw_version("Fw1.0"); |
| | |
| | | //认证提交参数准备 |
| | | |
| | | //正式服务器 |
| | | String spkStr = "screen.mirror";//产品spk |
| | | String spkStr = "screen.touch";//产品spk |
| | | String macStr = "f2c5d8bad48f";//设备唯一MAC地址 |
| | | |
| | | String mac_key = stringToMD5(stringToMD5(macStr + secret)); |
| | |
| | | void searchGatewayBroadcast() { |
| | | tv.setText("搜索网关中..."); |
| | | responseTv.setText(""); |
| | | HDLLinkConfig.getInstance().getGatewayId(); |
| | | |
| | | String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); |
| | | Log.d("panlili", "MainActivity.java:searchGatewayBroadcast----->gatewayId= " + gatewayId); |
| | | HDLLink.getInstance().searchGatewayBroadcast(new HDLAuthSocket.SearchGatewayCallBack() { |
| | | @Override |
| | | public void onError(HDLLinkException e) { |
| | |
| | | void getFunctionList() { |
| | | tv.setText("获取设备列表中..."); |
| | | responseTv.setText(""); |
| | | HDLLink.getInstance().getFunctionList(new HDLLinkCallBack() { |
| | | HDLLink.getInstance().getFunctionInfoList(new HDLLinkTCallBack<List<LinkFunctionInfo>>() { |
| | | @Override |
| | | public void onSuccess(List<LinkFunctionInfo> data) { |
| | | if (data != null && data.size() != 0) { |
| | | devicesList.clear(); |
| | | devicesList.addAll(data); |
| | | |
| | | tv.setText("获取设备列表成功"); |
| | | responseTv.setText(data.toString()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onError(HDLLinkException error) { |
| | | tv.setText(error.getMsg()); |
| | | } |
| | | |
| | | @Override |
| | | public void onSuccess(String data) { |
| | | tv.setText("获取设备列表成功"); |
| | | responseTv.setText(data); |
| | | |
| | | handelFunctionList(data); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | void handelFunctionList(String data) { |
| | | try { |
| | | final LinkResponse linkResponse = GsonConvert.getGson().fromJson(data, new TypeToken<LinkResponse>() { |
| | | }.getType()); |
| | | |
| | | final BaseLocalResponse<List<FunctionBean>> bean = GsonConvert.getGson().fromJson(linkResponse.getData(), new TypeToken<BaseLocalResponse<List<FunctionBean>>>() { |
| | | }.getType()); |
| | | devicesList.clear(); |
| | | devicesList.addAll(bean.getObjects()); |
| | | |
| | | Log.d(TAG, "handelFunList-----> " + devicesList.toString()); |
| | | } catch (Exception e) { |
| | | Log.e(TAG, "handelFunList: " + e.getMessage()); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | sids.add(testLightSid); |
| | | } |
| | | |
| | | HDLLink.getInstance().getFunctionAttribute(sids, new HDLLinkCallBack() { |
| | | HDLLink.getInstance().getFunctionAttributeInfo(sids, new HDLLinkTCallBack<List<LinkFunctionInfo>>() { |
| | | @Override |
| | | public void onSuccess(String msg) { |
| | | responseTv.setText(msg); |
| | | public void onSuccess(List<LinkFunctionInfo> data) { |
| | | if (data != null && data.size() != 0) { |
| | | responseTv.setText(data.toString()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | request.setStatus(statusBeanList); |
| | | requestList.add(request); |
| | | |
| | | HDLLink.getInstance().propertyDown(requestList, new HDLLinkCallBack() { |
| | | HDLLink.getInstance().propertyDownDevice(requestList, new HDLLinkTCallBack<String>() { |
| | | @Override |
| | | public void onSuccess(String data) { |
| | | responseTv.setText(data); |
| | |
| | | String propertyDownTopic = String.format(TopicConstant.PROPERTY_DOWN, HDLLinkConfig.getInstance().getGatewayId()); |
| | | String bodyStr = getPropertyDownBodyStr(); |
| | | HDLLink.getInstance().tcpSendMsg(propertyDownTopic, bodyStr); |
| | | |
| | | } |
| | | |
| | | /** |