A demo application for HXC900 LoRaWAN module using Nucleo-L053R8.

Dependencies:   mbed

Committer:
fahadmirza
Date:
Mon Jul 16 16:37:32 2018 +0000
Revision:
2:1ef859bc5cd2
Parent:
0:a0c5877bd360
Added settings for ADR; Removed Mbed specific serial declarations;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fahadmirza 0:a0c5877bd360 1 /*
fahadmirza 0:a0c5877bd360 2 _ _ _____ _______
fahadmirza 0:a0c5877bd360 3 | | | | |_ _| |__ __|
fahadmirza 0:a0c5877bd360 4 | |__| | __ ___ __ | | ___ | |
fahadmirza 0:a0c5877bd360 5 | __ |/ _` \ \/ / | | / _ \| |
fahadmirza 0:a0c5877bd360 6 | | | | (_| |> < _| || (_) | |
fahadmirza 0:a0c5877bd360 7 |_| |_|\__,_/_/\_\_____\___/|_|
fahadmirza 0:a0c5877bd360 8 (C)2017 HaxIoT
fahadmirza 0:a0c5877bd360 9 */
fahadmirza 0:a0c5877bd360 10 /*******************************************************************************
fahadmirza 0:a0c5877bd360 11 * File : lora_driver.h
fahadmirza 0:a0c5877bd360 12 * Author : Fahad Mirza (Haxiot)
fahadmirza 0:a0c5877bd360 13 * Version : V1.0.0
fahadmirza 0:a0c5877bd360 14 * Modified: 13-April-2018
fahadmirza 0:a0c5877bd360 15 * Brief : Header for driver lora_driver.h module
fahadmirza 0:a0c5877bd360 16 ******************************************************************************
fahadmirza 0:a0c5877bd360 17 * @attention
fahadmirza 0:a0c5877bd360 18 *
fahadmirza 0:a0c5877bd360 19 * <h2><center>&copy; COPYRIGHT(c) 2017 Haxiot</center></h2>
fahadmirza 0:a0c5877bd360 20 *
fahadmirza 0:a0c5877bd360 21 * Redistribution and use in source and binary forms, with or without modification,
fahadmirza 0:a0c5877bd360 22 * are permitted provided that the following conditions are met:
fahadmirza 0:a0c5877bd360 23 * 1. Redistributions of source code must retain the above copyright notice,
fahadmirza 0:a0c5877bd360 24 * this list of conditions and the following disclaimer.
fahadmirza 0:a0c5877bd360 25 * 2. Redistributions in binary form must reproduce the above copyright notice,
fahadmirza 0:a0c5877bd360 26 * this list of conditions and the following disclaimer in the documentation
fahadmirza 0:a0c5877bd360 27 * and/or other materials provided with the distribution.
fahadmirza 0:a0c5877bd360 28 * 3. Neither the name of Haxiot nor the names of its contributors
fahadmirza 0:a0c5877bd360 29 * may be used to endorse or promote products derived from this software
fahadmirza 0:a0c5877bd360 30 * without specific prior written permission.
fahadmirza 0:a0c5877bd360 31 *
fahadmirza 0:a0c5877bd360 32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
fahadmirza 0:a0c5877bd360 33 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
fahadmirza 0:a0c5877bd360 34 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
fahadmirza 0:a0c5877bd360 35 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
fahadmirza 0:a0c5877bd360 36 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
fahadmirza 0:a0c5877bd360 37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
fahadmirza 0:a0c5877bd360 38 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
fahadmirza 0:a0c5877bd360 39 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
fahadmirza 0:a0c5877bd360 40 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
fahadmirza 0:a0c5877bd360 41 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
fahadmirza 0:a0c5877bd360 42 *
fahadmirza 0:a0c5877bd360 43 ******************************************************************************
fahadmirza 0:a0c5877bd360 44 */
fahadmirza 0:a0c5877bd360 45
fahadmirza 0:a0c5877bd360 46 #ifndef __LORA_DRIVER_H
fahadmirza 0:a0c5877bd360 47 #define __LORA_DRIVER_H
fahadmirza 0:a0c5877bd360 48
fahadmirza 0:a0c5877bd360 49 #ifdef __cplusplus
fahadmirza 0:a0c5877bd360 50 extern "C" {
fahadmirza 0:a0c5877bd360 51 #endif
fahadmirza 0:a0c5877bd360 52
fahadmirza 0:a0c5877bd360 53 /* Exported types ------------------------------------------------------------*/
fahadmirza 0:a0c5877bd360 54 typedef enum eJoinMode
fahadmirza 0:a0c5877bd360 55 {
fahadmirza 0:a0c5877bd360 56 OTAA,
fahadmirza 0:a0c5877bd360 57 ABP
fahadmirza 0:a0c5877bd360 58 }eJoinMode_t;
fahadmirza 0:a0c5877bd360 59
fahadmirza 2:1ef859bc5cd2 60 typedef enum eAdrStatus
fahadmirza 2:1ef859bc5cd2 61 {
fahadmirza 2:1ef859bc5cd2 62 ADR_OFF = 0,
fahadmirza 2:1ef859bc5cd2 63 ADR_ON
fahadmirza 2:1ef859bc5cd2 64 }eAdrStatus_t;
fahadmirza 2:1ef859bc5cd2 65
fahadmirza 0:a0c5877bd360 66 typedef enum eJoinStatus
fahadmirza 0:a0c5877bd360 67 {
fahadmirza 0:a0c5877bd360 68 JOINED,
fahadmirza 0:a0c5877bd360 69 NOT_JOINED
fahadmirza 0:a0c5877bd360 70 }eJoinStatus_t;
fahadmirza 0:a0c5877bd360 71
fahadmirza 0:a0c5877bd360 72 typedef struct sLoraConfig
fahadmirza 0:a0c5877bd360 73 {
fahadmirza 0:a0c5877bd360 74 eJoinMode_t joinMode;
fahadmirza 2:1ef859bc5cd2 75 eAdrStatus_t adrStatus;
fahadmirza 0:a0c5877bd360 76 char class_;
fahadmirza 0:a0c5877bd360 77 char *devEui;
fahadmirza 0:a0c5877bd360 78 char *appEui;
fahadmirza 0:a0c5877bd360 79 char *appKey;
fahadmirza 0:a0c5877bd360 80 }sLoraConfig_t;
fahadmirza 0:a0c5877bd360 81
fahadmirza 0:a0c5877bd360 82 typedef struct sLoraDriverParam
fahadmirza 0:a0c5877bd360 83 {
fahadmirza 0:a0c5877bd360 84 uint32_t SensorMeasureTime;
fahadmirza 0:a0c5877bd360 85 void (*SendDataHandler)(uint8_t *buffer, uint8_t *dataSize, uint8_t *ack, uint8_t *port); // Sensor data callback
fahadmirza 0:a0c5877bd360 86 void (*ReceiveDataHandler)(uint8_t *buffer, uint8_t dataSize, uint8_t ack, uint8_t port);
fahadmirza 0:a0c5877bd360 87 }sLoraDriverParam_t;
fahadmirza 0:a0c5877bd360 88
fahadmirza 0:a0c5877bd360 89 /* Public functions ----------------------------------------------------------*/
fahadmirza 0:a0c5877bd360 90 void Lora_init(sLoraConfig_t *loraConfig, sLoraDriverParam_t *loraDriverParam);
fahadmirza 0:a0c5877bd360 91 void Lora_fsm(void);
fahadmirza 0:a0c5877bd360 92
fahadmirza 0:a0c5877bd360 93 #ifdef __cplusplus
fahadmirza 0:a0c5877bd360 94 }
fahadmirza 0:a0c5877bd360 95 #endif /* __cplusplus */
fahadmirza 0:a0c5877bd360 96
fahadmirza 0:a0c5877bd360 97 #endif