CY Lim
/
LoRaWAN-demo-SX1272-RP
RP
Diff: app/main.cpp
- Revision:
- 16:83e5836e986b
- Parent:
- 15:d4ce35d5c9f2
--- a/app/main.cpp Thu Jul 26 07:38:16 2018 +0000 +++ b/app/main.cpp Thu Jul 26 08:11:04 2018 +0000 @@ -34,7 +34,7 @@ /*! * Default datarate */ -#define LORAWAN_DEFAULT_DATARATE DR_0 +#define LORAWAN_DEFAULT_DATARATE DR_1 /*! * LoRaWAN confirmed messages @@ -83,13 +83,13 @@ /*! * User application data buffer size */ -#if ( LORAWAN_CONFIRMED_MSG_ON == 1 ) -#define LORAWAN_APP_DATA_SIZE 6 +//#if ( LORAWAN_CONFIRMED_MSG_ON == 1 ) +//#define LORAWAN_APP_DATA_SIZE 6 -#else -#define LORAWAN_APP_DATA_SIZE 8 +//#else +#define LORAWAN_APP_DATA_SIZE 12 -#endif +//#endif static uint8_t DevEui[] = LORAWAN_DEVICE_EUI; static uint8_t AppEui[] = LORAWAN_APPLICATION_EUI; @@ -234,7 +234,7 @@ AnalogIn LightSensor(A3); -AnalogIn AirSensor(A2); +AnalogIn AnalogSensor(A2); AnalogIn TemperatureSensor(A1); void SerialDisplayRefresh( void ) @@ -293,7 +293,7 @@ { unsigned int a, beta = 4275, units, tens; - float temperature, resistance, lux, air; + float temperature, resistance, lux, analog; switch( port ) { @@ -324,7 +324,7 @@ resistance = (float)(65535 - a) * 10 / a; // convert to Lux - lux = (1/resistance)*2000; // value to be optimise + lux = (1/resistance)*2000; // value need to be optimise SerialDisplayData(lux); AppData[4] = 2; // Channel 2 AppData[5] = 0x65; // lux @@ -332,10 +332,13 @@ AppData[7] = (int)lux; // Air quality - air = AirSensor.read()*1000; /* Read analog value */ + analog = AnalogSensor.read()*1000; /* Read analog value */ //SerialDisplayData(a); - SerialDisplayFloat(air); - + //SerialDisplayFloat(air); + AppData[8] = 3; // Channel 3 + AppData[9] = 2; // lux + AppData[10] = (int)analog/0x100; + AppData[11] = (int)analog; if( IsTxConfirmed == true ) {