| | |
| | | import androidx.appcompat.content.res.AppCompatResources; |
| | | |
| | | import android.Manifest; |
| | | import android.content.ComponentName; |
| | | import android.content.ServiceConnection; |
| | | import android.content.pm.PackageManager; |
| | | import android.os.Bundle; |
| | | import android.os.IBinder; |
| | | import android.os.Process; |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | | import com.hdl.linkpm.sdk.home.type.HomeType; |
| | | import com.hdl.linkpm.sdk.ota.bean.GatewayDriverBean; |
| | | import com.hdl.photovoltaic.R; |
| | | import com.hdl.photovoltaic.base.CustomBaseActivity; |
| | | import com.hdl.photovoltaic.bean.MqttInfo; |
| | |
| | | import com.hdl.photovoltaic.databinding.ActivityMyPowerStationBinding; |
| | | import com.hdl.photovoltaic.listener.CloudCallBeak; |
| | | import com.hdl.photovoltaic.other.HdlDeviceLogic; |
| | | import com.hdl.photovoltaic.other.HdlFileLogic; |
| | | import com.hdl.photovoltaic.other.HdlLogLogic; |
| | | import com.hdl.photovoltaic.other.HdlMqttLogic; |
| | | import com.hdl.photovoltaic.other.HdlOtaLogic; |
| | | import com.hdl.photovoltaic.other.HdlThreadLogic; |
| | | import com.hdl.photovoltaic.other.HdlUniLogic; |
| | | import com.hdl.photovoltaic.ui.bean.DeviceRemoteInfo; |
| | | import com.hdl.photovoltaic.uni.HDLUniMP; |
| | | import com.hdl.photovoltaic.utils.AesUtils; |
| | | import com.hdl.photovoltaic.utils.AppManagerUtils; |
| | | import com.hdl.photovoltaic.utils.Md5Utils; |
| | | import com.hdl.photovoltaic.utils.PermissionUtils; |
| | | import com.hdl.sdk.link.HDLLinkLocalSdk; |
| | | import com.hdl.sdk.link.common.event.EventListener; |
| | | import com.hdl.sdk.link.core.bean.LinkResponse; |
| | | import com.hdl.sdk.link.core.bean.ModbusResponse; |
| | | import com.hdl.sdk.link.core.bean.eventbus.EventNotifyRefreshGatewayAesKeyInfo; |
| | | import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; |
| | | import com.hdl.sdk.link.core.bean.gateway.GatewayBean; |
| | | import com.hdl.sdk.link.core.config.HDLLinkConfig; |
| | | import com.hdl.sdk.link.core.utils.mqtt.MqttRecvClient; |
| | |
| | | import org.greenrobot.eventbus.Subscribe; |
| | | import org.greenrobot.eventbus.ThreadMode; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | |
| | | import okhttp3.ResponseBody; |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | @Override |
| | | public void onBindView(Bundle savedInstanceState) { |
| | | |
| | | //初始化 |
| | | initView(); |
| | | //初始化界面监听器 |
| | |
| | | @Override |
| | | public void onMessage(Object msg) { |
| | | |
| | | if (msg == null) { |
| | | return; |
| | | } |
| | | if (msg instanceof ModbusResponse) { |
| | | ModbusResponse response = (ModbusResponse) msg; |
| | | if (response.getTopic() == null) { |
| | | return; |
| | | } |
| | | HdlLogLogic.print("监听到的数据==="+new Gson().toJson(response),false); |
| | | HdlLogLogic.print("监听到的数据===" + new Gson().toJson(response), false); |
| | | // if (response.getTopic().endsWith("custom/native/inverter/up")) { |
| | | HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean(); |
| | | uniCallBackBaseBean.setType(response.getTopic()); |
| | |
| | | HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean); |
| | | // } |
| | | |
| | | } else if (msg instanceof LinkResponse) { |
| | | LinkResponse linkResponse = (LinkResponse) msg; |
| | | if (linkResponse.getTopic() == null) { |
| | | return; |
| | | } |
| | | if (linkResponse.getTopic().endsWith("/ota/device/progress/up")) { |
| | | HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean(); |
| | | uniCallBackBaseBean.setType(linkResponse.getTopic()); |
| | | uniCallBackBaseBean.setData(linkResponse.getData()); |
| | | HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_REPLY_OTA_MODEL, uniCallBackBaseBean); |
| | | } |
| | | } |
| | | } |
| | | }; |
| | |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlLogLogic.print("读取mqtt远程信息失败==="+e.getMessage(), e.getCode(),true); |
| | | HdlLogLogic.print("读取mqtt远程信息失败===" + e.getMessage(), e.getCode(), true); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Subscribe(threadMode = ThreadMode.MAIN) |
| | | public void onEventMessage(EventNotifyRefreshGatewayAesKeyInfo event) { |
| | | public void onEventMessage(BaseEventBus event) { |
| | | //网关更新mqtt秘钥更新通知 |
| | | if (event == null) { |
| | | return; |
| | | } |
| | | if (TextUtils.isEmpty(event.getTopic())) { |
| | | return; |
| | | } |
| | | String[] topics = event.getTopic().split("/"); |
| | | //主题不符合规则不处理 |
| | | if (topics.length < 3) { |
| | | return; |
| | | } |
| | | int index = -1; |
| | | List<GatewayBean> list = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | GatewayBean gatewayBean = list.get(i); |
| | | if (gatewayBean.getGatewayId().equals(event.getGatewayId())) { |
| | | if (gatewayBean.getGatewayId().equals(topics[2])) { |
| | | index = i; |
| | | break; |
| | | } |
| | |
| | | super.onBackPressed(); |
| | | } |
| | | |
| | | |
| | | } |