Fahad Mirza
/
Nucleo_HXC900
A demo application for HXC900 LoRaWAN module using Nucleo-L053R8.
lora_driver.h@0:a0c5877bd360, 2018-07-12 (annotated)
- Committer:
- fahadmirza
- Date:
- Thu Jul 12 00:50:48 2018 +0000
- Revision:
- 0:a0c5877bd360
- Child:
- 2:1ef859bc5cd2
Porting complete!
Who changed what in which revision?
User | Revision | Line number | New 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>© 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 | 0:a0c5877bd360 | 60 | typedef enum eJoinStatus |
fahadmirza | 0:a0c5877bd360 | 61 | { |
fahadmirza | 0:a0c5877bd360 | 62 | JOINED, |
fahadmirza | 0:a0c5877bd360 | 63 | NOT_JOINED |
fahadmirza | 0:a0c5877bd360 | 64 | }eJoinStatus_t; |
fahadmirza | 0:a0c5877bd360 | 65 | |
fahadmirza | 0:a0c5877bd360 | 66 | typedef struct sLoraConfig |
fahadmirza | 0:a0c5877bd360 | 67 | { |
fahadmirza | 0:a0c5877bd360 | 68 | eJoinMode_t joinMode; |
fahadmirza | 0:a0c5877bd360 | 69 | char class_; |
fahadmirza | 0:a0c5877bd360 | 70 | char *devEui; |
fahadmirza | 0:a0c5877bd360 | 71 | char *appEui; |
fahadmirza | 0:a0c5877bd360 | 72 | char *appKey; |
fahadmirza | 0:a0c5877bd360 | 73 | }sLoraConfig_t; |
fahadmirza | 0:a0c5877bd360 | 74 | |
fahadmirza | 0:a0c5877bd360 | 75 | typedef struct sLoraDriverParam |
fahadmirza | 0:a0c5877bd360 | 76 | { |
fahadmirza | 0:a0c5877bd360 | 77 | uint32_t SensorMeasureTime; |
fahadmirza | 0:a0c5877bd360 | 78 | void (*SendDataHandler)(uint8_t *buffer, uint8_t *dataSize, uint8_t *ack, uint8_t *port); // Sensor data callback |
fahadmirza | 0:a0c5877bd360 | 79 | void (*ReceiveDataHandler)(uint8_t *buffer, uint8_t dataSize, uint8_t ack, uint8_t port); |
fahadmirza | 0:a0c5877bd360 | 80 | }sLoraDriverParam_t; |
fahadmirza | 0:a0c5877bd360 | 81 | |
fahadmirza | 0:a0c5877bd360 | 82 | /* Public functions ----------------------------------------------------------*/ |
fahadmirza | 0:a0c5877bd360 | 83 | void Lora_init(sLoraConfig_t *loraConfig, sLoraDriverParam_t *loraDriverParam); |
fahadmirza | 0:a0c5877bd360 | 84 | void Lora_fsm(void); |
fahadmirza | 0:a0c5877bd360 | 85 | |
fahadmirza | 0:a0c5877bd360 | 86 | #ifdef __cplusplus |
fahadmirza | 0:a0c5877bd360 | 87 | } |
fahadmirza | 0:a0c5877bd360 | 88 | #endif /* __cplusplus */ |
fahadmirza | 0:a0c5877bd360 | 89 | |
fahadmirza | 0:a0c5877bd360 | 90 | #endif |