Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Improved adapter discovery. #1197

Merged
merged 13 commits into from
Oct 11, 2024
Merged

Conversation

Nerivec
Copy link
Collaborator

@Nerivec Nerivec commented Sep 22, 2024

TODO:

  • Update Adapter.create (should remove most of the logic)
  • Remove adapter.autoDetectPath, adapter.isValidPath and definitions in all drivers
  • Complete fingerprints. Closes feat: add auto-detection of CC2652P #1071

@Nerivec
Copy link
Collaborator Author

Nerivec commented Sep 23, 2024

@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
Copy link
Contributor

@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
Copy link
Collaborator Author

Nerivec commented Sep 23, 2024

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Collaborator Author

Nerivec commented Sep 24, 2024

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.

@Nerivec Nerivec force-pushed the adapter-discovery branch 2 times, most recently from d8bf2b7 to c16b7f1 Compare September 25, 2024 18:50
@Koenkk
Copy link
Owner

Koenkk commented Oct 10, 2024

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

@Nerivec Nerivec changed the base branch from master to feat/3.0.0 October 10, 2024 16:32
@Nerivec Nerivec marked this pull request as ready for review October 10, 2024 16:36
@Koenkk Koenkk merged commit 09464fe into Koenkk:feat/3.0.0 Oct 11, 2024
1 check passed
@Nerivec Nerivec deleted the adapter-discovery branch October 11, 2024 20:11
Koenkk added a commit that referenced this pull request Dec 1, 2024
* feat: Improved adapter discovery.

* Fix.

* Update + tests.

* Add alt regex matching on `pnpId`.

* Feedback.

* Lower log level on specified config matching fail.

* Improve matching logic to avoid false positive.

* Restrict search by config as much as possible. Reorganize tests, add more coverage. Cleanup.

* More fingerprints

* Add fingerprint for SMLight slzb-07mg24

* Add additional fingerprints + tests

* Better matching with scoring.

* Remove `auto` from Adapter type.

---------

Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants