Skip to content

Conversation

@julianlotzer
Copy link

Description

This PR introduces a new command-line argument, --use-lighthouses, which allows specifying a comma-separated list of BaseStationIDs (hex) to use for tracking. Lighthouses whose IDs are not in this list will be disabled. Not using this argument will make the code work as usual and discover and optimize with all available lighthouses. The main reason to use this flag is if you have multiple lighthouse setups in the same room and you only want to use a specific set of lighthouses.

This change also fixes bugs in the lighthouse initialization and discovery logic so that the whitelist is respected even when lighthouses are discovered at runtime (e.g., when config.json is empty).

Technical Changes

1. survive.c - Configuration and Initialization

  • A new STATIC_CONFIG_ITEM for use-lighthouses is added to register the command-line argument.
  • In survive_init_internal:
    • The use-lighthouses config is read before iterating through lighthouse slots.
    • If the whitelist is active, any lighthouse slot without a config (has_config == false) is pre-emptively disabled (disable = 1).
    • If a lighthouse is found in the config, its BaseStationID is checked against the whitelist. If it does not match, it is disabled.
  • In survive_get_bsd_idx:
    • The BaseStationData struct is no longer fully reset when a new channel is assigned to an empty slot.
    • This change is necessary to preserve the disable = 1 flag set during survive_init_internal. Previously, this flag was cleared upon discovery.

2. survive_process_gen2.c - Runtime Discovery

  • In survive_default_sync_process:
    • The call to survive_ootx_behavior is moved to run before the if (so->ctx->bsd[bsd_idx].disable) check.
    • This allows disabled lighthouses (like those disabled during init) to still have their OOTX data processed for identification. The function still returns early to prevent them from being used in tracking.
  • In ootx_packet_clbk_d_gen2:
    • When an OOTX packet is successfully decoded, the BaseStationID is checked against the use-lighthouses whitelist.
    • If the ID is on the list, the lighthouse is explicitly enabled (b->disable = 0).
    • If the ID is not on the list, the lighthouse is disabled (b->disable = 1).

Summary of Behavior

With these changes, if --use-lighthouses is active:

  1. At Init: All lighthouses are disabled by default, unless they are in config.json and on the whitelist.
  2. At Runtime: Disabled lighthouses continue to process OOTX data.
  3. On OOTX Decode: A lighthouse is only enabled if its newly-discovered ID is on the whitelist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant