in esp32-ble-device/main.py [0:0]
def __init__(self, device_name):
'''
Initialises this ESP32 BLE Device
'''
try:
#######################################################
# Log the start of the process
print('Initialising ESP32 uProcessor BLE Device')
super().__init__()
# Descriptive name for this assembly
self.device_name = device_name
# Set the LED Pin
self.pin_led = Pin(2, Pin.OUT)
# Init the BleUartPeripheral
self.ble_peripheral = BleUartPeripheral()
self.ble_peripheral.irq(handler=self.ble_message_callback)
except ValueError as val_error: # includes JSON parsing errors
err_msg = 'VAL_ERROR: Initialising ESP32 BLE Device. JSON Parsing Error / Unexpected message format. ERROR MESSAGE: {}'.format(val_error)
self.publish_exception(500, err_msg)
except KeyError as key_error: # includes requests for fields that don't exist in the received config
err_msg = 'KEY_ERROR: Initialising ESP32 BLE Device. Missing required fields. ERROR MESSAGE: {}'.format(key_error)
self.publish_exception(500, err_msg)
except Exception as err:
err_msg = 'EXCEPTION: Exception initialising ESP32 BLE Device. ERROR MESSAGE: {}'.format(err)
self.publish_exception(500, err_msg)
finally:
gc.collect()