<commit_before>#include <ble.h>
#include <led.h>
#include <stdio.h>
#include <string.h>
#include <timer.h>

/*
 * BLE Demo Application
 * Active scanner for BLE advertisements
 */

#define BUF_SIZE 39
unsigned char scan[BUF_SIZE] = { 0 };

static void callback(__attribute__((unused)) int unused0,
                     __attribute__((unused)) int unused1, __attribute__((unused)) int unused2,
                     __attribute__((unused)) void* ud)
{
  for (int i = 0; i < BUF_SIZE; i++) {
    printf("%02x ", scan[i]);
  }
  printf("\r\n");
}

int main(void)
{
  int err;

  printf("BLE Scanner\r\n");

  // using the pre-configured adv interval
  err = ble_adv_scan(scan, BUF_SIZE, callback);
  if (err < 0) {
    printf("ble_adv_start error %d\r\n", err);
  }

  return 0;
}<commit_msg>added a very simple trait and modified the userapp a bit<commit_after>#include <ble.h>
#include <led.h>
#include <stdio.h>
#include <string.h>
#include <timer.h>

/*
 * BLE Demo Application
 * Active scanner for BLE advertisements
 */

bool isDetected(void);
bool listFull(void);
bool validAdType(int);
void printList(void);

#define BUF_SIZE 39
#define MAX_DEVICES 50

struct Vector {
   unsigned char (*data)[BUF_SIZE];
   int size;
};

// global variables
unsigned char scan[BUF_SIZE] = {0};
unsigned char *data[MAX_DEVICES] = {0};
int last = 0;
struct Vector scan_list = {.data = &data[0], .size = 0};

static void callback(__attribute__((unused)) int unused0,
                     __attribute__((unused)) int unused1,
                     __attribute__((unused)) int unused2,
                     __attribute__((unused)) void* ud) {

    if(!listFull() && validAdType(scan[0]) && !isDetected()) {
        memcpy(scan_list.data[scan_list.size], scan, BUF_SIZE);
        scan_list.size += 1;
    }
    if (last != scan_list.size) {
        printList();
        last = scan_list.size;
    }
}

int main(void)
{
  int err;

  printf("BLE Scanner\r\n");

  // using the pre-configured adv interval
  err = ble_adv_scan(scan, BUF_SIZE, callback);
  if (err < 0) {
    printf("ble_adv_start error %d\r\n", err);
  }

  return 0;
}

bool isDetected(void) {
    for(int i = 0; i < scan_list.size; i++) {
        if(memcmp(scan_list.data[i], scan, BUF_SIZE) == 0) {
            return true;
        }
    }
    return false;
}

void printList(void) {
        printf("--------SCANNING--------------------------------------------\r\n");
        for(int i = 0; i < scan_list.size; i++)  {
            printf("DEVICE #%d\r\n", i);
            for(int j = 0; j < BUF_SIZE; j++) {
                printf("%02x ", scan_list.data[i][j]);
            }
            printf("\r\n");
        }
        printf("----------END------------------------------------------------\r\n\n");
}

bool validAdType(int type) {
    return type <= 0x06;
}

bool listFull(void) {
    return scan_list.size >= MAX_DEVICES;
}
{'fraction_non_alphanumeric': 0.18491484184914841, 'fraction_numerical': 0.01251303441084463, 'mean_word_length': 2.342624854819977, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 14, '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': '4502169', 'n_tokens_mistral': 1014, 'n_tokens_neox': 975, 'n_words': 243}