Skip to content

trackerNum should not exists inside the protocol #100

@loucass003

Description

@loucass003

currently the tracker id holds the device id and the tracker num. like so

table TrackerId {
    /// The device the tracker is associated with. If there is no hardware device it is
    /// associated with, this should be `null`.
    device_id: solarxr_protocol.datatypes.DeviceId;
    /// There are possibly multiple trackers per device. This identifies which one.
    tracker_num: uint8;
}

but the issue with this is that you need to know the device id to change anything with the tracker. In many instance in the server code you have to do a lot of checks to make sure you are getting the right tracker.

also 99% of the time you are not changing settings to a device but to the tracker. So working with the device as the id is not that necessary.
And when you are mutating a device you will only send the device id anyway, no need to send a trackerNum.

here in the server code a function to get the tracker from its tracker id

	public Tracker getTrackerById(TrackerIdT id) {
		for (Tracker tracker : trackers) {
			if (tracker.getTrackerNum() != id.getTrackerNum()) {
				continue;
			}

			// Handle synthetic devices
			if (id.getDeviceId() == null && tracker.getDevice() == null) {
				return tracker;
			}

			if (
				tracker.getDevice() != null
					&& id.getDeviceId() != null
					&& id.getDeviceId().getId() == tracker.getDevice().getId()
			) {
				// This is a physical tracker, and both device id and the
				// tracker num match
				return tracker;
			}
		}
		return null;
	}

the protocol should hold unique ids for the device and the tracker.
lets see what a rewrite would look like

table TrackerId {
    id: uint8;
}


table TrackerData {
    tracker_id: solarxr_protocol.datatypes.TrackerId;
   // i removed everything below for convenience because it does not add any value to that topic
}

struct DeviceId {
    id: uint8;
}

table DeviceData {
    id: solarxr_protocol.datatypes.DeviceId;
    // i removed everything below for convenience because it does not add any value to that topic
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: Application ProtocolRelated to communication with apps like the GUI, overlay, gamesType: DiscussionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions