def sendShiftQRCode(idTimes,date): cursor = conn.execute(("select u.name, s.id, u.master_key, s.time_id, t.start, s.room_id, s.date from users as u, times as t, shifts as s where t.id=s.time_id AND u.id=s.user_id AND s.time_id=%s AND s.date="+"'"+"%s"+"'")%(idTimes,date)) for e in cursor: print("+++++++++++++++++++++++++++++++++++++++++") strQuery = str("{} # {} # {} # {} # {} # {} # {}".format(e[0],e[1],e[2],e[3],e[4],e[5],e[6])) print(strQuery) shiftId = str(e[1]) masterKeyUser = str(e[2]) room = str(e[5]) qrCodeData=md.enkrip(shiftId,masterKeyUser) md.dekrip(qrCodeData,shiftId,masterKeyUser) print(qrCodeData) topic='qrcode/'+room print("kirim ke "+topic) ##!kirim ke stiap node sesuai room_id mqtt.publishData(topic,qrCodeData) print("+++++++++++++++++++++++++++++++++++++++++") time.sleep(1)
## !kirim ke MQTT ## #mqtt.client.publish("tessatpam",strencode) mqtt.client.publish("ruang1", strencode) mqtt.client.publish("ruang2", strencode) mqtt.client.publish("ruang3", strencode) ## ! delay 2 detik ## time.sleep(2) # print(func1,func2) workstart() ## !contoh pengujian pada system ## print("\n\n\nkemudian dilakukan scan barcode pada data terakhir \n\n\n") print("==============contoh testing gagal================") modulderive.dekrip( b'S\x92^\x99Z\xc8\xb3\xece\xa4\x9fy\x05\x98\xc9\x18\xb9\xa2S\xb2\xf4\xa8Gf\xec{\x87\xc5Q\xd1\xb0g', value) print("==================================================\n") print("\n============contoh testing berhasil==============") modulderive.dekrip( b'&\xa9\xddL\xaf\x19\x8f\xc6\xdc\xf8.\x8a\xf4\x876\xe1X\xe2\x83\x19l\x86\x1c\x8af\x0b\x10\xeb\xd8\x9d\xe8\x8e', value) print("==================================================") print("Operation done successfully") conn.close() ###! query tabel times atribut start cek jam pada date and time. ###! apabila jam nya ada yang sama maka query yang mengacu pada id di table times ke table shift kemudian lemparkan lagi room id. ###! pada room id punya topik subscribe sendiri kemudian query pada user ambil informasi sesuai yang akan di derive kan master keynya.