12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- # -*- coding: utf-8 -*-
- # !/usr/bin/env python
- from typing import Dict
- from apps.web.constant import DeviceCmdCode, MQTT_TIMEOUT
- from apps.web.core.adapter.base import SmartBox
- from apps.web.core.exceptions import ServiceException
- from apps.web.core.networking import MessageSender
- class JHAccessBox(SmartBox):
- def __init__(self, device):
- super(JHAccessBox, self).__init__(device)
- def test(self, coins):
- devInfo = MessageSender.send(device = self.device, cmd = DeviceCmdCode.OPERATE_DEV_SYNC, payload = {
- 'IMEI': self._device['devNo'],
- 'funCode': '01',
- 'data': '01'
- })
- return devInfo
- def start_device(self, package, openId, attachParas):
- # type: (Dict, str, Dict)->Dict
- devInfo = MessageSender.send(device = self.device, cmd = DeviceCmdCode.OPERATE_DEV_SYNC, payload = {
- 'IMEI': self._device['devNo'],
- 'funCode': '01',
- 'data': '01'
- }, timeout = MQTT_TIMEOUT.START_DEVICE)
- # TODO zjl 此设备类型不会有
- if devInfo.has_key('rst') and devInfo['rst'] != 0:
- if devInfo['rst'] == -1:
- raise ServiceException(
- {
- 'result': 2,
- 'description': u'正在玩命找网络,请稍后重试'
- }
- )
- elif devInfo['rst'] == 1:
- raise ServiceException(
- {
- 'result': 2,
- 'description': u'设备正在忙,请稍后再试'
- }
- )
- return devInfo
|