summaryrefslogtreecommitdiff
path: root/fw/esp32/components/eos/include/cell.h
blob: af2dda82f31e64d353d50644edc010aa1af2f7d8 (plain)
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
115
#include <sys/types.h>
#include <stdint.h>

#define EOS_CELL_MTYPE_DEV              0x10
#define EOS_CELL_MTYPE_VOICE            0x20
#define EOS_CELL_MTYPE_SMS              0x30
#define EOS_CELL_MTYPE_CBS              0x40
#define EOS_CELL_MTYPE_USSD             0x50
#define EOS_CELL_MTYPE_PDP              0x60

#define EOS_CELL_MTYPE_MASK             0xf0
#define EOS_CELL_MAX_MTYPE              8

/* EOS_CELL_MTYPE_DEV subtypes */
#define EOS_CELL_MTYPE_STATUS           1
#define EOS_CELL_MTYPE_UART_DATA        2
#define EOS_CELL_MTYPE_UART_TAKE        3
#define EOS_CELL_MTYPE_UART_GIVE        4
#define EOS_CELL_MTYPE_RESET            5

#define EOS_CELL_MTYPE_VOICE_PCM        1
#define EOS_CELL_MTYPE_VOICE_DIAL       2
#define EOS_CELL_MTYPE_VOICE_RING       3
#define EOS_CELL_MTYPE_VOICE_ANSWER     4
#define EOS_CELL_MTYPE_VOICE_HANGUP     5
#define EOS_CELL_MTYPE_VOICE_BEGIN      6
#define EOS_CELL_MTYPE_VOICE_END        7
#define EOS_CELL_MTYPE_VOICE_MISS       8
#define EOS_CELL_MTYPE_VOICE_BUSY       9
#define EOS_CELL_MTYPE_VOICE_ERR        10

#define EOS_CELL_MTYPE_SMS_MSG          1
#define EOS_CELL_MTYPE_SMS_LIST         2
#define EOS_CELL_MTYPE_SMS_LIST_ITEM    3

#define EOS_CELL_MTYPE_USSD_REQUEST     1
#define EOS_CELL_MTYPE_USSD_REPLY       2
#define EOS_CELL_MTYPE_USSD_CANCEL      3

#define EOS_CELL_MTYPE_PDP_GET_APN      1
#define EOS_CELL_MTYPE_PDP_GET_USR      2
#define EOS_CELL_MTYPE_PDP_GET_PWD      3
#define EOS_CELL_MTYPE_PDP_SET_APN      4
#define EOS_CELL_MTYPE_PDP_SET_USR      5
#define EOS_CELL_MTYPE_PDP_SET_PWD      6
#define EOS_CELL_MTYPE_PDP_CONNECT      7
#define EOS_CELL_MTYPE_PDP_DISCONNECT   8

#define EOS_CELL_STATUS_RESET           0
#define EOS_CELL_STATUS_IDLE            1
#define EOS_CELL_STATUS_RELAY           2
#define EOS_CELL_STATUS_PPP             3

#define EOS_CELL_SMS_ADDRTYPE_INTL      1
#define EOS_CELL_SMS_ADDRTYPE_ALPHA     2
#define EOS_CELL_SMS_ADDRTYPE_OTHER     3

#define EOS_CELL_PDP_SIZE_APN           64
#define EOS_CELL_PDP_SIZE_USR           64
#define EOS_CELL_PDP_SIZE_PWD           64
#define EOS_CELL_PDP_SIZE_ARG           64

#define EOS_CELL_UART_MODE_NONE         0
#define EOS_CELL_UART_MODE_ATCMD        1
#define EOS_CELL_UART_MODE_PPP          2
#define EOS_CELL_UART_MODE_RELAY        3

#define EOS_CELL_MAX_USSD_STR           128
#define EOS_CELL_MAX_DIAL_STR           16

#define EOS_CELL_UART_SIZE_BUF          1024

void eos_cell_init(void);

void eos_modem_init(void);
int eos_modem_atinit(void);
void eos_modem_flush(void);
size_t eos_modem_write(void *data, size_t size);
size_t eos_modem_read(void *data, size_t size, uint32_t timeout);
int eos_modem_readln(char *buf, size_t buf_size, uint32_t timeout);
int eos_modem_resp(char *ok_str, char *err_str, uint32_t timeout);
int eos_modem_present(void);
uint8_t eos_modem_get_mode(void);
size_t eos_modem_get_status(unsigned char *buffer);
int eos_modem_set_mode(uint8_t mode);
int eos_modem_take(uint32_t timeout);
void eos_modem_give(void);
void eos_modem_sleep(void);
void eos_modem_deep_sleep(void);
void eos_modem_wake(uint8_t source, uint8_t mode);
int eos_modem_reset(void);

void eos_ppp_get_apn(char *apn);
void eos_ppp_set_apn(char *apn);
void eos_ppp_get_usr(char *usr);
void eos_ppp_set_usr(char *usr);
void eos_ppp_get_pwd(char *pwd);
void eos_ppp_set_pwd(char *pwd);
int eos_ppp_connect(void);
void eos_ppp_disconnect(void);

void eos_cell_pcm_init(void);
ssize_t eos_cell_pcm_read(unsigned char *data, size_t size);
int eos_cell_pcm_push(unsigned char *data, size_t size);
void eos_cell_pcm_start(void);
void eos_cell_pcm_stop(void);

void eos_cell_voice_handler(unsigned char mtype, unsigned char *buffer, uint16_t buf_len);
void eos_cell_sms_handler(unsigned char mtype, unsigned char *buffer, uint16_t buf_len);
void eos_cell_ussd_handler(unsigned char mtype, unsigned char *buffer, uint16_t buf_len);
void eos_cell_pdp_handler(unsigned char mtype, unsigned char *buffer, uint16_t buf_len);

void eos_cell_voice_init(void);
void eos_cell_sms_init(void);
void eos_cell_ussd_init(void);