Koenkk / zigbee-herdsman

A Node.js Zigbee library
MIT License
482 stars 300 forks source link

feat!: Improved adapter discovery. #1197

Closed Nerivec closed 1 month ago

Nerivec commented 2 months ago

TODO:

Nerivec commented 2 months ago

@kirovilya Can you provide a fingerprint for the nordic adapter? I'll clean up the matching/tests with it.

import {SerialPort} from 'zigbee-herdsman/dist/adapter/serialPort.js';

const list = await SerialPort.list();

console.log(list);
kirovilya commented 2 months ago

@kirovilya Can you provide a fingerprint for the nordic adapter? I'll clean up the matching/tests with it.

for this? https://github.com/Koenkk/zigbee-herdsman/blob/master/src/adapter/zboss/adapter/zbossAdapter.ts#L24

Nerivec commented 2 months ago

Whatever comes out of the bit of code I mentioned above should have it all; mostly the path. This PR improves upon the discovery a bit, more refined using regex matching against the paths.

See the adapterDiscovery.ts file in the PR, in case you can provide more missing fingerprints 😉

kirovilya commented 2 months ago

Whatever comes out of the bit of code I mentioned above should have it all; mostly the path. This PR improves upon the discovery a bit, more refined using regex matching against the paths.

See the adapterDiscovery.ts file in the PR, in case you can provide more missing fingerprints 😉

{
    manufacturer: 'ZEPHYR',
    serialNumber: '54ACCFAFA6DADC49',
    pnpId: 'usb-ZEPHYR_Zigbee_NCP_54ACCFAFA6DADC49-if00',
    locationId: undefined,
    vendorId: '2fe3',
    productId: '0100',
    path: '/dev/ttyACM0'
  },

and in windows


    {
    path: 'COM22',
    manufacturer: 'Корпорация Майкрософт',
    serialNumber: '6&11E6BDCD&1&0000',
    pnpId: 'USB\\VID_2FE3&PID_0100&MI_00\\6&11E6BDCD&1&0000',
    locationId: '0000.0014.0000.009.000.000.000.000.000',
    friendlyName: 'Устройство с последовательным интерфейсом USB (COM22)',
    vendorId: '2FE3',
    productId: '0100'
  },
kirovilya commented 2 months ago

there is also a proposal to extract the serial port from the adapters and transfer the ready-made connection inside. connection and reconnection control can also be performed outside the adapter

Nerivec commented 2 months ago

It would require adding more variables to Adapter that can be overridden in subclasses to have the proper settings for serial/socket ports (hw/sw, stop bits, parity, watermark, etc.) since these can vary. Parser/writer would have to stay in adapters too, since these are very different in most cases (or would require an even bigger refactoring). Probably wouldn't be bad to have just the writer instance and a parser callback function passed to adapters, but at first glance, it's a pretty large refactor.

Koenkk commented 1 month ago

Could you target this against the feat/3.0.0 branch? Then this can be merged.