예제 #1
0
 def set_advValues(self, addr , sBuff ):
 	clsConst=appConst.appConstClass()
 	sV1=""
 	sV2=""
 	sV3=""
 	sV4=""
 	sV5=""
 	#for j in range(3 ,8 ):
 	for j in range(0 ,5 ):
 		sV1 += sBuff[j]
 	for j1 in range(5 ,10 ):
 		sV2 += sBuff[j1 ]
 	if (len(sBuff) >= clsConst.mMax_GapLength_25 ):
 		for j2 in range(10 ,15 ):
 			sV3 += sBuff[j2 ]
 		for j3 in range(15 ,20 ):
 			sV4 += sBuff[j3 ]
 		for j4 in range(20 , 25 ):
 			sV5 += sBuff[j4 ]
 		
 	for i in range(0 ,mMaxdevice  ):
 		if(mBleDat[i ]["pubAddr"]==addr ):
 			mBleDat[i ]["val_1"]=sV1
 			mBleDat[i ]["val_2"]=sV2
 			mBleDat[i ]["val_3"]=sV3
 			mBleDat[i ]["val_4"]=sV4
 			mBleDat[i ]["val_5"]=sV5
예제 #2
0
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
예제 #3
0
    def Is_validActive(self, iNum):
        ret = 0
        clsConst = appConst.appConstClass()
        if clsConst.mActStart <= iNum:
            if clsConst.mActEnd > iNum:
                ret = 1
#return ret
#return ret
#ret=1
        return ret
예제 #4
0
def init_param(clsDat ):
	clsConst=appConst.appConstClass()
	cls= config.configClass()
	clsDat.init_proc()
	cls.load_config(clsConst.mDeviceFile )
#	clsDat.set_addr(0,  mPubAddr01)
#	clsDat.set_addr(1,  mPubAddr02)
#	clsDat.set_addr(2,  mPubAddr03)
	
	clsDat.debug_printDat()
예제 #5
0
 def convert_hexToString(self, sHex):
     sRet = ""
     clsConst = appConst.appConstClass()
     #		sRead="44313330313031303130313031303130313031303130313031"
     #sOut=""
     for i in range(0, clsConst.mMax_GapLength_25):
         iPos = i * 2
         sBuff = "0x" + sHex[iPos] + sHex[iPos + 1]
         #print("i="+str(i)  +" ,"+ sBuff)
         iBuff = int(sBuff, 16)
         cNum = chr(iBuff)
         # print(str(iBuff))
         #print(cNum)
         sRet += str(cNum)
     print(sRet)
     return sRet
예제 #6
0
    def set_advValues(self, name, sBuff):
        clsConst = appConst.appConstClass()
        sV1 = ""
        sV2 = ""
        sV3 = ""
        sV4 = ""
        for j in range(3, 8):
            sV1 += sBuff[j]
        for j1 in range(8, 13):
            sV2 += sBuff[j1]
        if (len(sBuff) >= clsConst.mMax_GapLength_25):
            for j2 in range(13, 18):
                sV3 += sBuff[j2]
            for j3 in range(18, 23):
                sV4 += sBuff[j3]

        for i in range(0, mMaxdevice):
            if (mBleDat[i]["adv_name"] == name):
                mBleDat[i]["val_1"] = sV1
                mBleDat[i]["val_2"] = sV2
                mBleDat[i]["val_3"] = sV3
                mBleDat[i]["val_4"] = sV4
예제 #7
0
    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():
                #if(desc==  clsConst.mDesc_Localname ):