|
@@ -29,6 +29,7 @@ import com.ifastore.maintain.repository.remote.mqtt.flatbuffer.MaintainFlatHandl
|
|
|
import com.ifastore.maintain.repository.remote.mqtt.flatbuffer.src.weightbox.msg.AdjustZero;
|
|
import com.ifastore.maintain.repository.remote.mqtt.flatbuffer.src.weightbox.msg.AdjustZero;
|
|
|
import com.ifastore.maintain.repository.remote.mqtt.flatbuffer.src.weightbox.msg.AdjustZeroEvent;
|
|
import com.ifastore.maintain.repository.remote.mqtt.flatbuffer.src.weightbox.msg.AdjustZeroEvent;
|
|
|
import com.ifastore.maintain.repository.remote.mqtt.flatbuffer.src.weightbox.msg.Calibration;
|
|
import com.ifastore.maintain.repository.remote.mqtt.flatbuffer.src.weightbox.msg.Calibration;
|
|
|
|
|
+import com.ifastore.maintain.repository.remote.mqtt.flatbuffer.src.weightbox.msg.CheckSensor;
|
|
|
import com.ifastore.maintain.repository.remote.mqtt.flatbuffer.src.weightbox.msg.Gratings;
|
|
import com.ifastore.maintain.repository.remote.mqtt.flatbuffer.src.weightbox.msg.Gratings;
|
|
|
import com.ifastore.maintain.repository.remote.mqtt.flatbuffer.src.weightbox.msg.Monitoring;
|
|
import com.ifastore.maintain.repository.remote.mqtt.flatbuffer.src.weightbox.msg.Monitoring;
|
|
|
import com.ifastore.maintain.repository.remote.mqtt.flatbuffer.src.weightbox.msg.Open;
|
|
import com.ifastore.maintain.repository.remote.mqtt.flatbuffer.src.weightbox.msg.Open;
|
|
@@ -50,6 +51,7 @@ import static android.os.Build.ID;
|
|
|
import static android.provider.CalendarContract.Calendars.NAME;
|
|
import static android.provider.CalendarContract.Calendars.NAME;
|
|
|
import static com.ifastore.maintain.common.Contants.CMD_MQ_ADJUST_EVENT;
|
|
import static com.ifastore.maintain.common.Contants.CMD_MQ_ADJUST_EVENT;
|
|
|
import static com.ifastore.maintain.common.Contants.CMD_MQ_CALIBRATION;
|
|
import static com.ifastore.maintain.common.Contants.CMD_MQ_CALIBRATION;
|
|
|
|
|
+import static com.ifastore.maintain.common.Contants.CMD_MQ_CHECK_SENSOR;
|
|
|
import static com.ifastore.maintain.common.Contants.CMD_MQ_GRATINGS;
|
|
import static com.ifastore.maintain.common.Contants.CMD_MQ_GRATINGS;
|
|
|
import static com.ifastore.maintain.common.Contants.CMD_MQ_MONITORING;
|
|
import static com.ifastore.maintain.common.Contants.CMD_MQ_MONITORING;
|
|
|
import static com.ifastore.maintain.common.Contants.CMD_MQ_OPENDOOR;
|
|
import static com.ifastore.maintain.common.Contants.CMD_MQ_OPENDOOR;
|
|
@@ -123,6 +125,7 @@ public class ControlService extends Service {
|
|
|
IntentFilter filter = new IntentFilter();
|
|
IntentFilter filter = new IntentFilter();
|
|
|
filter.addAction(CMD_MQ_SET_ZERO);
|
|
filter.addAction(CMD_MQ_SET_ZERO);
|
|
|
filter.addAction(CMD_MQ_CALIBRATION);
|
|
filter.addAction(CMD_MQ_CALIBRATION);
|
|
|
|
|
+ filter.addAction(CMD_MQ_CHECK_SENSOR);
|
|
|
registerReceiver(messageRecvice, filter);
|
|
registerReceiver(messageRecvice, filter);
|
|
|
Logger.debug("initBoardCast");
|
|
Logger.debug("initBoardCast");
|
|
|
}
|
|
}
|
|
@@ -165,6 +168,13 @@ public class ControlService extends Service {
|
|
|
data = maintainFlatHandler.createCalibrationBuffer(bean);
|
|
data = maintainFlatHandler.createCalibrationBuffer(bean);
|
|
|
mqttManager.publishControlMessage(CMD_MQ_CALIBRATION, sn, data, bean.getReply());
|
|
mqttManager.publishControlMessage(CMD_MQ_CALIBRATION, sn, data, bean.getReply());
|
|
|
break;
|
|
break;
|
|
|
|
|
+ case CMD_MQ_CHECK_SENSOR:
|
|
|
|
|
+ sn = intent.getStringExtra("sn");
|
|
|
|
|
+ String reply = "maintain-"+CMD_MQ_CHECK_SENSOR+"-"+clientID;
|
|
|
|
|
+ int result = 0;
|
|
|
|
|
+ data = maintainFlatHandler.createCheckSensorBuffer(reply, result);
|
|
|
|
|
+ mqttManager.publishControlMessage(CMD_MQ_CHECK_SENSOR, sn, data, reply);
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -266,6 +276,9 @@ public class ControlService extends Service {
|
|
|
case CMD_MQ_SENSOR_EVENT:
|
|
case CMD_MQ_SENSOR_EVENT:
|
|
|
remoteReqSensorEvent((SensorEvent) reqmsg.getMesg());
|
|
remoteReqSensorEvent((SensorEvent) reqmsg.getMesg());
|
|
|
break;
|
|
break;
|
|
|
|
|
+ case CMD_MQ_CHECK_SENSOR:
|
|
|
|
|
+ remoteReqSensorEvent((SensorEvent) reqmsg.getMesg());
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -347,6 +360,11 @@ public class ControlService extends Service {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param sensorEvent
|
|
|
|
|
+ * type = 0 Calibration result
|
|
|
|
|
+ * type = 1 checkSensor result,
|
|
|
|
|
+ */
|
|
|
private void remoteReqSensorEvent(SensorEvent sensorEvent){
|
|
private void remoteReqSensorEvent(SensorEvent sensorEvent){
|
|
|
List<String> gratingsList = new ArrayList<>();
|
|
List<String> gratingsList = new ArrayList<>();
|
|
|
for(int i = 0; i < sensorEvent.gratingsLength(); i ++){
|
|
for(int i = 0; i < sensorEvent.gratingsLength(); i ++){
|
|
@@ -355,13 +373,16 @@ public class ControlService extends Service {
|
|
|
gratingsList.add(sensorEvent.gratings(i));
|
|
gratingsList.add(sensorEvent.gratings(i));
|
|
|
}
|
|
}
|
|
|
Intent intent = new Intent();
|
|
Intent intent = new Intent();
|
|
|
- intent.setAction(CMD_MQ_SENSOR_EVENT+MQ_ACK);
|
|
|
|
|
|
|
+ if(sensorEvent.type()==0){
|
|
|
|
|
+ intent.setAction(CMD_MQ_SENSOR_EVENT+MQ_ACK);
|
|
|
|
|
+ }else if(sensorEvent.type()==1){
|
|
|
|
|
+ intent.setAction(CMD_MQ_CHECK_SENSOR+MQ_ACK);
|
|
|
|
|
+ }
|
|
|
intent.putStringArrayListExtra("result", (ArrayList<String>) gratingsList);
|
|
intent.putStringArrayListExtra("result", (ArrayList<String>) gratingsList);
|
|
|
sendBroadcast(intent);
|
|
sendBroadcast(intent);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void onDestroy() {
|
|
public void onDestroy() {
|
|
|
Logger.error("onDestroy");
|
|
Logger.error("onDestroy");
|