-
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathpipe.c
More file actions
26 lines (21 loc) · 552 Bytes
/
Copy pathpipe.c
File metadata and controls
26 lines (21 loc) · 552 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#define _POSIX_C_SOURCE 2
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void send(FILE * fp, char * command) {
fprintf(fp, "%s\n", command);
fflush(fp);
sleep(5);
}
int main() {
FILE *fp = popen("gatttool -b 96:90:16:63:2D:25 -I", "w");
if (fp == NULL) return 1;
sleep(10);
send(fp, "connect");
send(fp, "char-write-req 0x0010 6b7570");
send(fp, "disconnect");
send(fp, "exit");
// Можно оставить gatttool открытым или закрыть
pclose(fp);
return 0;
}