def ble_state_change_callback()

in src/main.py [0:0]


    def ble_state_change_callback(self, ble_mac, current_state, previous_state):

        try:
            # If transitioning to a conected state, subscribe to the BLE devices TX IPC / MQTT topic.
            # if this connection has bounced, the subscribe function will gracefully ignore duplicate subscriptions.
            if self.ble_controller.is_peripheral_connected(ble_mac):
                log.info('BLE MAc: {} State Change to connected, subscribing to TX Topics.'.format(ble_mac))
                ble_tx_topic = '{}/{}'.format(self.pubsub_data_tx_topic, ble_mac)
                self.ipc_topic_pubsub.subscribe_to_topic(ble_tx_topic)
                self.mqtt_core_pubsub.subscribe_to_topic(ble_tx_topic)

            status_update = {
                "control-command" : "ble-conection-state-changed",
                "ble-mac" : ble_mac, 
                "updated" : datetime.now().strftime("%Y%m%d%H%M%S%f"),
                "data" : { 
                    "previous-state" : previous_state,
                    "current_state" : current_state,
                }
            }

            self.publish_message('ipc', status_update, topic=self.pubsub_ble_state_topic)
            self.publish_message('mqtt', status_update, topic=self.pubsub_ble_state_topic)

        except Exception as err:
            msg = 'BLE Mac: {} State Change ERROR: {}'.format(ble_mac, err)
            log.error(msg)
            self.publish_error(500, msg)