-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path3GPort.c
117 lines (98 loc) · 2.86 KB
/
3GPort.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/time.h>
#include "h324m.h"
unsigned char env[] =
{
0x87, 0xb2, 0x00, 0x00, 0x00, 0x87, 0xb2, 0x00, 0x00, 0x00, 0x87, 0xb2, 0x00, 0x00, 0x00,
0x87, 0xb2, 0x00, 0x00, 0x00, 0x87, 0xb2, 0x00, 0x00, 0x00, 0x87, 0xb2, 0x00, 0x00, 0x00,
0x87, 0xb2, 0x00, 0x00, 0x00, 0x87, 0xb2, 0x00, 0x00, 0x00, 0x87, 0xb2, 0x00, 0x00, 0x00,
0x87, 0xb2, 0x00, 0x00, 0x00, 0x87, 0xb2, 0x00, 0x00, 0x00, 0x87, 0xb2, 0x00, 0x00, 0x00,
0x87, 0xb2, 0x00, 0x00, 0x00, 0x87, 0xb2, 0x00, 0x00, 0x00, 0x87, 0xb2, 0x00, 0x00, 0x00,
0x87, 0xb2, 0x00, 0x00, 0x00, 0x87, 0xb2, 0x00, 0x00, 0x00, 0x87, 0xb2, 0x00, 0x00, 0x00,
0x87, 0xb2, 0x00, 0x00, 0x00, 0x87, 0xb2, 0x00, 0x00, 0x00, 0x87, 0xb2, 0x00, 0x00, 0x00,
0x87, 0xb2, 0x00, 0x00, 0x00, 0x87, 0xb2, 0x00, 0x00, 0x00, 0x87, 0xb2, 0x00, 0x00, 0x00,
0x87, 0xb2, 0x00, 0x00, 0x00, 0x87, 0xb2, 0x00, 0x00, 0x00, 0x87, 0xb2, 0x00, 0x00, 0x00,
0x87, 0xb2, 0x00, 0x00, 0x00, 0x87, 0xb2, 0x00, 0x00, 0x00, 0x87, 0xb2, 0x00, 0x00, 0x00,
0x87, 0xb2, 0x00, 0x00, 0x00, 0x87, 0xb2, 0x00, 0x00, 0x00};
/*
static int myaffiche(unsigned char *buf, int len)
{
int i,m=0;
for(i = 0; i <len; i++){
//printf("%02x ",reverse(buf[i]));
printf("%02x ",buf[i]);
if (m == 15){
printf("\n");
m = 0;
}
else m++;
}
if(len)
printf("\n");
return 0;
}
*/
const unsigned char tmplate[16][20] = {
"AT S7=45 S0=0 L1 V1 X4 &c1 E1 Q0 \r\n"
"ATZ \r\n",
"AT&F \r\n",
"AT&C1 \r\n",
"ATE1 \r\n",
"ATQ0 \r\n",
"ATV1 \r\n",
"AT+CMEE=1 \r\n",
"AT+CPBS=\"SM\" \r\n",
"AT+CBST=134,1,0 \r\n",
"AT+CLIP=1 \r\n",
"AT+CLIR=1 \r\n",
"ATS10=10 \r\n",
"ATS0=0 \r\n",
"ATS7=60 \r\n",
"ATS0=1 \r\n",
"ATD0634065160 \r\n", //Compose le numero ici
};
int main(int argc, char *argv[])
{
h324m_session *session;
session = new_session();
FILE *out, *in;
unsigned char buffer[4096];
int *fd, *fdb;
unsigned int m,n,i,k=0;
out =fopen("output.amr","wb");
fprintf(out,"#!AMR\n");
fclose(out);
out = fopen("Received.bin","wb");
in = fopen("Sent.bin","wb");
printf("AMIN RAMTIN, TUNNEL \n");
fd = open("/dev/ttyUSB2",O_RDWR);
for(i = 0; i < 15; i++){
n = write(fd,tmplate[i],strlen(tmplate[i]));
printf("%d: Ecrit %d %s\n",i,n,tmplate[i]);
usleep(50000);
bzero(buffer,256);
n = read(fd,buffer,256);
printf("Lu %d %s\n",n,buffer);
bzero(buffer,256);
}
printf("READY\n");
fdb = open("/dev/ttyUSB0",O_RDWR);
while(1){
n = read(fd,buffer,4096);
k+= n;
h324m_OnReceived(session,buffer,n);
//myaffiche(buffer,n);
fwrite(buffer,1,n,out);
// h324m_TreatPackets(session);
if(session->audiolen)
myaffiche(session->audiobuf, session->audiolen);
if (k >= 160){
k = 0;
h324m_MakePdu(session);
m = write(fdb,session->Output,160);
fwrite(session->Output,1,160,in);
}
}
}