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

RF24 radio(9,10);

const uint64_t pipes[2] = { 0xF0F0F0F001LL, 0xF0F0F0F002LL };
const byte shortAddr = 0x02;
int led = 13;
void setup(void)
{
  Serial.begin(57600);

  radio.begin();
  //radio.setChannel(0x4b);
  radio.setAutoAck(false);
  radio.setRetries(15,15);
  radio.setPALevel(RF24_PA_MAX);
  radio.openReadingPipe(1,pipes[1]);
  radio.openWritingPipe(pipes[0]);
  
  radio.startListening();
  
  // Testing switch on/off
   pinMode(led, OUTPUT);  
 
  
  
}

void loop(void)
{
  byte command[32] ;
  byte *ptr;
  ptr = &command[0];
  if ( radio.available() )
    {
     
      bool done = false;
      while (!done)
      {
        done = radio.read( ptr, sizeof(byte[32]) );
        Serial.println(ptr[1]);
	// Delay just a little bit to let the other unit
	// make the transition to receiver
	delay(20);
      }
      runCommand(ptr);
      Serial.println(ptr[3]);
      radio.stopListening();
      radio.write(ptr, sizeof(byte[32]));
      radio.startListening();
    }

}
bool runCommand(byte *ptr)
{
  Serial.println(ptr[1]);
  Serial.println(ptr[2]);
  Serial.println(ptr[3]);
  switch (ptr[1])
  {
    case 0:
      break;
    case 1:
      if (ptr[3]== 0x00)
      {
        switchOnLight(ptr);
      }
      break;
    case 2:
      if (ptr[3]== 0x00)
      {
        switchOffLight(ptr);
      }
      break;
  }

}

byte readTemp(void){}
byte readHum(void){}
byte readLight(void){}
bool switchOnLight(byte* ptr)
{
  digitalWrite(led, HIGH);
  ptr[3] = 0xFF;
}
bool switchOffLight(byte* ptr){
  digitalWrite(led, LOW);
  ptr[3] = 0xFF;
}<commit_msg>SensorBoard: filling some packet fields<commit_after>#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"

RF24 radio(9,10);

const uint64_t pipes[2] = { 0xF0F0F0F001LL, 0xF0F0F0F002LL };
const byte shortAddr = 0x02;
int led = 13;
void setup(void)
{
  Serial.begin(57600);

  radio.begin();
  radio.setAutoAck(false);
  radio.setRetries(15,15);
  radio.setPALevel(RF24_PA_MAX);
  radio.openReadingPipe(1,pipes[1]);
  radio.openWritingPipe(pipes[0]);
  
  radio.startListening();
  
  // Testing switch on/off
   pinMode(led, OUTPUT);  
 
  
  
}

void loop(void)
{
  char command[32] ;
  char *ptr;
  ptr = &command[0];
  if ( radio.available() )
    {
     
      bool done = false;
      while (!done)
      {
        done = radio.read( ptr, sizeof(char[32]) );
        delay(20);
      }
      runCommand(ptr);
      Serial.println(ptr[12]);
      
      radio.stopListening();
      radio.write(ptr, sizeof(byte[32]));
      radio.startListening();
    }

}
void runCommand(char *ptr)
{
  Serial.println(ptr[10]);
  switch (ptr[10])
  {
    case 0:
      break;
    case 1:
      if (ptr[12]== 0x00){
        switchOnLight(ptr);
      }
      break;
    case 2:
      if (ptr[12]== 0x00)
      {
        switchOffLight(ptr);
      }
      break;
  }

}
void readAllSensors(char* ptr){
  readTemp(ptr);
  readHum(ptr);
  readLum(ptr);
  
}
void readTemp(char* ptr){
  ptr[12] = 0xFF;
  ptr[13] = 0x02;
}
void readHum(char* ptr){
  ptr[12] = 0xFF;
  ptr[14] = 0x03;
}
void readLum(char* ptr){
  ptr[12] = 0xFF;
  ptr[15] = 0xFF;

}
void switchOnLight(char* ptr)
{
  digitalWrite(led, HIGH);
  ptr[12] = 0xFF;
  ptr[16] = 0xFF;
}
bool switchOffLight(char* ptr){
  digitalWrite(led, LOW);
  ptr[12] = 0xFF;
  ptr[16] = 0xFF;
}
{'fraction_non_alphanumeric': 0.15895610913404506, 'fraction_numerical': 0.05575326215895611, 'mean_word_length': 2.7856341189674523, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1302705', 'n_tokens_mistral': 1466, 'n_tokens_neox': 1355, 'n_words': 256}