macchina-io / macchina.io

macchina.io EDGE is a powerful C++ and JavaScript SDK for edge devices, multi-service IoT gateways and connected embedded systems.
https://macchina.io
GNU General Public License v3.0
516 stars 154 forks source link

Service Registry question #51

Closed Sultan91 closed 7 years ago

Sultan91 commented 7 years ago

Can someone clarify how ' serviceRegistry.find( 'io.macchina.physicalQuantity == "temperature"');' locates the sensor I've currently connected? Do we need explicitly specify Pin Port number, beacuse I've tried connect a temperature sensor but temperature value keep going from simulated one?

obiltschnig commented 7 years ago

Just connecting a temperature sensor is not enough. You'll also need to create and register a service (basically, implement a subclass of IoT::Devices::Sensor) that retrieves the temperature from the sensor. Examples for various Sensor implementations can be found in the devices/Tf, devices/SensorTag and devices/Simulation directories. Every sensor implementation usually adds its own service properties, which you can also use in serviceRegistry.find(). Example:

var sensorRefs = serviceRegistry.find(
    'io.macchina.physicalQuantity == "temperature" && io.macchina.device == "io.macchina.btle.sensortag");

will only find SensorTag temperature sensors.

Now, if you have a temperature sensor connected to an analog input pin, you'll need to write your own Sensor implementation that reads the value from the ADC and also does the necessary scaling and calibration in order to derive an accurate temperature value from the raw ADC value. If you have more of those sensors, having the pin number available as a service property will allow you to search for a specific sensor.

Depending on what kind of sensor you want to connect, libraries like mraa and upm can be a great help.

SH2222 commented 6 years ago

How can i get data using serviceUUID and characteristicUUID