-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_configuration.c
48 lines (40 loc) · 1.02 KB
/
client_configuration.c
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
#include<unistd.h>
#include<limits.h>
#include"client_protocol.h"
int main() {
char *buf = calloc(PIPE_BUF, sizeof(char));
int in_fd, out_fd;
init_fone_client();
if(send_hello(&in_fd, &out_fd) != 0) {
return 1;
}
/* Disable Echo */
write(out_fd, "ATE 0\r\n", 7);
sleep(1);
read(in_fd, buf, PIPE_BUF);
printf("Turning Echo off: %s\n", buf);
memset(buf, 0, PIPE_BUF);
/* Enable Caller ID */
write(out_fd, "AT+CLIP=1\r\n", 11);
sleep(1);
read(in_fd, buf, PIPE_BUF);
printf("Enabling Caller ID: %s\n", buf);
memset(buf, 0, PIPE_BUF);
/* Set volume = 20 */
write(out_fd, "AT+CLVL=20\r\n", 12);
sleep(1);
read(in_fd, buf, PIPE_BUF);
printf("Setting speaker volume: %s\n", buf);
memset(buf, 0, PIPE_BUF);
/* Disable SMS notifications */
write(out_fd, "AT+CNMI=2,0\r\n", 13);
sleep(1);
read(in_fd, buf, PIPE_BUF);
printf("Disable notifications on SMS events: %s\n", buf);
memset(buf, 0, PIPE_BUF);
free(buf);
return send_finish(&in_fd, &out_fd);
}