File tree Expand file tree Collapse file tree 7 files changed +106
-78
lines changed Expand file tree Collapse file tree 7 files changed +106
-78
lines changed Original file line number Diff line number Diff line change 20
20
*/
21
21
22
22
#include " LoRaWANInterface.h"
23
+ #include " lorastack/phy/loraphy_target.h"
23
24
24
25
using namespace events ;
25
26
26
27
LoRaWANInterface::LoRaWANInterface (LoRaRadio &radio)
28
+ : _default_phy(NULL )
27
29
{
28
- _lw_stack.bind_radio_driver (radio);
30
+ _default_phy = new LoRaPHY_region;
31
+ MBED_ASSERT (_default_phy);
32
+ _lw_stack.bind_phy_and_radio_driver (radio, *_default_phy);
33
+ }
34
+
35
+ LoRaWANInterface::LoRaWANInterface (LoRaRadio &radio, LoRaPHY &phy)
36
+ : _default_phy(NULL )
37
+ {
38
+ _lw_stack.bind_phy_and_radio_driver (radio, phy);
29
39
}
30
40
31
41
LoRaWANInterface::~LoRaWANInterface ()
32
42
{
43
+ delete _default_phy;
44
+ _default_phy = NULL ;
33
45
}
34
46
35
47
lorawan_status_t LoRaWANInterface::initialize (EventQueue *queue)
Original file line number Diff line number Diff line change 24
24
#include " LoRaRadio.h"
25
25
#include " LoRaWANBase.h"
26
26
27
+ class LoRaPHY ;
28
+
27
29
class LoRaWANInterface : public LoRaWANBase {
28
30
29
31
public:
@@ -33,9 +35,19 @@ class LoRaWANInterface: public LoRaWANBase {
33
35
* Currently, LoRaWANStack is a singleton and you should only
34
36
* construct a single instance of LoRaWANInterface.
35
37
*
38
+ * LoRaWANInterface will construct PHY based on "lora.phy" setting in mbed_app.json.
39
+ *
40
+ * @param radio A reference to radio object
36
41
*/
37
42
LoRaWANInterface (LoRaRadio &radio);
38
43
44
+ /* * Constructs a LoRaWANInterface using the user provided PHY object.
45
+
46
+ * @param radio A reference to radio object
47
+ * @param phy A reference to PHY object
48
+ */
49
+ LoRaWANInterface (LoRaRadio &radio, LoRaPHY &phy);
50
+
39
51
virtual ~LoRaWANInterface ();
40
52
41
53
/* * Initialize the LoRa stack.
@@ -508,6 +520,13 @@ class LoRaWANInterface: public LoRaWANBase {
508
520
typedef mbed::ScopedLock<LoRaWANInterface> Lock;
509
521
510
522
LoRaWANStack _lw_stack;
523
+
524
+ /* * PHY object if created by LoRaWANInterface
525
+ *
526
+ * PHY object if LoRaWANInterface has created it.
527
+ * If PHY object is provided by the application, this pointer is NULL.
528
+ */
529
+ LoRaPHY *_default_phy;
511
530
};
512
531
513
532
#endif /* LORAWANINTERFACE_H_ */
Original file line number Diff line number Diff line change @@ -98,15 +98,16 @@ LoRaWANStack::LoRaWANStack()
98
98
/* ****************************************************************************
99
99
* Public Methods *
100
100
****************************************************************************/
101
- void LoRaWANStack::bind_radio_driver (LoRaRadio &radio)
101
+ void LoRaWANStack::bind_phy_and_radio_driver (LoRaRadio &radio, LoRaPHY &phy )
102
102
{
103
103
radio_events.tx_done = mbed::callback (this , &LoRaWANStack::tx_interrupt_handler);
104
104
radio_events.rx_done = mbed::callback (this , &LoRaWANStack::rx_interrupt_handler);
105
105
radio_events.rx_error = mbed::callback (this , &LoRaWANStack::rx_error_interrupt_handler);
106
106
radio_events.tx_timeout = mbed::callback (this , &LoRaWANStack::tx_timeout_interrupt_handler);
107
107
radio_events.rx_timeout = mbed::callback (this , &LoRaWANStack::rx_timeout_interrupt_handler);
108
108
109
- _loramac.bind_radio_driver (radio);
109
+ phy.set_radio_instance (radio);
110
+ _loramac.bind_phy (phy);
110
111
111
112
radio.lock ();
112
113
radio.init_radio (&radio_events);
Original file line number Diff line number Diff line change 51
51
#include " system/lorawan_data_structures.h"
52
52
#include " LoRaRadio.h"
53
53
54
+ class LoRaPHY ;
55
+
54
56
class LoRaWANStack : private mbed ::NonCopyable<LoRaWANStack> {
55
57
56
58
public:
57
59
LoRaWANStack ();
58
60
59
- /* * Binds radio driver to PHY layer .
61
+ /* * Binds PHY layer and radio driver to stack .
60
62
*
61
63
* MAC layer is totally detached from the PHY layer so the stack layer
62
- * needs to play the role of an arbitrator. This API gets a radio driver
63
- * object from the application (via LoRaWANInterface), binds it to the PHY
64
- * layer and initialises radio callback handles which the radio driver will
64
+ * needs to play the role of an arbitrator.
65
+ * This API sets the PHY layer object to stack and bind the radio driver
66
+ * object from the application to the PHY layer.
67
+ * Also initialises radio callback handles which the radio driver will
65
68
* use in order to report events.
66
69
*
67
70
* @param radio LoRaRadio object, i.e., the radio driver
71
+ * @param phy LoRaPHY object.
68
72
*
69
73
*/
70
- void bind_radio_driver (LoRaRadio &radio);
74
+ void bind_phy_and_radio_driver (LoRaRadio &radio, LoRaPHY &phy );
71
75
72
76
/* * End device initialization.
73
77
* @param queue A pointer to an EventQueue passed from the application.
You can’t perform that action at this time.
0 commit comments