Kenji Arai / TYBLE16_mbedlized_os5_several_examples_1st

Dependencies:   nRF51_Vdd TextLCD BME280

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LoRaWANInterface.h Source File

LoRaWANInterface.h

00001 /**
00002  * Copyright (c) 2017, Arm Limited and affiliates.
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef LORAWANINTERFACE_H_
00019 #define LORAWANINTERFACE_H_
00020 
00021 #include "platform/Callback.h"
00022 #include "platform/ScopedLock.h"
00023 #include "LoRaWANStack.h"
00024 #include "LoRaRadio.h"
00025 #include "LoRaWANBase.h"
00026 
00027 class LoRaPHY;
00028 
00029 class LoRaWANInterface: public LoRaWANBase {
00030 
00031 public:
00032 
00033     /** Constructs a LoRaWANInterface using the LoRaWANStack instance underneath.
00034      *
00035      * Currently, LoRaWANStack is a singleton and you should only
00036      * construct a single instance of LoRaWANInterface.
00037      *
00038      * LoRaWANInterface will construct PHY based on "lora.phy" setting in mbed_app.json.
00039      *
00040      * @param radio A reference to radio object
00041      */
00042     LoRaWANInterface(LoRaRadio &radio);
00043 
00044     /** Constructs a LoRaWANInterface using the user provided PHY object.
00045 
00046      * @param radio A reference to radio object
00047      * @param phy   A reference to PHY object
00048      */
00049     LoRaWANInterface(LoRaRadio &radio, LoRaPHY &phy);
00050 
00051     virtual ~LoRaWANInterface();
00052 
00053     // From LoRaWANBase:
00054     virtual lorawan_status_t initialize(events::EventQueue *queue);
00055     virtual lorawan_status_t connect();
00056     virtual lorawan_status_t connect(const lorawan_connect_t &connect);
00057     virtual lorawan_status_t disconnect();
00058     virtual lorawan_status_t add_link_check_request();
00059     virtual void remove_link_check_request();
00060     virtual lorawan_status_t set_datarate(uint8_t data_rate);
00061     virtual lorawan_status_t enable_adaptive_datarate();
00062     virtual lorawan_status_t disable_adaptive_datarate();
00063     virtual lorawan_status_t set_confirmed_msg_retries(uint8_t count);
00064     virtual lorawan_status_t set_channel_plan(const lorawan_channelplan_t &channel_plan);
00065     virtual lorawan_status_t get_channel_plan(lorawan_channelplan_t &channel_plan);
00066     virtual lorawan_status_t remove_channel_plan();
00067     virtual lorawan_status_t remove_channel(uint8_t index);
00068     virtual int16_t send(uint8_t port, const uint8_t *data, uint16_t length, int flags);
00069     virtual int16_t receive(uint8_t port, uint8_t *data, uint16_t length, int flags);
00070     virtual int16_t receive(uint8_t *data, uint16_t length, uint8_t &port, int &flags);
00071     virtual lorawan_status_t add_app_callbacks(lorawan_app_callbacks_t *callbacks);
00072     virtual lorawan_status_t set_device_class(const device_class_t device_class);
00073     virtual lorawan_status_t get_tx_metadata(lorawan_tx_metadata &metadata);
00074     virtual lorawan_status_t get_rx_metadata(lorawan_rx_metadata &metadata);
00075     virtual lorawan_status_t get_backoff_metadata(int &backoff);
00076     virtual lorawan_status_t cancel_sending(void);
00077 
00078     void lock(void)
00079     {
00080         _lw_stack.lock();
00081     }
00082     void unlock(void)
00083     {
00084         _lw_stack.unlock();
00085     }
00086 
00087 
00088 private:
00089     typedef mbed::ScopedLock<LoRaWANInterface> Lock;
00090 
00091     LoRaWANStack _lw_stack;
00092 
00093     /** PHY object if created by LoRaWANInterface
00094      *
00095      * PHY object if LoRaWANInterface has created it.
00096      * If PHY object is provided by the application, this pointer is NULL.
00097      */
00098     LoRaPHY *_default_phy;
00099 };
00100 
00101 #endif /* LORAWANINTERFACE_H_ */