def fromJsondict(self, dictjson): # Note: if the json dictionary isn't correct, this will naturally throw an exception that may # need to be caught for error detection self.macAddr = dictjson['macAddr'] self.ssid = dictjson['ssid'] self.mode = dictjson['mode'] self.security = dictjson['security'] self.privacy = dictjson['privacy'] self.cipher = dictjson['cipher'] self.frequency = int(dictjson['frequency']) self.channel = int(dictjson['channel']) self.secondaryChannel = int(dictjson['secondaryChannel']) self.secondaryChannelLocation = dictjson['secondaryChannelLocation'] self.thirdChannel = int(dictjson['thirdChannel']) self.signal = int(dictjson['signal']) self.stationcount = int(dictjson['stationcount']) self.utilization = float(dictjson['utilization']) self.strongestsignal = int(dictjson['strongestsignal']) self.bandwidth = int(dictjson['bandwidth']) self.firstSeen = parser.parse(dictjson['firstseen']) self.lastSeen = parser.parse(dictjson['lastseen']) self.gps.latitude = float(dictjson['lat']) self.gps.longitude = float(dictjson['lon']) self.gps.altitude = float(dictjson['alt']) self.gps.speed = float(dictjson['speed']) self.gps.isValid = stringtobool(dictjson['gpsvalid']) self.strongestgps.latitude = float(dictjson['strongestlat']) self.strongestgps.longitude = float(dictjson['strongestlon']) self.strongestgps.altitude = float(dictjson['strongestalt']) self.strongestgps.speed = float(dictjson['strongestspeed']) self.strongestgps.isValid = stringtobool(dictjson['strongestgpsvalid'])
def fromJsondict(self, dictjson): # Note: if the json dictionary isn't correct, this will naturally throw an exception that may # need to be caught for error detection self.uuid = dictjson['uuid'] self.macAddress = dictjson['macAddr'] self.name = dictjson['name'] self.company = dictjson['company'] self.manufacturer = dictjson['manufacturer'] self.bluetoothDescription = dictjson['bluetoothdescription'] self.btType = int(dictjson['bttype']) self.rssi = int(dictjson['rssi']) self.txPower = int(dictjson['txpower']) self.txPowerValid = stringtobool(dictjson['txpowervalid']) self.strongestRssi = int(dictjson['strongestrssi']) self.iBeaconRange = float(dictjson['ibeaconrange']) self.firstSeen = parser.parse(dictjson['firstseen']) self.lastSeen = parser.parse(dictjson['lastseen']) self.gps.latitude = float(dictjson['lat']) self.gps.longitude = float(dictjson['lon']) self.gps.altitude = float(dictjson['alt']) self.gps.speed = float(dictjson['speed']) self.gps.isValid = stringtobool(dictjson['gpsvalid']) self.strongestgps.latitude = float(dictjson['strongestlat']) self.strongestgps.longitude = float(dictjson['strongestlon']) self.strongestgps.altitude = float(dictjson['strongestalt']) self.strongestgps.speed = float(dictjson['strongestspeed']) self.strongestgps.isValid = stringtobool(dictjson['strongestgpsvalid'])
def fromJsondict(self, dictjson): # Note: if the json dictionary isn't correct, this will naturally throw an exception that may # need to be caught for error detection self.macAddr = dictjson['macAddr'] self.apMacAddr = dictjson['apMacAddr'] self.ssid = dictjson['ssid'] self.channel = int(dictjson['channel']) self.signal = int(dictjson['signal']) self.strongestsignal = int(dictjson['strongestsignal']) self.firstSeen = parser.parse(dictjson['firstseen']) self.lastSeen = parser.parse(dictjson['lastseen']) self.gps.latitude = float(dictjson['lat']) self.gps.longitude = float(dictjson['lon']) self.gps.altitude = float(dictjson['alt']) self.gps.speed = float(dictjson['speed']) self.gps.isValid = stringtobool(dictjson['gpsvalid']) self.strongestgps.latitude = float(dictjson['strongestlat']) self.strongestgps.longitude = float(dictjson['strongestlon']) self.strongestgps.altitude = float(dictjson['strongestalt']) self.strongestgps.speed = float(dictjson['strongestspeed']) self.strongestgps.isValid = stringtobool(dictjson['strongestgpsvalid']) self.probedSSIDs = dictjson['probedssids']
def requestRemoteGPS(remoteIP, remotePort): url = "http://" + remoteIP + ":" + str(remotePort) + "/gps/status" statusCode, responsestr = makeGetRequest(url) if statusCode == 200: try: gpsjson = json.loads(responsestr) gpsStatus = GPSStatus() gpsStatus.gpsInstalled = stringtobool(gpsjson['gpsinstalled']) gpsStatus.gpsRunning = stringtobool(gpsjson['gpsrunning']) gpsStatus.isValid = stringtobool(gpsjson['gpssynch']) if gpsStatus.isValid: # These won't be there if it's not synchronized gpsStatus.latitude = float(gpsjson['gpspos']['latitude']) gpsStatus.longitude = float(gpsjson['gpspos']['longitude']) gpsStatus.altitude = float(gpsjson['gpspos']['altitude']) gpsStatus.speed = float(gpsjson['gpspos']['speed']) return 0, "", gpsStatus except: return -2, "Error parsing remote agent response", None else: return -1, "Error connecting to remote agent", None