nrf24-zaebalo

maks971014/nrf24-17032020/nrf24-zaebalo

No description
nrf24-zaebalo
@/nrf24-zaebalo
_cepinnumber
_cspinnumber
AutoAckboolean
режим подтверждения приёма, true вкл false выкл
delaynumber
время между попыткой достучаться
countnumber
число попыток
sizenumber
размер пакета, в байтах
address_numbernumber
адрес тунелей всего их шесть начиная от 0 до 5
speed_numbernumber
скорость передачи всего их 3 0-1MBPS 1-2MBPS 2-250KBPS
signal_strength_numbernumber
мощность сигнала 0-RF24_PA_MIN 1-RF24_PA_LOW 2-RF24_PA_HIGH 3-RF24_PA_MAX 4-RF24_PA_ERROR
nrf24-zaebalo
_cepin
_cspin
AutoAck
delay
count
size
address_number
speed_number
signal_strength_number
To use the node in your project you should have the maks971014/nrf24-17032020 library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#pragma XOD require "https://github.com/nRF24/RF24"

// Include C++ library:
{{#global}}
#include <RF24.h>
#include <SPI.h>

{{/global}}

// Our namespace should be: rf24_ll__rf24
// Reserve the space for the object.
struct State {
 // uint8_t mem[sizeof(RF24)];
  };
//using Type = RF24*; // 'Type' is assumed by xod code-generator

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
  // It should be evaluated only once on the first (setup) transaction
  if (!isSettingUp()) return; // FIXME: relax this?
  byte address[][6] = {"1Node", "2Node", "3Node", "4Node", "5Node", "6Node"};
  byte speed[][3] ={"RF24_1MBPS","RF24_2MBPS","RF24_250KBPS"};
  byte signal_strength[][5] ={"RF24_PA_MIN","RF24_PA_LOW","RF24_PA_HIGH","RF24_PA_MAX","RF24_PA_ERROR"};
  auto state = getState(ctx);

  // var names are valid c++ because we got them from the arglist of the c++ constructor
  auto _cepin = static_cast<int> (getValue<input__cepin>(ctx)); // int
  auto _cspin = static_cast<int> (getValue<input__cspin>(ctx)); // int
  auto AutoAck = static_cast<bool> (getValue<input_AutoAck>(ctx)); // bool
  auto delay = static_cast<int> (getValue<input_delay>(ctx)); // int
  auto count = static_cast<int> (getValue<input_count>(ctx)); // int
  auto size = static_cast<int> (getValue<input_size>(ctx)); // int
  auto number_address = static_cast<int> (getValue<input_address_number>(ctx)); // int
  auto signal = static_cast<int> (getValue<input_signal_strength_number>(ctx)); // int
  auto number_speed = static_cast<int> (getValue<input_speed_number>(ctx)); // int


  
  RF24 radio( _cepin, _cspin );
  radio.begin(); //активировать модуль
  radio.setAutoAck(AutoAck);         //режим подтверждения приёма, 1 вкл 0 выкл
  radio.setRetries(delay, count);    //(время между попыткой достучаться, число попыток)
  radio.enableAckPayload();    //разрешить отсылку данных в ответ на входящий сигнал
  radio.setPayloadSize(size);     //размер пакета, в байтах

  radio.openWritingPipe(address[number_address]);   //мы - труба 0, открываем канал для передачи данных
  radio.setChannel(0x60);  //выбираем канал (в котором нет шумов!)

  radio.setPALevel (signal_strength[signal]); //уровень мощности передатчика. На выбор RF24_PA_MIN, RF24_PA_LOW, RF24_PA_HIGH, RF24_PA_MAX
  radio.setDataRate (RF24_1MBPS); //скорость обмена. На выбор RF24_2MBPS, RF24_1MBPS, RF24_250KBPS
  //должна быть одинакова на приёмнике и передатчике!
  //при самой низкой скорости имеем самую высокую чувствительность и дальность!!
  radio.powerUp(); //начать работу
  radio.stopListening();  //не слушаем радиоэфир, мы передатчик

}