Send data in network endianness Add information to README about the data packet format.
authorNathael Pajani <nathael.pajani@ed3l.fr>
Sun, 14 May 2017 10:45:32 +0000 (12:45 +0200)
committerNathael Pajani <nathael.pajani@ed3l.fr>
Sat, 11 Feb 2023 04:09:54 +0000 (05:09 +0100)
v04/README
v04/main.c

index 6ce3aeb..d686ea5 100644 (file)
@@ -49,13 +49,41 @@ format is :
   #         addr           type          [other data]
  0x23  (0x01 to 0x1F)  (0x00 to 0xFF)    [....]
 Valid types are :
- - 'a' : all - request to send all available sensor data to host.
+ - 'a' : get all - request to send all available sensor data to host, no data.
  - 'l' : set led color - set the sensor led color. Three bytes of data (RGB).
+ - 'c' : get compensation data from BME280 sensor. (TO BE DEFINED)
 
 It is also possible to broadcast a message to all sensors by sending to address
 255 (0xFF)
 
 
+The response for the "get all" request has the following format :
+  #    (addr | sensors)      data
+ 0x23      1 byte          18 bytes
+
+The second byte holds the address on the fist 5 bits (LSB), and information on
+available sensors on the three top bits :
+addr | sensors : (0x01 to 0x1F) | (got_tsl << 5) | (got_veml << 6) | (got_bme << 7)
+  got_tsl : Set if TSL256x sensor is present and configured
+  got_veml : Set if VEML6070 sensor is present and configured
+  got_bme : Set if BME280 sensor is present and configured
+
+data is a set of nine 16bits values, in network (big) endian order, with the
+following meaning, in this order :
+ - raw_humidity from soil moisture sensor
+ - lux value from TSL256x
+ - ir value from TSL256x
+ - uv value from VEML6070
+ - pressure from BME280
+ - comp_temp from BME280
+ - humidity from BME280
+ - unused - should be 0 (nul)
+ - unused - should be 0 (nul)
+
+
+The response for the "get compensation data" request has to be defined.
+
+
 To set the sensor address using a serial line from a linux host, you can use
 these commands (sensor connected to ttyUSB0) :
 
index e63189c..be8d52f 100644 (file)
@@ -484,13 +484,13 @@ int main(void)
 
                                buff[0] = '#';
                                buff[1] = address | (got_tsl << 5) | (got_veml << 6) | (got_bme << 7);
-                               data[1] = (uint16_t)raw_humidity;
-                               data[2] = (uint16_t)lux;
-                               data[3] = (uint16_t)ir;
-                               data[4] = (uint16_t)uv;
-                               data[5] = (uint16_t)pressure;
-                               data[6] = (uint16_t)comp_temp;
-                               data[7] = (uint16_t)humidity;
+                               data[1] = (uint16_t)htons(raw_humidity);
+                               data[2] = (uint16_t)htons(lux);
+                               data[3] = (uint16_t)htons(ir);
+                               data[4] = (uint16_t)htons(uv);
+                               data[5] = (uint16_t)htons(pressure);
+                               data[6] = (uint16_t)htons(comp_temp);
+                               data[7] = (uint16_t)htons(humidity);
 
                                gpio_clear(tx_en);
                                serial_write(UART0, buff, 20);