Skip to content

When there are multiple sensors of a given type, how do we identify which one to instantiate? #26

@tobie

Description

@tobie

In #8 we agreed that sensors shouldn't be singletons because it was both useful to allow multiple instances of each sensor and necessary to support multiple sensor of a given type on a single device (think for example proximity sensors on a car).

Imagine we want to check the presence of an object on the back of a car, we'll need to get data from one of the back sensors, right?

Should we go with a generic system, taking a DOMString, that would be defined in this spec, so for example:

new Sensor.Proximity({ identifier: "back-right" });
new Sensor.Temperature({ identifier: "internal" });

…or should we let specs for concrete sensors implement that the way they want? So we might get something like (trading off consistency for context):

new Sensor.Proximity({ position: "back-right" });
new Sensor.Temperature({ id: "internal" });

Questions:

  • Is such an identifier the right solution?
  • Should we favor consistency or context?
  • What happens when no identifier is passed to the constructor? Must there be a default sensor for each type so that you can do: new Sensor.Geoloc() and not new Sensor.Geoloc({ identifier: "default" })?
  • Where are those lists of sensors defined? In the concrete specs themselves? Through an API the consumer can query (e.g. Sensor.Proximity.getAll())?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions