def starttransport(self): """ start transport """ print ">>>>>>> start transport ", self.transport_name if self.transport_name == "bluetooth": print "start bluetooth" self.bluetooth = androbluetooth(name=self.bluetooth_name, logfunc=self.log) self.transport = self.bluetooth.connect() if self.transport_name == "tcpip": print "start tcpip" self.transport = jsonrpc.TransportTcpIp(addr=(self.tcpip_name, 1000), timeout=3, logfunc=self.log) if self.transport_name == "serial": print "start serial" self.transport = jsonrpc.TransportSERIAL( port=self.serial_device, baudrate=self.serial_baudrate, logfunc=self.log) if self.transport_name == "mqtt": print "start mqtt" self.transport = jsonrpc.TransportMQTT(user=self.mqtt_user, password=self.mqtt_password, host=self.mqtt_host, logfunc=self.log) if self.transport is None: raise Exception("start transport", 1)
def __init__ (self, device=None, did=None,invitecode=None,\ pins=[None,None,None,None],pinsstate=["output",None,None,None],memdump=False): self.device = device if not self.device is None: lockdev(self.device) self.transport = jsonrpc.TransportSERIAL( port=device, baudrate=115200, logfunc=jsonrpc.log_file("myrpc.log")) self._mgr = jsonrpc.ServerProxy( jsonrpc.JsonRpc20(radio=False, notification=False), self.transport) self.ana = dict.fromkeys( ("onenet", "nid", "did", "invitecode", "region", "channel", "version", "invitecode", "status", "nsmkey", "smkey"), None) self.clients = [] self.events = Asyncevent() self.ana["did"] = did self.ana["invitecode"] = invitecode self.pins = pins self.pinsstate = pinsstate self._pinsstandingunit = None self._pinsstandingonoff = None self._mem = dict.fromkeys( ("master_param", "base_param", "client_list", "peer"), None) if device is None: return