C++ Wrapper around the IBM LMiC LoRaWAN implementation
OTAA/OTAANode.cpp@10:9bf05e9b4cde, 2016-11-22 (annotated)
- Committer:
- Sille Van Landschoot
- Date:
- Tue Nov 22 20:43:03 2016 +0100
- Revision:
- 10:9bf05e9b4cde
- Parent:
- 4:05735e9431c2
Add reset pin support with define directive
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sillevl | 3:63ac55b3514a | 1 | /* The MIT License (MIT) |
sillevl | 3:63ac55b3514a | 2 | * |
sillevl | 3:63ac55b3514a | 3 | * Copyright (c) 2016 Sille Van Landschoot |
sillevl | 3:63ac55b3514a | 4 | * |
sillevl | 3:63ac55b3514a | 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
sillevl | 3:63ac55b3514a | 6 | * of this software and associated documentation files (the "Software"), to deal |
sillevl | 3:63ac55b3514a | 7 | * in the Software without restriction, including without limitation the rights |
sillevl | 3:63ac55b3514a | 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
sillevl | 3:63ac55b3514a | 9 | * copies of the Software, and to permit persons to whom the Software is |
sillevl | 3:63ac55b3514a | 10 | * furnished to do so, subject to the following conditions: |
sillevl | 3:63ac55b3514a | 11 | * |
sillevl | 3:63ac55b3514a | 12 | * The above copyright notice and this permission notice shall be included in all |
sillevl | 3:63ac55b3514a | 13 | * copies or substantial portions of the Software. |
sillevl | 3:63ac55b3514a | 14 | * |
sillevl | 3:63ac55b3514a | 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
sillevl | 3:63ac55b3514a | 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
sillevl | 3:63ac55b3514a | 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
sillevl | 3:63ac55b3514a | 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
sillevl | 3:63ac55b3514a | 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
sillevl | 3:63ac55b3514a | 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
sillevl | 3:63ac55b3514a | 21 | * SOFTWARE. |
sillevl | 3:63ac55b3514a | 22 | */ |
sillevl | 3:63ac55b3514a | 23 | |
sillevl | 3:63ac55b3514a | 24 | |
sillevl | 3:63ac55b3514a | 25 | #include "OTAANode.h" |
sillevl | 3:63ac55b3514a | 26 | |
sillevl | 3:63ac55b3514a | 27 | uint8_t* simple_lorawan_dev_eui; |
sillevl | 3:63ac55b3514a | 28 | uint8_t* simple_lorawan_app_eui; |
sillevl | 3:63ac55b3514a | 29 | uint8_t* simple_lorawan_app_key; |
sillevl | 3:63ac55b3514a | 30 | |
sillevl | 3:63ac55b3514a | 31 | void os_getArtEui(uint8_t *buf) |
sillevl | 3:63ac55b3514a | 32 | { |
sillevl | 3:63ac55b3514a | 33 | memcpy(buf, (const void*) simple_lorawan_app_eui, 8); |
sillevl | 3:63ac55b3514a | 34 | } |
sillevl | 3:63ac55b3514a | 35 | |
sillevl | 3:63ac55b3514a | 36 | void os_getDevEui(uint8_t *buf) |
sillevl | 3:63ac55b3514a | 37 | { |
sillevl | 3:63ac55b3514a | 38 | memcpy(buf, (const void*) simple_lorawan_dev_eui, 8); |
sillevl | 3:63ac55b3514a | 39 | } |
sillevl | 3:63ac55b3514a | 40 | |
sillevl | 3:63ac55b3514a | 41 | void os_getDevKey(uint8_t *buf) |
sillevl | 3:63ac55b3514a | 42 | { |
sillevl | 3:63ac55b3514a | 43 | memcpy(buf, (const void*) simple_lorawan_app_key, 16); |
sillevl | 3:63ac55b3514a | 44 | } |
sillevl | 3:63ac55b3514a | 45 | |
sillevl | 3:63ac55b3514a | 46 | namespace SimpleLoRaWAN |
sillevl | 3:63ac55b3514a | 47 | { |
sillevl | 3:63ac55b3514a | 48 | |
sillevl | 3:63ac55b3514a | 49 | namespace OTAA |
sillevl | 3:63ac55b3514a | 50 | { |
sillevl | 3:63ac55b3514a | 51 | |
sillevl | 3:63ac55b3514a | 52 | Node::Node(uint8_t _app_eui[], uint8_t _dev_eui[], uint8_t _app_key[]) : SimpleLoRaWAN::Node() |
sillevl | 3:63ac55b3514a | 53 | { |
sillevl | 3:63ac55b3514a | 54 | simple_lorawan_dev_eui = _dev_eui; |
sillevl | 3:63ac55b3514a | 55 | simple_lorawan_app_eui = _app_eui; |
sillevl | 3:63ac55b3514a | 56 | simple_lorawan_app_key = _app_key; |
sillevl | 3:63ac55b3514a | 57 | |
sillevl | 3:63ac55b3514a | 58 | LMIC_startJoining(); |
sillevl | 4:05735e9431c2 | 59 | while(LMIC.devaddr == 0){ |
sillevl | 4:05735e9431c2 | 60 | process(); |
sillevl | 4:05735e9431c2 | 61 | }; |
sillevl | 3:63ac55b3514a | 62 | } |
sillevl | 3:63ac55b3514a | 63 | |
sillevl | 3:63ac55b3514a | 64 | Node::~Node() |
sillevl | 3:63ac55b3514a | 65 | { |
sillevl | 3:63ac55b3514a | 66 | |
sillevl | 3:63ac55b3514a | 67 | } |
sillevl | 3:63ac55b3514a | 68 | |
sillevl | 3:63ac55b3514a | 69 | } |
sillevl | 3:63ac55b3514a | 70 | |
sillevl | 3:63ac55b3514a | 71 | } |