Skip to content

Commit 4035b45

Browse files
Szynkaarlubos
authored andcommitted
samples: esb: improve samples output
Make PTX sample print number of TX attempts. PRX samples now periodically put data into TX fifo. Signed-off-by: Szymon Antkowiak <[email protected]>
1 parent 5d2f2b5 commit 4035b45

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

samples/esb/esb_prx/src/main.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ LOG_MODULE_REGISTER(esb_prx, CONFIG_ESB_PRX_APP_LOG_LEVEL);
3030

3131
static struct esb_payload rx_payload;
3232
static struct esb_payload tx_payload = ESB_CREATE_PAYLOAD(0,
33-
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17);
33+
0x00, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17);
3434

3535
static void leds_update(uint8_t value)
3636
{
@@ -45,6 +45,8 @@ static void leds_update(uint8_t value)
4545

4646
void event_handler(struct esb_evt const *event)
4747
{
48+
int err;
49+
4850
switch (event->evt_id) {
4951
case ESB_EVENT_TX_SUCCESS:
5052
LOG_DBG("TX SUCCESS EVENT");
@@ -53,8 +55,6 @@ void event_handler(struct esb_evt const *event)
5355
LOG_DBG("TX FAILED EVENT");
5456
break;
5557
case ESB_EVENT_RX_RECEIVED:
56-
int err;
57-
5858
while ((err = esb_read_rx_payload(&rx_payload)) == 0) {
5959
LOG_DBG("Packet received, len %d : "
6060
"0x%02x, 0x%02x, 0x%02x, 0x%02x, "
@@ -239,21 +239,20 @@ int main(void)
239239
}
240240

241241
LOG_INF("Initialization complete");
242-
243-
err = esb_write_payload(&tx_payload);
244-
if (err) {
245-
LOG_ERR("Write payload, err %d", err);
246-
return 0;
247-
}
248-
249-
LOG_INF("Setting up for packet receiption");
242+
LOG_INF("Setting up for packet reception");
250243

251244
err = esb_start_rx();
252245
if (err) {
253246
LOG_ERR("RX setup failed, err %d", err);
254247
return 0;
255248
}
256249

257-
/* return to idle thread */
258-
return 0;
250+
while (true) {
251+
err = esb_write_payload(&tx_payload);
252+
if (err) {
253+
LOG_WRN("Write payload, err %d", err);
254+
}
255+
tx_payload.data[0]++;
256+
k_msleep(550);
257+
}
259258
}

samples/esb/esb_ptx/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void event_handler(struct esb_evt const *event)
4444

4545
switch (event->evt_id) {
4646
case ESB_EVENT_TX_SUCCESS:
47-
LOG_DBG("TX SUCCESS EVENT");
47+
LOG_DBG("TX SUCCESS EVENT %u attempts", event->tx_attempts);
4848
break;
4949
case ESB_EVENT_TX_FAILED:
5050
LOG_DBG("TX FAILED EVENT");

0 commit comments

Comments
 (0)