LR Initial Publish
Dependencies: X_NUCLEO_IKS01A2 driver_mbed_TH02 mbed LoRaWAN-lib-v1_0_1 SX1272Lib
Fork of Training-Aug2018-SX1272-X-NUCLEO-IKS01A2 by
Diff: app/LoRaApp.cpp
- Revision:
- 10:bba416e2c3e1
- Parent:
- 9:a47750bce9f8
--- a/app/LoRaApp.cpp Sun Aug 12 06:09:53 2018 +0000 +++ b/app/LoRaApp.cpp Sun Aug 19 20:08:35 2018 +0000 @@ -18,9 +18,8 @@ float sensor_data; -#ifdef USE_IKS01A1_SENSOR int32_t Accl_Value[3] = {0}; -#endif + #ifdef USE_CAYENNE_LPP /* @@ -29,7 +28,7 @@ .... Humidity .... Accelerometer */ -uint8_t maxLPPsize[4] = {4, 4, 3, 8}; +uint8_t maxLPPsize[5] = {4, 4, 3, 8, 8}; #endif bool VerticalStatus = false; @@ -63,18 +62,10 @@ { // Appends 1 Byte to TX buffer case AppTemp: - { -#if defined( USE_IKS01A1_SENSOR ) -//#ifdef USE_IKS01A1_SENSOR + { - temp_sensor2->GetTemperature(&sensor_data); - -#elif defined( USE_GROVE_SENSOR ) - - sensor_data = myTH02.ReadTemperature(); - -#endif - + hum_temp->get_temperature(&sensor_data); + printf("Temp = %f, %d\r\n", sensor_data, (int8_t) sensor_data); if( ( BuffPtr + 1 ) <= LORAWAN_APP_DATA_SIZE ) @@ -93,10 +84,8 @@ // Appends 2 Bytes to TX buffer case AppPressr: - { -#ifdef USE_IKS01A1_SENSOR - - pressure_sensor->GetPressure(&sensor_data); + { + press_temp->get_pressure(&sensor_data); printf("Pressure = %f, %d\r\n", sensor_data, (uint16_t) sensor_data); @@ -113,23 +102,15 @@ BuffAddr[BuffPtr++] = ( (int16_t) sensor_data ) & 0xFF; #endif } - -#endif + break; } // Appends 2 Bytes to TX buffer case AppHumid: - { -#if defined ( USE_IKS01A1_SENSOR ) - - humidity_sensor->GetHumidity(&sensor_data); - -#elif defined ( USE_GROVE_SENSOR ) - - sensor_data = myTH02.ReadHumidity(); - -#endif + { + + hum_temp->get_humidity(&sensor_data); printf("Humidity = %f, %d\r\n", sensor_data, (uint8_t) sensor_data); @@ -144,6 +125,29 @@ break; } + + // Appends 2 Bytes to TX buffer + case AppGyro: + { + acc_gyro->get_g_axes(Accl_Value); + + printf("Gyro X/Y/Z = %d/%d/%d\r\n", Accl_Value[0], Accl_Value[1], Accl_Value[2]); + + if( ( BuffPtr + 6 ) <= LORAWAN_APP_DATA_SIZE ) + { + Accl_Value[0] /= 10; + BuffAddr[BuffPtr++] = ( (int16_t) Accl_Value[0] >> 8 ) & 0xFF; + BuffAddr[BuffPtr++] = ( (int16_t) Accl_Value[0] ) & 0xFF; + Accl_Value[1] /= 10; + BuffAddr[BuffPtr++] = ( (int16_t) Accl_Value[1] >> 8 ) & 0xFF; + BuffAddr[BuffPtr++] = ( (int16_t) Accl_Value[1] ) & 0xFF; + Accl_Value[2] /= 10; + BuffAddr[BuffPtr++] = ( (int16_t) Accl_Value[2] >> 8 ) & 0xFF; + BuffAddr[BuffPtr++] = ( (int16_t) Accl_Value[2] ) & 0xFF; + } + + break; + } // Appends 1 Byte to TX buffer case AppBat: @@ -172,9 +176,8 @@ // Appends 2 Bytes to TX buffer case AppAccl: { -#ifdef USE_IKS01A1_SENSOR - accelerometer->Get_X_Axes(Accl_Value); + accelerometer->get_x_axes(Accl_Value); printf("X/Y/Z = %d/%d/%d\r\n", Accl_Value[0], Accl_Value[1], Accl_Value[2]); @@ -185,16 +188,15 @@ BuffAddr[BuffPtr++] = ( (int16_t) Accl_Value[1] >> 8 ) & 0xFF; BuffAddr[BuffPtr++] = ( (int16_t) Accl_Value[1] ) & 0xFF; BuffAddr[BuffPtr++] = ( (int16_t) Accl_Value[2] >> 8 ) & 0xFF; - BuffAddr[BuffPtr++] = ( (int16_t) Accl_Value[2] ) & 0xFF; - } -#endif + BuffAddr[BuffPtr++] = ( (int16_t) Accl_Value[2] ) & 0xFF; + } + break; } case AppPushButton: { static uint8_t PushButtonCnt = 0; - uint8_t *p = (uint8_t *) &PushButtonCnt; PushButtonCnt = LoRaMacUplinkStatus.UplinkCounter; PushButtonCnt = (PushButtonCnt + 1) & 0xFF;