from json_commander import jtester from adv_parser import AdvParser if __name__ == "__main__": log_wrapper.setup(__file__, console_level=logging.DEBUG) isBle = True jc = JsonConfig(isBle, "config.json") ser = serial.Serial(jc.get_port(), baudrate=jc.get_baudrate(), timeout=1, rtscts=True) with serial.threaded.ReaderThread(ser, BL65x) as bt_module: jt = jtester() jt.set_protocol(bt_module) bt_module.secondary_initialization() name_to_look_for = jc.get("name_to_look_for") number_of_devices_to_look_for = jc.get("number_of_devices_to_look_for") bt_module.scan(nameMatch=name_to_look_for) configured_devices = dict() while number_of_devices_to_look_for > 0: ad = bt_module.get_scan(timeout=None) ap = None try: junk, address, rssi, ad_rsp = ad.split(' ') logging.debug(f"{address} {rssi} {ad_rsp}") ap = AdvParser(ad_rsp.strip('"')) except: logging.debug("unable to process advertisement") if ap is not None: if ap.adv_valid:
import boto3 NAMESPACE = "Client/Application" if __name__ == "__main__": log_wrapper.setup(__file__, console_level=logging.INFO, file_mode='a') isBle = True jc = JsonConfig(isBle) ser = serial.Serial(jc.get_port(), baudrate=jc.get_baudrate(), timeout=1, rtscts=True) with serial.threaded.ReaderThread(ser, BL65x) as bt_module: cloudwatch = boto3.client('cloudwatch') jt = jtester() jt.set_protocol(bt_module) bt_module.secondary_initialization() name_to_look_for = jc.get("system_name_to_look_for") bt_module.scan(nameMatch=name_to_look_for) event_dict = dict() while True: ad = bt_module.get_scan(timeout=None) ap = None try: junk, address, rssi, ad_rsp = ad.split(' ') logging.debug(f"{address} {rssi} {ad_rsp}") except: logging.info("unable to split advertisement") try: ap = AdvParser(ad_rsp.strip('"')) except: logging.info("unable to parse")
s += '\n' return s if __name__ == "__main__": log_wrapper.setup(__file__, console_level=logging.INFO) isBle = True jc = JsonConfig(isBle, "config.json") ser = serial.Serial(jc.get_port(), baudrate=jc.get_baudrate(), timeout=1, rtscts=True) with serial.threaded.ReaderThread(ser, BL65x) as bt_module: jt = jtester() jt.set_protocol(bt_module) bt_module.secondary_initialization() name_to_look_for = jc.get("system_name_to_look_for") ofile = "logs/" + name_to_look_for + ".system_report.log" append_report(ofile, COLUMN_LIST) bt_module.scan(nameMatch=name_to_look_for) device_list = list() stop_time = time.time() + jc.get("system_report_scan_duration_seconds") while time.time() < stop_time: ad = bt_module.get_scan(timeout=None) ap = None try: junk, address, rssi, ad_rsp = ad.split(' ') logging.debug(f"{address} {rssi} {ad_rsp}") ap = AdvParser(ad_rsp.strip('"')) except: logging.debug("unable to process advertisement")