RF24Network Send example program.

Dependencies:   xtoff RF24Network mbed

Fork of RF24Network_Send by Akash Vibhute

Verzender.h

Committer:
pietor
Date:
2018-03-21
Revision:
11:2aa84e063c49
Parent:
10:875812a04307
Child:
12:38c5efed7950

File content as of revision 11:2aa84e063c49:

#ifndef Verzender_h
#define Verzender_h
#include "mbed.h"
#include <RF24Network.h>
#include <RF24.h>

#define nrf_CE      p9
#define nrf_CSN     p8
#define spi_SCK     p7
#define spi_MOSI    p5
#define spi_MISO    p6

#define INIT            '1'
#define TARE            '2'
#define TARE_FIRST      '3'
#define TARE_COMPLETE   '4'
#define TARE_ERROR      '5'
#define POSITION        '6'
#define POSITION_WAIT   '7'
#define POSITION_ERROR  '8'


#ifdef PRINT_ENABLE
    #define IF_PRINT_ENABLE(x) ({x;})
    #else
    #define IF_PRINT_ENABLE(x)
    #endif

//Identificatie verzender/ontvanger
const uint16_t this_node = 01;
const uint16_t other_node = 00;

struct payload_t {
    bool reedsensor;
    float gram;
    bool messageAvailable;
    char messageIndex;
};

enum State {State_init,
            State_tare,
            State_position,
            State_read,
            State_receive,
            State_calibrate
           };

struct state_Packet {
    char setstate;
};


class Verzender
{
private:


public:
    Verzender();
    
    /**
    Update to receive a message available for this node
    */
    void update();
    
    
    /**
        Send a message to the receiver
    
        @param message of type payload_t
    */
    bool write(payload_t message);
    
    
    /**
    Test whether there is a message available for this node
    */
    bool available();
    
    
    /**
    Read a message to the receiver

    @return message of type state_packet
    */
    state_Packet read();
    
    
    /*messageIndex:
        0: Nothing wrong
        1: Tare first
        2: Error on Position
        3: Bad Tare value (<2.5V)
*/
    void sendMessage(char index);
};

#endif