BBR 1 Ebene

Committer:
borlanic
Date:
Mon May 14 11:29:06 2018 +0000
Revision:
0:fbdae7e6d805
BBR

Who changed what in which revision?

UserRevisionLine numberNew contents of line
borlanic 0:fbdae7e6d805 1 /**
borlanic 0:fbdae7e6d805 2 * @file
borlanic 0:fbdae7e6d805 3 *
borlanic 0:fbdae7e6d805 4 * @brief Implementation of LoRaWANBase
borlanic 0:fbdae7e6d805 5 *
borlanic 0:fbdae7e6d805 6 * Copyright (c) 2017, Arm Limited and affiliates.
borlanic 0:fbdae7e6d805 7 * SPDX-License-Identifier: Apache-2.0
borlanic 0:fbdae7e6d805 8 *
borlanic 0:fbdae7e6d805 9 * Licensed under the Apache License, Version 2.0 (the "License");
borlanic 0:fbdae7e6d805 10 * you may not use this file except in compliance with the License.
borlanic 0:fbdae7e6d805 11 * You may obtain a copy of the License at
borlanic 0:fbdae7e6d805 12 *
borlanic 0:fbdae7e6d805 13 * http://www.apache.org/licenses/LICENSE-2.0
borlanic 0:fbdae7e6d805 14 *
borlanic 0:fbdae7e6d805 15 * Unless required by applicable law or agreed to in writing, software
borlanic 0:fbdae7e6d805 16 * distributed under the License is distributed on an "AS IS" BASIS,
borlanic 0:fbdae7e6d805 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
borlanic 0:fbdae7e6d805 18 * See the License for the specific language governing permissions and
borlanic 0:fbdae7e6d805 19 * limitations under the License.
borlanic 0:fbdae7e6d805 20 */
borlanic 0:fbdae7e6d805 21
borlanic 0:fbdae7e6d805 22 #include "LoRaWANInterface.h"
borlanic 0:fbdae7e6d805 23
borlanic 0:fbdae7e6d805 24 using namespace events;
borlanic 0:fbdae7e6d805 25
borlanic 0:fbdae7e6d805 26 LoRaWANInterface::LoRaWANInterface(LoRaRadio& radio)
borlanic 0:fbdae7e6d805 27 {
borlanic 0:fbdae7e6d805 28 _lw_stack.bind_radio_driver(radio);
borlanic 0:fbdae7e6d805 29 }
borlanic 0:fbdae7e6d805 30
borlanic 0:fbdae7e6d805 31 LoRaWANInterface::~LoRaWANInterface()
borlanic 0:fbdae7e6d805 32 {
borlanic 0:fbdae7e6d805 33 }
borlanic 0:fbdae7e6d805 34
borlanic 0:fbdae7e6d805 35 lorawan_status_t LoRaWANInterface::initialize(EventQueue *queue)
borlanic 0:fbdae7e6d805 36 {
borlanic 0:fbdae7e6d805 37 Lock lock(*this);
borlanic 0:fbdae7e6d805 38 return _lw_stack.initialize_mac_layer(queue);
borlanic 0:fbdae7e6d805 39 }
borlanic 0:fbdae7e6d805 40
borlanic 0:fbdae7e6d805 41 lorawan_status_t LoRaWANInterface::connect()
borlanic 0:fbdae7e6d805 42 {
borlanic 0:fbdae7e6d805 43 Lock lock(*this);
borlanic 0:fbdae7e6d805 44 return _lw_stack.connect();
borlanic 0:fbdae7e6d805 45 }
borlanic 0:fbdae7e6d805 46
borlanic 0:fbdae7e6d805 47 lorawan_status_t LoRaWANInterface::connect(const lorawan_connect_t &connect)
borlanic 0:fbdae7e6d805 48 {
borlanic 0:fbdae7e6d805 49 Lock lock(*this);
borlanic 0:fbdae7e6d805 50 return _lw_stack.connect(connect);
borlanic 0:fbdae7e6d805 51 }
borlanic 0:fbdae7e6d805 52
borlanic 0:fbdae7e6d805 53 lorawan_status_t LoRaWANInterface::disconnect()
borlanic 0:fbdae7e6d805 54 {
borlanic 0:fbdae7e6d805 55 Lock lock(*this);
borlanic 0:fbdae7e6d805 56 return _lw_stack.shutdown();
borlanic 0:fbdae7e6d805 57 }
borlanic 0:fbdae7e6d805 58
borlanic 0:fbdae7e6d805 59 lorawan_status_t LoRaWANInterface::add_link_check_request()
borlanic 0:fbdae7e6d805 60 {
borlanic 0:fbdae7e6d805 61 Lock lock(*this);
borlanic 0:fbdae7e6d805 62 return _lw_stack.set_link_check_request();
borlanic 0:fbdae7e6d805 63 }
borlanic 0:fbdae7e6d805 64
borlanic 0:fbdae7e6d805 65 void LoRaWANInterface::remove_link_check_request()
borlanic 0:fbdae7e6d805 66 {
borlanic 0:fbdae7e6d805 67 Lock lock(*this);
borlanic 0:fbdae7e6d805 68 _lw_stack.remove_link_check_request();
borlanic 0:fbdae7e6d805 69 }
borlanic 0:fbdae7e6d805 70
borlanic 0:fbdae7e6d805 71 lorawan_status_t LoRaWANInterface::set_datarate(uint8_t data_rate)
borlanic 0:fbdae7e6d805 72 {
borlanic 0:fbdae7e6d805 73 Lock lock(*this);
borlanic 0:fbdae7e6d805 74 return _lw_stack.set_channel_data_rate(data_rate);
borlanic 0:fbdae7e6d805 75 }
borlanic 0:fbdae7e6d805 76
borlanic 0:fbdae7e6d805 77 lorawan_status_t LoRaWANInterface::set_confirmed_msg_retries(uint8_t count)
borlanic 0:fbdae7e6d805 78 {
borlanic 0:fbdae7e6d805 79 Lock lock(*this);
borlanic 0:fbdae7e6d805 80 return _lw_stack.set_confirmed_msg_retry(count);
borlanic 0:fbdae7e6d805 81 }
borlanic 0:fbdae7e6d805 82
borlanic 0:fbdae7e6d805 83 lorawan_status_t LoRaWANInterface::enable_adaptive_datarate()
borlanic 0:fbdae7e6d805 84 {
borlanic 0:fbdae7e6d805 85 Lock lock(*this);
borlanic 0:fbdae7e6d805 86 return _lw_stack.enable_adaptive_datarate(true);
borlanic 0:fbdae7e6d805 87 }
borlanic 0:fbdae7e6d805 88
borlanic 0:fbdae7e6d805 89 lorawan_status_t LoRaWANInterface::disable_adaptive_datarate()
borlanic 0:fbdae7e6d805 90 {
borlanic 0:fbdae7e6d805 91 Lock lock(*this);
borlanic 0:fbdae7e6d805 92 return _lw_stack.enable_adaptive_datarate(false);
borlanic 0:fbdae7e6d805 93 }
borlanic 0:fbdae7e6d805 94
borlanic 0:fbdae7e6d805 95 lorawan_status_t LoRaWANInterface::set_channel_plan(const lorawan_channelplan_t &channel_plan)
borlanic 0:fbdae7e6d805 96 {
borlanic 0:fbdae7e6d805 97 Lock lock(*this);
borlanic 0:fbdae7e6d805 98 return _lw_stack.add_channels(channel_plan);
borlanic 0:fbdae7e6d805 99 }
borlanic 0:fbdae7e6d805 100
borlanic 0:fbdae7e6d805 101 lorawan_status_t LoRaWANInterface::get_channel_plan(lorawan_channelplan_t &channel_plan)
borlanic 0:fbdae7e6d805 102 {
borlanic 0:fbdae7e6d805 103 Lock lock(*this);
borlanic 0:fbdae7e6d805 104 return _lw_stack.get_enabled_channels(channel_plan);
borlanic 0:fbdae7e6d805 105 }
borlanic 0:fbdae7e6d805 106
borlanic 0:fbdae7e6d805 107 lorawan_status_t LoRaWANInterface::remove_channel(uint8_t id)
borlanic 0:fbdae7e6d805 108 {
borlanic 0:fbdae7e6d805 109 Lock lock(*this);
borlanic 0:fbdae7e6d805 110 return _lw_stack.remove_a_channel(id);
borlanic 0:fbdae7e6d805 111 }
borlanic 0:fbdae7e6d805 112
borlanic 0:fbdae7e6d805 113 lorawan_status_t LoRaWANInterface::remove_channel_plan()
borlanic 0:fbdae7e6d805 114 {
borlanic 0:fbdae7e6d805 115 Lock lock(*this);
borlanic 0:fbdae7e6d805 116 return _lw_stack.drop_channel_list();
borlanic 0:fbdae7e6d805 117 }
borlanic 0:fbdae7e6d805 118
borlanic 0:fbdae7e6d805 119 int16_t LoRaWANInterface::send(uint8_t port, const uint8_t* data, uint16_t length, int flags)
borlanic 0:fbdae7e6d805 120 {
borlanic 0:fbdae7e6d805 121 Lock lock(*this);
borlanic 0:fbdae7e6d805 122 return _lw_stack.handle_tx(port, data, length, flags);
borlanic 0:fbdae7e6d805 123 }
borlanic 0:fbdae7e6d805 124
borlanic 0:fbdae7e6d805 125 int16_t LoRaWANInterface::receive(uint8_t port, uint8_t* data, uint16_t length, int flags)
borlanic 0:fbdae7e6d805 126 {
borlanic 0:fbdae7e6d805 127 Lock lock(*this);
borlanic 0:fbdae7e6d805 128 return _lw_stack.handle_rx(data, length, port, flags, true);
borlanic 0:fbdae7e6d805 129 }
borlanic 0:fbdae7e6d805 130
borlanic 0:fbdae7e6d805 131 int16_t LoRaWANInterface::receive(uint8_t* data, uint16_t length, uint8_t& port, int& flags)
borlanic 0:fbdae7e6d805 132 {
borlanic 0:fbdae7e6d805 133 Lock lock(*this);
borlanic 0:fbdae7e6d805 134 return _lw_stack.handle_rx(data, length, port, flags, false);
borlanic 0:fbdae7e6d805 135 }
borlanic 0:fbdae7e6d805 136
borlanic 0:fbdae7e6d805 137 lorawan_status_t LoRaWANInterface::add_app_callbacks(lorawan_app_callbacks_t *callbacks)
borlanic 0:fbdae7e6d805 138 {
borlanic 0:fbdae7e6d805 139 Lock lock(*this);
borlanic 0:fbdae7e6d805 140 return _lw_stack.set_lora_callbacks(callbacks);
borlanic 0:fbdae7e6d805 141 }
borlanic 0:fbdae7e6d805 142
borlanic 0:fbdae7e6d805 143 lorawan_status_t LoRaWANInterface::set_device_class(const device_class_t device_class)
borlanic 0:fbdae7e6d805 144 {
borlanic 0:fbdae7e6d805 145 Lock lock(*this);
borlanic 0:fbdae7e6d805 146 return _lw_stack.set_device_class(device_class);
borlanic 0:fbdae7e6d805 147 }