Cayenne-LPP avec NFC

Dependents:   er4_2022

Committer:
superphil06
Date:
Tue Feb 08 09:03:59 2022 +0000
Revision:
8:2b94df050b00
Parent:
5:a67d5a7955c7
add addVEHICLE function

Who changed what in which revision?

UserRevisionLine numberNew contents of line
eptak 2:ac824f095591 1 # Cayenne Low Power Payload
superphil06 8:2b94df050b00 2 # 8_2_2022 add addVEHICLE () function to send 8 ascii character representing Vehicle ID
eptak 2:ac824f095591 3 Payload builder library
eptak 2:ac824f095591 4
eptak 2:ac824f095591 5
eptak 2:ac824f095591 6 # Example use
eptak 2:ac824f095591 7 ```
eptak 2:ac824f095591 8 #include 'CayenneLPP.h';
eptak 2:ac824f095591 9
eptak 2:ac824f095591 10 #define MAX_SIZE 200; // depends on spreading factor and frequency used
eptak 2:ac824f095591 11
eptak 2:ac824f095591 12 CayenneLPP Payload(MAX_SIZE);
eptak 2:ac824f095591 13
eptak 3:a65959c9e3b9 14 float celsius = -4.1;
eptak 2:ac824f095591 15 float accel[] = {1.234, -1.234, 0};
eptak 2:ac824f095591 16 float rh = 30;
eptak 3:a65959c9e3b9 17 float hpa = 1014.1;
eptak 5:a67d5a7955c7 18 float latitude = 42.3519;
eptak 5:a67d5a7955c7 19 float longitude = -87.9094;
eptak 5:a67d5a7955c7 20 float altitude:10
eptak 3:a65959c9e3b9 21
eptak 3:a65959c9e3b9 22 int size = 0;
eptak 2:ac824f095591 23
eptak 2:ac824f095591 24 Payload.reset();
eptak 3:a65959c9e3b9 25 size = Payload.addTemperature(0, celsius);
eptak 3:a65959c9e3b9 26
eptak 3:a65959c9e3b9 27 if (size == 0) {
eptak 3:a65959c9e3b9 28 // not enough byte left to add the data
eptak 3:a65959c9e3b9 29 }
eptak 3:a65959c9e3b9 30
eptak 3:a65959c9e3b9 31 else {
eptak 3:a65959c9e3b9 32 // add function returned current payload size
eptak 3:a65959c9e3b9 33 }
eptak 3:a65959c9e3b9 34
eptak 3:a65959c9e3b9 35
eptak 2:ac824f095591 36 Payload.addAccelerometer(1, accel[0], accel[1], accel[2]);
eptak 2:ac824f095591 37 Payload.addRelativeHumidity(3, rh);
eptak 3:a65959c9e3b9 38 Payload.addBarometricPressure(4, hpa);
eptak 4:8d32c35e74ad 39 Payload.addGPS(5, latitude, longitude, altitude);
eptak 2:ac824f095591 40
eptak 3:a65959c9e3b9 41 // Call LoRaWAN library to send the frame
eptak 2:ac824f095591 42 LORA_SEND(Payload.getBuffer(), Payload.getSize());
eptak 2:ac824f095591 43 ```