RF24Network Send example program.

Dependencies:   xtoff RF24Network mbed

Fork of RF24Network_Send by Akash Vibhute

Verzender.cpp

Committer:
pietor
Date:
2018-03-12
Revision:
10:875812a04307
Parent:
9:6d8c0b946259
Child:
11:2aa84e063c49

File content as of revision 10:875812a04307:

#include "Verzender.h"

RF24 radio(spi_MOSI, spi_MISO, spi_SCK, nrf_CE, nrf_CSN );
RF24Network network(radio);
unsigned long packets_sent;
Serial pc2(USBTX, USBRX);
RF24NetworkHeader header_rx;


/**
    Constructor: Initialize RF24 and RF24Network
*/
Verzender::Verzender()
{
    wait_ms(2000);
    radio.begin();
    network.begin(90, this_node);
    wait_ms(2000);
    radio.setPALevel(RF24_PA_MIN);
    radio.setDataRate(RF24_250KBPS);
}

void Verzender::update()
{
    network.update();
}


bool Verzender::write(payload_t message)
{
    RF24NetworkHeader header_tx(other_node);
    payload_t payload_tx;
    payload_tx = message;
    return network.write(header_tx,&payload_tx,sizeof(payload_tx));
}



state_Packet Verzender::read()
{
    state_Packet packet;
    network.read(header_rx,&packet,sizeof(packet));

    return packet;
}

bool Verzender::available()
{
    return network.available();
}