RF24Network Send example program.

Dependencies:   xtoff RF24Network mbed

Fork of RF24Network_Send by Akash Vibhute

Committer:
pietor
Date:
Mon Mar 12 11:02:12 2018 +0000
Revision:
10:875812a04307
Parent:
9:6d8c0b946259
Child:
11:2aa84e063c49
Verzender 12/03

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pietor 5:e6067799a414 1 #ifndef Verzender_h
pietor 5:e6067799a414 2 #define Verzender_h
pietor 5:e6067799a414 3 #include "mbed.h"
pietor 5:e6067799a414 4 #include <RF24Network.h>
pietor 5:e6067799a414 5 #include <RF24.h>
pietor 5:e6067799a414 6
pietor 5:e6067799a414 7 #define nrf_CE p9
pietor 5:e6067799a414 8 #define nrf_CSN p8
pietor 5:e6067799a414 9 #define spi_SCK p7
pietor 5:e6067799a414 10 #define spi_MOSI p5
pietor 5:e6067799a414 11 #define spi_MISO p6
pietor 5:e6067799a414 12
pietor 10:875812a04307 13 #ifdef PRINT_ENABLE
pietor 10:875812a04307 14 #define IF_PRINT_ENABLE(x) ({x;})
pietor 10:875812a04307 15 #else
pietor 10:875812a04307 16 #define IF_PRINT_ENABLE(x)
pietor 10:875812a04307 17 #endif
pietor 10:875812a04307 18
pietor 9:6d8c0b946259 19
pietor 9:6d8c0b946259 20 //Identificatie verzender/ontvanger
pietor 5:e6067799a414 21 const uint16_t this_node = 01;
pietor 5:e6067799a414 22 const uint16_t other_node = 00;
pietor 8:62b4607c44ca 23
pietor 5:e6067799a414 24 struct payload_t {
pietor 5:e6067799a414 25 bool reedsensor;
pietor 7:cbdbaf825b4a 26 float milligram;
pietor 5:e6067799a414 27 };
pietor 5:e6067799a414 28
pietor 6:03ba3e18ced2 29 enum State {State_init,
pietor 6:03ba3e18ced2 30 State_tare,
pietor 6:03ba3e18ced2 31 State_position,
pietor 6:03ba3e18ced2 32 State_read,
pietor 10:875812a04307 33 State_receive,
pietor 10:875812a04307 34 State_calibrate
pietor 6:03ba3e18ced2 35 };
pietor 6:03ba3e18ced2 36
pietor 6:03ba3e18ced2 37 struct state_Packet {
pietor 6:03ba3e18ced2 38 State setstate;
pietor 6:03ba3e18ced2 39 };
pietor 6:03ba3e18ced2 40
pietor 6:03ba3e18ced2 41
pietor 5:e6067799a414 42 class Verzender
pietor 5:e6067799a414 43 {
pietor 5:e6067799a414 44 private:
pietor 5:e6067799a414 45
pietor 5:e6067799a414 46
pietor 5:e6067799a414 47 public:
pietor 5:e6067799a414 48 Verzender();
pietor 9:6d8c0b946259 49
pietor 9:6d8c0b946259 50 /**
pietor 9:6d8c0b946259 51 Update to receive a message available for this node
pietor 9:6d8c0b946259 52 */
pietor 5:e6067799a414 53 void update();
pietor 9:6d8c0b946259 54
pietor 9:6d8c0b946259 55
pietor 9:6d8c0b946259 56 /**
pietor 9:6d8c0b946259 57 Send a message to the receiver
pietor 9:6d8c0b946259 58
pietor 9:6d8c0b946259 59 @param message of type payload_t
pietor 9:6d8c0b946259 60 */
pietor 5:e6067799a414 61 bool write(payload_t message);
pietor 9:6d8c0b946259 62
pietor 9:6d8c0b946259 63
pietor 9:6d8c0b946259 64 /**
pietor 9:6d8c0b946259 65 Test whether there is a message available for this node
pietor 9:6d8c0b946259 66 */
pietor 6:03ba3e18ced2 67 bool available();
pietor 9:6d8c0b946259 68
pietor 9:6d8c0b946259 69
pietor 9:6d8c0b946259 70 /**
pietor 9:6d8c0b946259 71 Read a message to the receiver
pietor 9:6d8c0b946259 72
pietor 9:6d8c0b946259 73 @return message of type state_packet
pietor 9:6d8c0b946259 74 */
pietor 6:03ba3e18ced2 75 state_Packet read();
pietor 5:e6067799a414 76 };
pietor 5:e6067799a414 77
pietor 5:e6067799a414 78 #endif
pietor 5:e6067799a414 79
pietor 5:e6067799a414 80
pietor 5:e6067799a414 81
pietor 5:e6067799a414 82
pietor 5:e6067799a414 83