backup.c
int BLE_driver(){
  pid_BLE = fork();
  if (pid_BLE == 0){
    close(pipe_stm2bb[0]);
    dup2(pipe_stm2bb[1], STDOUT_FILENO);

    char MAC_addr [256];
    FILE *bctl_file = fopen("bctl.txt", "r");
    while(fgets(MAC_addr, sizeof(MAC_addr), bctl_file) != NULL);
    fclose(bctl_file);
    MAC_addr[17] = '\0'; // remove the newline at end

    const char* suffix[9] =
    {
      "/usr/bin/gatttool",
      "-b",
      "-t",
      "random",
      "--char-write-req",
      "--handle=0x0012",
      "--value=0100",
      "--listen"
    };
    execl("/usr/bin/gatttool", suffix[0], suffix[1], MAC_addr, suffix[2], suffix[3], suffix[4], suffix[5], suffix[6], suffix[7], (char *) NULL);
    return -1;
  }
  else{
    close(pipe_stm2bb[1]);
    return 0;
  }
}
////////////////////////////////////////////////////////////////////
// Process 1: Raw Data Collection (BLE)
////////////////////////////////////////////////////////////////////
Process 1: Raw Data Collection (BLE)
Process 1 : Raw Data Collection ( BLE )
int BLE_driver(){
  pid_BLE = fork();
  if (pid_BLE == 0){
    close(pipe_stm2bb[0]);
    dup2(pipe_stm2bb[1], STDOUT_FILENO);
    char MAC_addr [256];
    FILE *bctl_file = fopen("bctl.txt", "r");
    while(fgets(MAC_addr, sizeof(MAC_addr), bctl_file) != NULL);
    fclose(bctl_file);
    MAC_addr[17] = '\0'; 
    const char* suffix[9] =
    {
      "/usr/bin/gatttool",
      "-b",
      "-t",
      "random",
      "--char-write-req",
      "--handle=0x0012",
      "--value=0100",
      "--listen"
    };
    execl("/usr/bin/gatttool", suffix[0], suffix[1], MAC_addr, suffix[2], suffix[3], suffix[4], suffix[5], suffix[6], suffix[7], (char *) NULL);
    return -1;
  }
  else{
    close(pipe_stm2bb[1]);
    return 0;
  }
}
int BLE_driver ( ) { pid_BLE = fork ( ) ; if ( pid_BLE == 0 ) { close ( pipe_stm2bb [ 0 ] ) ; dup2 ( pipe_stm2bb [ 1 ] , STDOUT_FILENO ) ; char MAC_addr [ 256 ] ; FILE * bctl_file = fopen ( " " , " " ) ; while ( fgets ( MAC_addr , sizeof ( MAC_addr ) , bctl_file ) != NULL ) ; fclose ( bctl_file ) ; MAC_addr [ 17 ] = ' \0 ' ; const char * suffix [ 9 ] = { " " , " " , " " , " " , " " , " " , " " , " " } ; execl ( " " , suffix [ 0 ] , suffix [ 1 ] , MAC_addr , suffix [ 2 ] , suffix [ 3 ] , suffix [ 4 ] , suffix [ 5 ] , suffix [ 6 ] , suffix [ 7 ] , ( char * ) NULL ) ; return -1 ; } else { close ( pipe_stm2bb [ 1 ] ) ; return 0 ; } }
Process 1: Raw Data Collection (BLE)
Process 1 : Raw Data Collection ( BLE )
// remove the newline at end