dante_device.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * SPDX-FileCopyrightText: 2026 Benjamin Harris
  3. * SPDX-License-Identifier: Apache-2.0
  4. *
  5. * Shared Dante device identity — clean-room, from docs/dante-protocol-notes.md.
  6. *
  7. * A Dante device is identified on the wire by a friendly hostname, an 8-byte
  8. * factory device id (real hardware uses its MAC padded to 8 bytes), a process
  9. * id (distinguishes multiple instances on one IP), and the set of UDP control
  10. * ports it listens on. The advertiser and the control-protocol servers all
  11. * work from one of these.
  12. */
  13. #pragma once
  14. #include <stdint.h>
  15. #include "esp_err.h"
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. #define DANTE_DEVICE_ID_LEN 8
  20. /* Standard Dante UDP control ports (as seen on hardware). */
  21. #define DANTE_PORT_ARC 4440 /* control / routing */
  22. #define DANTE_PORT_CMC 8800 /* device announce */
  23. #define DANTE_PORT_FLOWS 4455 /* flow setup (dbcp) */
  24. #define DANTE_PORT_INFO 8700 /* info / multicast */
  25. typedef struct {
  26. char hostname[64]; /* friendly hostname: DNS-SD instance + SRV target (single DNS label, no spaces) */
  27. uint8_t device_id[DANTE_DEVICE_ID_LEN]; /* factory device id (MAC padded with zeros) */
  28. uint16_t process_id; /* unique per instance on a given IP */
  29. uint32_t ipv4; /* device IPv4, host byte order */
  30. uint16_t arc_port;
  31. uint16_t cmc_port;
  32. uint16_t flows_port;
  33. uint16_t info_port;
  34. char manufacturer[32]; /* mDNS "mf" */
  35. char model[32]; /* mDNS "model" */
  36. char board_name[48]; /* mDNS "router_info" */
  37. uint32_t sample_rate; /* Hz */
  38. uint8_t bits_per_sample; /* 16 / 24 / 32 */
  39. } dante_identity_t;
  40. /*
  41. * Populate an identity with sensible Dante defaults:
  42. * - standard control ports,
  43. * - device_id = the 6 MAC bytes followed by two zero bytes,
  44. * - a hostname derived from the last three MAC bytes,
  45. * - manufacturer/model/board placeholders, 48 kHz / 24-bit.
  46. * The caller may override any field afterward (e.g. a nicer hostname).
  47. * `mac` is the 6-byte Ethernet MAC; `ipv4` is host byte order.
  48. */
  49. void dante_identity_init_default(dante_identity_t *id,
  50. uint32_t ipv4, const uint8_t mac[6]);
  51. #ifdef __cplusplus
  52. }
  53. #endif