<commit_before>#include <SPI.h>
#include "RF24.h"

/* Hardware configuration: Set up nRF24L01 radio on SPI protocol*/
RF24 radio(3, 2);   //arduino nano
//RF24 radio(10,A0); //arduino pro micro
/**********************************************************/

byte pipe[][6] = {"1Node", "2Node", "3Node", "4Node", "5Node", "6Node", "7Node"};
int msg_from_robot[2];
int msg_from_ROS[3];

int commands[2];
int robotPipe;

bool robot_online = false;

void setup() {
  Serial.begin(250000);
  Serial.println("Inicio - central");
  radio.begin();

  radio.setPALevel(RF24_PA_MAX);
  radio.setDataRate(RF24_2MBPS);
  radio.setChannel(108);

  radio.openReadingPipe(1, pipe[1]); //n1->central pelo pipe0
  radio.openReadingPipe(3, pipe[3]); //n1->central pelo pipe0
  radio.openReadingPipe(5, pipe[5]); //n1->central pelo pipe0
  radio.openReadingPipe(7, pipe[7]); //n1->central pelo pipe0
  radio.startListening();
}

void checkIfRadioIsPVariant() {
  if (radio.isPVariant()) {
    Serial.println("versao nrf24l01+");
  }
}

bool receive_data_from_robot() {
  if (radio.available()) {
    while (radio.available()) {
      radio.read(&msg_from_robot, sizeof(msg_from_robot));
    }
    return true;
  }
  return false;
}

void send_data_to_ROS() {
  Serial.println(msg_from_robot[0]); //Serial.write() may be a better choice for this
  Serial.println(msg_from_robot[1]); //Serial.write() may be a better choice for this
}

bool receive_data_from_ROS() {
  if (Serial.available()) {
    int i = 0;
    while (Serial.available()) {
      msg_from_ROS[i++] = Serial.read() - 48;
    }
    parseROStoRobot();
    return true;
  }
  return false;
}

void parseROStoRobot() {
  robotPipe = msg_from_ROS[0];
  commands[0] = msg_from_ROS[1];
  commands[1] = msg_from_ROS[2];
}

void send_data_to_robot() {
  radio.stopListening();
  radio.openWritingPipe(pipe[robotPipe]);
  robot_online = radio.write(commands, sizeof(commands));
  Serial.println(robot_online);
  radio.startListening();
}

void loop() {
  if (receive_data_from_robot())
    send_data_to_ROS();
  if (receive_data_from_ROS())
    send_data_to_robot();

  delay(10);
}

<commit_msg>Made sure the radio is working again. <commit_after>#include <SPI.h>
#include "RF24.h"

/* Hardware configuration: Set up nRF24L01 radio on SPI protocol*/
//RF24 radio(3, 2);   //arduino nano
RF24 radio(10,A0); //arduino pro micro
/**********************************************************/

byte pipe[][6] = {"1Node", "2Node", "3Node", "4Node", "5Node", "6Node", "7Node", "8Node"};
int msg_from_robot[2];
int msg_from_ROS[3];

int commands[2];
int robotPipe;

bool robot_online = false;

void setup() {
  Serial.begin(19200);
  while(!Serial)
    Serial.println("Inicio - central");
  radio.begin();

  radio.setPALevel(RF24_PA_MAX);
  radio.setDataRate(RF24_2MBPS);
  radio.setChannel(108);

  radio.openReadingPipe(1, pipe[1]); //n1->central pelo pipe0
  radio.openReadingPipe(2, pipe[3]); //n1->central pelo pipe0
  radio.openReadingPipe(3, pipe[5]); //n1->central pelo pipe0
  radio.openReadingPipe(4, pipe[7]); //n1->central pelo pipe0
  radio.startListening();
}

void checkIfRadioIsPVariant() {
  if (radio.isPVariant()) {
    Serial.println("versao nrf24l01+");
  }
}

bool receive_data_from_robot() {
  if (radio.available()) {
    while (radio.available()) {
      radio.read(&msg_from_robot, sizeof(msg_from_robot));
    }
    return true;
  }
  return false;
}

void send_data_to_ROS() {
  //Serial.println(msg_from_robot[0]); //Serial.write() may be a better choice for this
  //Serial.println(msg_from_robot[1]); //Serial.write() may be a better choice for this
}

bool receive_data_from_ROS() {
  if (Serial.available()) {
    int i = 0;
    while (i<3) {
      msg_from_ROS[i++] = Serial.read() - 48;
      Serial.println(msg_from_ROS[i-1]);
    }
    parseROStoRobot();
    return true;
  }
  return false;
}

void parseROStoRobot() {
  robotPipe = msg_from_ROS[0];
  commands[0] = msg_from_ROS[1];
  commands[1] = msg_from_ROS[2];
}

void send_data_to_robot() {
  radio.stopListening();
  radio.openWritingPipe(pipe[robotPipe]);
  robot_online = radio.write(commands, sizeof(commands));
  Serial.println(robot_online);
  radio.startListening();
}

void loop() {
  if (receive_data_from_robot())
    send_data_to_ROS();
  if (receive_data_from_ROS())
    send_data_to_robot();

  delay(10);
}


{'fraction_non_alphanumeric': 0.18181818181818182, 'fraction_numerical': 0.03360184119677791, 'mean_word_length': 4.4054726368159205, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5381493', 'n_tokens_mistral': 1714, 'n_tokens_neox': 1619, 'n_words': 318}