Fahad Mirza
/
Nucleo_HXC900
A demo application for HXC900 LoRaWAN module using Nucleo-L053R8.
Diff: lora_conf.h
- Revision:
- 6:1d09b7960d57
- Parent:
- 5:53302861bfea
- Child:
- 7:3c5d342068dd
--- a/lora_conf.h Mon Jul 16 20:12:42 2018 +0000 +++ b/lora_conf.h Mon Jul 16 23:54:41 2018 +0000 @@ -50,6 +50,8 @@ extern "C" { #endif +#include <ctype.h> +#include <string.h> /* Private Macros ------------------------------------------------------------*/ #define SENSORS_MEASURE_CYCLE (15000U) // Send packet every 15s @@ -64,7 +66,11 @@ // Mbed specific declaration AnalogIn temperatureSensor(A0); DigitalOut nucleoLED(LED1); +DigitalOut blueLED(D11); +DigitalOut redLED(D10); +DigitalOut greenLED(D9); +static void tolower_str(char *strBuffer, uint8_t bufferSize); /* Private function definitions ----------------------------------------------*/ /****************************************************************************** * @Brief : Uplink packet handler for lora_driver @@ -104,18 +110,39 @@ ******************************************************************************/ static void LedControl(uint8_t *buffer, uint8_t dataSize, uint8_t ack, uint8_t port) { - switch(buffer[dataSize - 1]) + tolower_str((char *)buffer, dataSize); + + if(strncmp("red", (const char *)buffer, 3) == 0) + { + redLED = 1; + greenLED = 0; + blueLED = 0; + } + else if(strncmp("green", (const char *)buffer, 5) == 0) + { + redLED = 0; + greenLED = 1; + blueLED = 0; + } + else if(strncmp("blue", (const char *)buffer, 4) == 0) { - case 1: - { - BSP_LED_On(LED_GREEN); - break; - } - default: - { - BSP_LED_Off(LED_GREEN); - break; - } + redLED = 0; + greenLED = 0; + blueLED = 1; + } + else if(strncmp("off", (const char *)buffer, 4) == 0) + { + redLED = 0; + greenLED = 0; + blueLED = 0; + } +} + +static void tolower_str(char *strBuffer, uint8_t bufferSize) +{ + for(uint8_t i = 0; i < bufferSize; i++) + { + strBuffer[i] = tolower(strBuffer[i]); } }