Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: xtoff2 RF24Network mbed
Fork of xtoff3 by
Verzender.cpp@6:6a82110ff393, 2018-02-19 (annotated)
- Committer:
- pietor
- Date:
- Mon Feb 19 14:44:11 2018 +0000
- Revision:
- 6:6a82110ff393
Ontvanger
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| pietor | 6:6a82110ff393 | 1 | #include "Verzender.h" |
| pietor | 6:6a82110ff393 | 2 | |
| pietor | 6:6a82110ff393 | 3 | RF24 radio(spi_MOSI, spi_MISO, spi_SCK, nrf_CE, nrf_CSN ); |
| pietor | 6:6a82110ff393 | 4 | RF24Network network(radio); |
| pietor | 6:6a82110ff393 | 5 | Timer t; |
| pietor | 6:6a82110ff393 | 6 | unsigned long packets_sent; |
| pietor | 6:6a82110ff393 | 7 | Timer t_packet; |
| pietor | 6:6a82110ff393 | 8 | |
| pietor | 6:6a82110ff393 | 9 | |
| pietor | 6:6a82110ff393 | 10 | |
| pietor | 6:6a82110ff393 | 11 | Verzender::Verzender() |
| pietor | 6:6a82110ff393 | 12 | { |
| pietor | 6:6a82110ff393 | 13 | radio.begin(); |
| pietor | 6:6a82110ff393 | 14 | network.begin(90,this_node); |
| pietor | 6:6a82110ff393 | 15 | wait_ms(2000); |
| pietor | 6:6a82110ff393 | 16 | t.start(); |
| pietor | 6:6a82110ff393 | 17 | t_packet.start(); |
| pietor | 6:6a82110ff393 | 18 | } |
| pietor | 6:6a82110ff393 | 19 | |
| pietor | 6:6a82110ff393 | 20 | |
| pietor | 6:6a82110ff393 | 21 | void Verzender::update() |
| pietor | 6:6a82110ff393 | 22 | { |
| pietor | 6:6a82110ff393 | 23 | network.update(); |
| pietor | 6:6a82110ff393 | 24 | } |
| pietor | 6:6a82110ff393 | 25 | |
| pietor | 6:6a82110ff393 | 26 | |
| pietor | 6:6a82110ff393 | 27 | |
| pietor | 6:6a82110ff393 | 28 | bool Verzender::write(payload_t message) |
| pietor | 6:6a82110ff393 | 29 | { |
| pietor | 6:6a82110ff393 | 30 | RF24NetworkHeader header_tx(other_node); |
| pietor | 6:6a82110ff393 | 31 | payload_t payload_tx; |
| pietor | 6:6a82110ff393 | 32 | payload_tx = message; |
| pietor | 6:6a82110ff393 | 33 | return network.write(header_tx,&payload_tx,sizeof(payload_tx)); |
| pietor | 6:6a82110ff393 | 34 | } |
