Skip to content

Commit eb79ee6

Browse files
committed
0.4.3 update
1 parent 7a77ba7 commit eb79ee6

File tree

6 files changed

+27
-11
lines changed

6 files changed

+27
-11
lines changed

history.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Release History
22
===============
33

4+
## 0.4.3
5+
6+
- changed LDL::Device so that worker thread is scheduled to run when a radio ISR
7+
event is received
8+
49
## 0.4.2
510

611
- fixed RegTcxo bug again: got the mapping backwards in 0.4.1

version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.4.2
1+
0.4.3

wrappers/mbed/big_device.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ using namespace LDL;
3030

3131
Device::Device(Store &store, SM &sm, Radio &radio) :
3232
mac(store, sm, radio),
33-
worker_thread(1024U)
33+
worker_thread(1024U),
34+
radio(radio)
3435
{
3536
}
3637

@@ -198,6 +199,13 @@ Device::notify_api()
198199
api.release();
199200
}
200201

202+
void
203+
Device::handle_radio_event(enum ldl_radio_event ev)
204+
{
205+
mac.handle_radio_event(ev);
206+
do_work();
207+
}
208+
201209
/* public methods *****************************************************/
202210

203211
bool
@@ -209,6 +217,9 @@ Device::start(enum ldl_region region)
209217

210218
if(mac.start(region)){
211219

220+
// override the callback set by mac so we can intercept the events
221+
radio.set_event_handler(callback(this, &Device::handle_radio_event));
222+
212223
worker_thread.start(callback(this,&Device::worker));
213224
retval = true;
214225
}

wrappers/mbed/big_device.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ namespace LDL {
4444
Mutex mutex;
4545
Semaphore work;
4646
LowPowerTimeout timeout;
47+
Radio &radio;
4748

4849
void do_work();
4950

@@ -53,6 +54,9 @@ namespace LDL {
5354
void wait_until_api_done();
5455
void notify_api();
5556

57+
/* called by radio in ISR */
58+
void handle_radio_event(enum ldl_radio_event ev);
59+
5660
/* executed from the event queue */
5761
void do_unconfirmed(enum ldl_mac_status *retval, uint8_t port, const void *data, uint8_t len, const struct ldl_mac_data_opts *opts);
5862
void do_confirmed(enum ldl_mac_status *retval, uint8_t port, const void *data, uint8_t len, const struct ldl_mac_data_opts *opts);

wrappers/mbed/mac.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,14 @@ MAC::app_handler(void *app, enum ldl_mac_response_type type, const union ldl_mac
206206
}
207207
}
208208

209-
/* protected **********************************************************/
209+
/* public methods *****************************************************/
210210

211211
void
212212
MAC::handle_radio_event(enum ldl_radio_event event)
213213
{
214214
LDL_MAC_radioEvent(&mac, event);
215215
}
216216

217-
/* public methods *****************************************************/
218-
219217
bool
220218
MAC::start(enum ldl_region region)
221219
{
@@ -259,8 +257,6 @@ MAC::start(enum ldl_region region)
259257

260258
arg.session = (session_size == sizeof(session)) ? &session : NULL;
261259

262-
radio.set_event_handler(callback(this, &MAC::handle_radio_event));
263-
264260
LDL_MAC_init(&mac, region, &arg);
265261

266262
/* apply TTN fair access policy
@@ -275,6 +271,8 @@ MAC::start(enum ldl_region region)
275271
* */
276272
LDL_MAC_setMaxDCycle(&mac, 12U);
277273

274+
radio.set_event_handler(callback(this, &MAC::handle_radio_event));
275+
278276
run_state = ON;
279277

280278
return true;

wrappers/mbed/mac.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,14 @@ namespace LDL {
6060

6161
static void app_handler(void *app, enum ldl_mac_response_type type, const union ldl_mac_response_arg *arg);
6262

63-
/* called by radio in ISR */
64-
void handle_radio_event(enum ldl_radio_event event);
65-
6663
static uint32_t _ticks(void *app);
6764
static uint32_t _rand(void *app);
6865
static uint8_t _get_battery_level(void *app);
6966

7067
public:
7168

72-
void do_process();
69+
/* called by radio in ISR */
70+
void handle_radio_event(enum ldl_radio_event event);
7371

7472
MAC(Store& store, SM& sm, Radio& radio);
7573

0 commit comments

Comments
 (0)