# Path: thingsboard_gateway/connectors/socket/socket_uplink_converter.py
# class SocketUplinkConverter(Converter):
#     def convert(self, config, data):


from thingsboard_gateway.connectors.socket.socket_uplink_converter import SocketUplinkConverter, log
            "deviceName": config['deviceName'],
            "deviceType": config['deviceType']
        }

    def convert(self, config, data):
        if data is None:
            return {}

        try:
            self.dict_result["telemetry"] = []
            self.dict_result["attributes"] = []

            for section in ('telemetry', 'attributes'):
                for item in config[section]:
                    try:
                        byte_from = item.get('byteFrom')
                        byte_to = item.get('byteTo')

                        byte_to = byte_to if byte_to != -1 else len(data)
                        converted_data = data[byte_from:byte_to]

                        try:
                            converted_data = converted_data.replace(b"\x00", b'').decode(config['encoding'])
                        except UnicodeDecodeError:
                            converted_data = str(converted_data)

                        if item.get('key') is not None:
                            self.dict_result[section].append(
                                {item['key']: converted_data})
                        else:

# Path: thingsboard_gateway/connectors/socket/socket_uplink_converter.py
# class SocketUplinkConverter(Converter):
#     def convert(self, config, data):


# Path: thingsboard_gateway/connectors/socket/bytes_socket_uplink_converter.py
from thingsboard_gateway.connectors.socket.socket_uplink_converter import SocketUplinkConverter, log

            "deviceName": config['deviceName'],
            "deviceType": config['deviceType']
        }

    def convert(self, config, data):
        if data is None:
            return {}

        try:
            self.dict_result["telemetry"] = []
            self.dict_result["attributes"] = []

            for section in ('telemetry', 'attributes'):
                for item in config[section]:
                    try:
                        byte_from = item.get('byteFrom')
                        byte_to = item.get('byteTo')

                        byte_to = byte_to if byte_to != -1 else len(data)
                        converted_data = data[byte_from:byte_to]

                        try:
                            converted_data = converted_data.replace(b"\x00", b'').decode(config['encoding'])
                        except UnicodeDecodeError:
                            converted_data = str(converted_data)

                        if item.get('key') is not None:
                            self.dict_result[section].append(
                                {item['key']: converted_data})
                        else:

                            log.error('Key for %s not found in config: %s', config['type'], config['section_config'])