_parseResponse(data, remote) {
        if (!(data[0] === 0x00 && data[1] === 0x00 && data[2] === 0x00 && data[3] === 0x03)) {
            debug(`Ignore data package because invalid prefix: ${data.toString('hex')}`);
            return;
        }
        const dataLength = data[4];

        if (data.length !== dataLength + 5) {
            debug(`Ignore data package because invalid length: ${data.toString('hex')}`);
            this.emit('error', `Ignore data package because invalid length`, data);
            return;
        }

        if (data[7] === 0x03) {
            return;
        }
        if (data[7] !== 0x04) {
            // there might be other packages being returned, ignore them
            debug(`Ignore data package because invalid message type ${data[7]}: ${data.toString('hex')}`);
            return;
        }

        debug('Parsing discovered device: ' + remote.address + ':' + remote.port + ' - ' + data.toString('hex'));

        let dataIdx = 9;
        const id = this._readDataField(data, dataIdx, true, true);
        dataIdx += id.length + 2;

        const data1 = this._readDataField(data, dataIdx, true, true);
        dataIdx += data1.length + 2;
        const data2 = this._readDataField(data, dataIdx, true, true);
        dataIdx += data2.length + 2;
        const data3 = this._readDataField(data, dataIdx, true, true);
        dataIdx += data3.length + 2;

        dataIdx += 7;

        const apiServer = this._readDataField(data, dataIdx, false, true);
        dataIdx += apiServer.length + 1;
        const version = this._readDataField(data, dataIdx, false, true);

        const result = {
            ip: remote.address,
            id: id.toString('ascii'),
            data1: data1.toString('hex'),
            data2: data2.toString('hex'),
            data3: data3.toString('ascii'),
            apiServer: apiServer.toString('ascii'),
            version: version.toString('ascii')
        };
        debug(`Discovered device: ${JSON.stringify(result)}`);

        /**
         * Device Event emitted when device was discovered
         *
         * @param {object} result Object with response data
         * @param {string} result.ip IP of the discovered device
         * @param {string} result.id Unique ID of the device - also used for MQTT messages to the Cloud server
         * @param {string} result.data1 Unknown Data packet 1 as hex String
         * @param {string} result.data2 Unknown Data packet 2 as hex String
         * @param {string} result.data3 Unknown Data packet 3 as hex String
         * @param {string} result.apiServer API server String
         * @param {string} result.version Version of the device Firmware (?)
         */
        this.emit('device', result);
    }
/**
     * Handle Discovery response messages
     *
     * @param {Buffer} data Received data
     * @param {Object} remote Information on remote client that responded
     * @private
     */
Handle Discovery response messages
@param {Buffer} data Received data
@param {Object} remote Information on remote client that responded
@private
Handle Discovery response messages @param { Buffer } data Received data @param { Object } remote Information on remote client that responded @private
_parseResponse(data, remote) {
        if (!(data[0] === 0x00 && data[1] === 0x00 && data[2] === 0x00 && data[3] === 0x03)) {
            debug(`Ignore data package because invalid prefix: ${data.toString('hex')}`);
            return;
        }
        const dataLength = data[4];
        if (data.length !== dataLength + 5) {
            debug(`Ignore data package because invalid length: ${data.toString('hex')}`);
            this.emit('error', `Ignore data package because invalid length`, data);
            return;
        }
        if (data[7] === 0x03) {
            return;
        }
        if (data[7] !== 0x04) {
            debug(`Ignore data package because invalid message type ${data[7]}: ${data.toString('hex')}`);
            return;
        }
        debug('Parsing discovered device: ' + remote.address + ':' + remote.port + ' - ' + data.toString('hex'));
        let dataIdx = 9;
        const id = this._readDataField(data, dataIdx, true, true);
        dataIdx += id.length + 2;
        const data1 = this._readDataField(data, dataIdx, true, true);
        dataIdx += data1.length + 2;
        const data2 = this._readDataField(data, dataIdx, true, true);
        dataIdx += data2.length + 2;
        const data3 = this._readDataField(data, dataIdx, true, true);
        dataIdx += data3.length + 2;
        dataIdx += 7;
        const apiServer = this._readDataField(data, dataIdx, false, true);
        dataIdx += apiServer.length + 1;
        const version = this._readDataField(data, dataIdx, false, true);
        const result = {
            ip: remote.address,
            id: id.toString('ascii'),
            data1: data1.toString('hex'),
            data2: data2.toString('hex'),
            data3: data3.toString('ascii'),
            apiServer: apiServer.toString('ascii'),
            version: version.toString('ascii')
        };
        debug(`Discovered device: ${JSON.stringify(result)}`);
        this.emit('device', result);
    }
_parseResponse ( data , remote ) { if ( ! ( data [ 0 ] === 0x00 && data [ 1 ] === 0x00 && data [ 2 ] === 0x00 && data [ 3 ] === 0x03 ) ) { debug ( ` ${ data . toString ( 'hex' ) } ` ) ; return ; } const dataLength = data [ 4 ] ; if ( data . length !== dataLength + 5 ) { debug ( ` ${ data . toString ( 'hex' ) } ` ) ; this . emit ( 'error' , ` ` , data ) ; return ; } if ( data [ 7 ] === 0x03 ) { return ; } if ( data [ 7 ] !== 0x04 ) { debug ( ` ${ data [ 7 ] } ${ data . toString ( 'hex' ) } ` ) ; return ; } debug ( 'Parsing discovered device: ' + remote . address + ':' + remote . port + ' - ' + data . toString ( 'hex' ) ) ; let dataIdx = 9 ; const id = this . _readDataField ( data , dataIdx , true , true ) ; dataIdx += id . length + 2 ; const data1 = this . _readDataField ( data , dataIdx , true , true ) ; dataIdx += data1 . length + 2 ; const data2 = this . _readDataField ( data , dataIdx , true , true ) ; dataIdx += data2 . length + 2 ; const data3 = this . _readDataField ( data , dataIdx , true , true ) ; dataIdx += data3 . length + 2 ; dataIdx += 7 ; const apiServer = this . _readDataField ( data , dataIdx , false , true ) ; dataIdx += apiServer . length + 1 ; const version = this . _readDataField ( data , dataIdx , false , true ) ; const result = { ip : remote . address , id : id . toString ( 'ascii' ) , data1 : data1 . toString ( 'hex' ) , data2 : data2 . toString ( 'hex' ) , data3 : data3 . toString ( 'ascii' ) , apiServer : apiServer . toString ( 'ascii' ) , version : version . toString ( 'ascii' ) } ; debug ( ` ${ JSON . stringify ( result ) } ` ) ; this . emit ( 'device' , result ) ; }
Handle Discovery response messages
 @param {Buffer} data Received data
 @param {Object} remote Information on remote client that responded
 @private
Handle Discovery response messages @param { Buffer } data Received data @param { Object } remote Information on remote client that responded @private
// there might be other packages being returned, ignore them /**
         * Device Event emitted when device was discovered
         *
         * @param {object} result Object with response data
         * @param {string} result.ip IP of the discovered device
         * @param {string} result.id Unique ID of the device - also used for MQTT messages to the Cloud server
         * @param {string} result.data1 Unknown Data packet 1 as hex String
         * @param {string} result.data2 Unknown Data packet 2 as hex String
         * @param {string} result.data3 Unknown Data packet 3 as hex String
         * @param {string} result.apiServer API server String
         * @param {string} result.version Version of the device Firmware (?)
         */