def send_http(clsDat): clsDat= datModel.datModelClass() if( clsDat.recvCount() ==0): print("# Nothing, data") return #else: #debug clsDat.debug_printDat() print("# http-start") sReq="" sV1=clsDat.get_datByName("device1" , 1) if (len(sV1 ) > 0 ): sReq +="&field1=" + str(sV1) sV2=clsDat.get_datByName("device2" , 1) if (len(sV2 ) > 0 ): sReq +="&field2=" + str(sV2) sV2b=clsDat.get_datByName("device2" , 2 ) if (len(sV2b ) > 0 ): sReq +="&field3=" + str(sV2b ) sV3=clsDat.get_datByName("device3" , 1 ) if (len(sV3 ) > 0 ): sReq +="&field4=" + str(sV3 ) sV4=clsDat.get_datByName("device4" , 1 ) if (len(sV4 ) > 0 ): sReq +="&field5=" + str(sV4 ) th=threading.Thread(target=execute_httpSend ,args=(sReq, ) ) th.start()
def load_config(self, fname): clsDat = datModel.datModelClass() sDir = os.path.dirname(os.path.abspath(__file__)) sPath = sDir + "/" + fname print("sPath=" + sPath) file = open(sPath, 'r') json_dict = json.load(file) iCt = 0 for item in json_dict: # print (item) print json_dict[item] # clsDat.set_addr(iCt, json_dict[item ] ) clsDat.set_device(iCt, json_dict[item], item) iCt = iCt + 1
def send_http(clsDat): clsDat = datModel.datModelClass() #cHttp = http_func.http_funcClass() if (clsDat.recvCount() == 0): print("# Nothing, data") return #else: print("# http-start") #debug clsDat.debug_printDat() sReq = "" sV1 = clsDat.get_datByAdvname(mAdv_name11, 1) if (len(sV1) > 0): sReq += "&field3=" + str(sV1) sV2 = clsDat.get_datByAdvname(mAdv_name12, 1) if (len(sV2) > 0): sReq += "&field4=" + str(sV2) sV3 = clsDat.get_datByAdvname(mAdv_name13, 1) if (len(sV3) > 0): sReq += "&field5=" + str(sV3) th = threading.Thread(target=execute_httpSend, args=(sReq, )) th.start()
th = threading.Thread(target=execute_httpSend, args=(sReq, )) th.start() def Is_valid_desc(desc): ret = mNG_CODE clsConst = appConst.appConstClass() if (desc == clsConst.mDesc_Localname): ret = mOK_CODE if (desc == clsConst.mDesc_mafact): ret = mOK_CODE return ret if __name__ == "__main__": clsDat = datModel.datModelClass() clsConst = appConst.appConstClass() init_param(clsDat) scanner = Scanner().withDelegate(ScanDelegate()) from datetime import datetime tmBef = datetime.now() while True: tmNow = datetime.now() tmSpan = tmNow - tmBef iSpan = tmSpan.total_seconds() sTime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") print("time=" + sTime) # BLE devices = scanner.scan(2.0) for dev in devices: for (adtype, desc, value) in dev.getScanData():