## 6 Analysis and Results
### Libellium Connector: Implementation and Observations
#### 6.2.1 ASCII Encoding  
The Waspmote sensor transmits its value with a payload containing the hexadecimal string shown in Listing 13, forwarding it to the connector following the path shown in Figure 7.  
Upon receiving the payload, the first operation the connector performs is checking the frame encoding. The byte carrying information about the frame (0x80) has the most significant bit set to 1, so the connector will interpret the frame as the ASCII string shown in Listing 14. ```
<->0x80x0x0>#35690284#NODE01214#TCA:35#GPS:31.200;42.100#BAT:87

Figure 7: Architecture for testing the Waspmote Libellium device and the corresponding connector. The second operation performed by the connector is to identify the sensor within the system. To do this, it reads the frame field containing the unique device ID, in this case, 35690284, consults its internal database, and retrieves the ID of the associated THING entity present on the server, as shown in Listing 15. Finally, proceed to the analysis of the information contained in the payload. ```
{ Name:\"Waspnote001\", Description:\"SensorWaspnote1\", }
```
Listing 15: Waspnote Libellium THING extraction. \(\blacksquare\)**TCA:35**: This field corresponds to a temperature measurement. The Libellium connector searches among the DATASTREAMs associated with the Waspnote sensor for the one corresponding to temperature; if not found, it creates a new one (Listing 16). Once the DATASTREAM is identified, it creates an OBSERVATION entity to link to it, containing the measurement, as shown in Listing 17. ```
{ name:\"TemperatureCelsius\", description:\"Temperature\", unitOfMeasurement: { name:\"Celsius\", symbol:\"C\", }, observationType:\"OM_Measurement\", resultTime:2024-11-03T13:00:00Z/2024-11-03T13:00:00Z\" }
```
Listing 16: Libellium temperature DATASTREAM. \(\blacksquare\)**GPS:45.354;11.884**: In this case, the measurement corresponds to the GPS position of the device. The first value corresponds to latitude, while the second value corresponds to longitude. The connector creates a new LOCATION entity to be associated with the THING entity of the sensor, as shown in Listing 18. ```
{ encodingType:\"application/vnd.geo+json\", location:{ type:Feature, geometry:! type:\"Point\", coordinates:[45.354,11.884] } }
```
Listing 18: Association of Libellium LOCATION. \(\blacksquare\)**BAT:87**: The device communicates the remaining battery percentage, and the connector handles this measurement like any other produced by the sensor (Listing 19). Consequently, it searches for the associated DATASTREAM and, if it does not find one, creates a new one. Subsequently, it creates the corresponding OBSERVATION entity. ```
{  name: \"Battery\", description: \"Battery in Libellium device\", unifOfMeasurement: {  name: \"Percentuale\", symbol: \"%\", definition:... }, observationType: \"OM_Observation\", resultTime: \"2024-11-03T13:00:00Z/2020-11-03T13: 00:00Z\"  result: 87 }
```
Listing 19: DATASTREAM and OBSERVATION of battery in Libellium device. #### 6.2.2 Binary Encoding

Similarly to previous cases, the sensor transmits the following payload to the connector: \"3C3D3E 00 03 74F94515 53 2624 180000 DA41 0 FD7A3 CA42\". The second field of the payload (0x00) contains only zeros, so the connector will interpret the frame as binary, while the fourth field contains the unique device ID, which is used to retrieve the associated THING entity from the database with an ID equal to 002, as shown in Listing 20. ```
{  Name: \"Wsynote002\", Description: \"Sensor Wasynote 2\", }
```
Listing 20: Wasynote Libellium THING extraction. ```
{  name: \"Leaf Wetness\", description: \"Leaf Wetness value\", unitOfMeasurement: {  name: \"Percentuale\", symbol: \"%\", observationType:OM_CountObservation, resultTime: \"2024-11-03T13:00:00Z/2020-11-03T13: 00:00Z\" result: 36 }
```
Listing 21: Datastream and observation of Leaf Wetness sensor. \(\blacksquare\) **180000 DA41**: The first byte corresponds to the \"Temperature Celsius\" measurement, which has a value in float format.