forked from apache/nuttx-apps
-
Notifications
You must be signed in to change notification settings - Fork 4
/
alt1250_daemon.h
173 lines (140 loc) · 5.55 KB
/
alt1250_daemon.h
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/****************************************************************************
* apps/lte/alt1250/alt1250_daemon.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __LTE_ALT1250_ALT1250_DAEMON_H__
#define __LTE_ALT1250_ALT1250_DAEMON_H__
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <queue.h>
#include <mqueue.h>
#include <semaphore.h>
#include <string.h>
#include <nuttx/net/netdev.h>
#include <nuttx/wireless/lte/lte.h>
#include <nuttx/modem/alt1250.h>
#include "alt1250_socket.h"
#include "alt1250_usockif.h"
#include "alt1250_util.h"
#include "alt1250_fwupdate.h"
#include "alt1250_sms.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* The maximum number of sockets that the ALT1250 modem can open. */
#define SOCKET_COUNT 5
#define _TX_BUFF_SIZE (1500)
#define _RX_BUFF_SIZE (1500)
#define ACCEPT_USOCK_REQUEST(dev) (!(dev)->is_usockrcvd && !(dev)->recvfrom_processing)
#define IS_USOCKREQ_RECEIVED(dev) ((dev)->is_usockrcvd)
#define MODEM_STATE(d) ((d)->modem_state)
#define MODEM_STATE_POFF(d) ((d)->modem_state = MODEM_POWER_OFF)
#define MODEM_STATE_PON(d) ((d)->modem_state = MODEM_POWER_ON)
#define MODEM_STATE_B4PON(d) ((d)->modem_state = MODEM_BEFORE_PON)
#define MODEM_STATE_B4PON_2ND(d) ((d)->modem_state = MODEM_BEFORE_PON_STAGE2)
#define MODEM_STATE_INTENTRST(d) ((d)->modem_state = MODEM_RST_INTENTIONAL)
#define MODEM_STATE_RON(d) ((d)->modem_state = MODEM_RADIO_ON)
#define MODEM_STATE_IS_RON(d) ((d)->modem_state == MODEM_RADIO_ON)
#define MODEM_STATE_IS_POFF(d) ((d)->modem_state == MODEM_POWER_OFF)
#define MODEM_STATE_IS_PON(d) ((d)->modem_state == MODEM_POWER_ON)
#define MODEM_FWVERSION(d) ((d)->fw_version)
/****************************************************************************
* Public Data Types
****************************************************************************/
enum alt1250_state_e
{
MODEM_POWER_OFF = 0,
MODEM_BEFORE_PON,
MODEM_BEFORE_PON_STAGE2,
MODEM_POWER_ON,
MODEM_RST_INTENTIONAL,
MODEM_RADIO_ON,
};
struct usrsock_request_buff_s;
struct alt1250_s
{
int usockfd;
int altfd;
int usock_enable;
int32_t scnt;
int32_t sid; /* Select ID requested to Alt1250 module.
* Negative value indicats no select request */
FAR sem_t *syncsem; /* Semaphore to synchronize LAPI Caller */
mqd_t evtq; /* Event queue to communicate "Callback task" */
struct net_driver_s net_dev;
enum alt1250_state_e modem_state;
lte_apn_setting_t apn;
char apn_name[LTE_APN_LEN];
char user_name[LTE_APN_USER_NAME_LEN];
char pass[LTE_APN_PASSWD_LEN];
lte_pdn_t o_pdn;
struct usock_s sockets[SOCKET_COUNT];
struct usrsock_request_buff_s usockreq;
bool is_usockrcvd; /* A flag indicates that daemon has already read
* usrsock request */
bool recvfrom_processing;
uint8_t tx_buff[_TX_BUFF_SIZE];
uint8_t rx_buff[_RX_BUFF_SIZE];
char fw_version[LTE_VER_NP_PACKAGE_LEN];
struct update_info_s fwup_info;
struct sms_info_s sms_info;
bool is_support_lwm2m;
int64_t lwm2m_apply_xid;
bool api_enable;
context_save_cb_t context_cb;
bool is_resuming;
};
struct alt1250_save_ctx
{
uint8_t ip_type;
uint8_t auth_type;
uint32_t apn_type;
char apn_name[LTE_APN_LEN];
char user_name[LTE_APN_USER_NAME_LEN];
char pass[LTE_APN_PASSWD_LEN];
uint32_t d_flags;
#ifdef CONFIG_NET_IPv4
in_addr_t d_ipaddr;
in_addr_t d_draddr;
in_addr_t d_netmask;
#endif
#ifdef CONFIG_NET_IPv6
net_ipv6addr_t d_ipv6addr;
net_ipv6addr_t d_ipv6draddr;
net_ipv6addr_t d_ipv6netmask;
#endif
uint16_t checksum;
};
/****************************************************************************
* Public Functions Prototypes
****************************************************************************/
#ifdef CONFIG_LTE_ALT1250_ENABLE_HIBERNATION_MODE
int alt1250_set_api_enable(FAR struct alt1250_s *dev, bool enable);
int alt1250_count_opened_sockets(FAR struct alt1250_s *dev);
int alt1250_is_api_in_progress(FAR struct alt1250_s *dev);
int alt1250_set_context_save_cb(FAR struct alt1250_s *dev,
context_save_cb_t context_cb);
int alt1250_collect_daemon_context(FAR struct alt1250_s *dev);
int alt1250_apply_daemon_context(FAR struct alt1250_s *dev,
FAR struct alt1250_save_ctx *ctx);
#endif
#endif /* __LTE_ALT1250_ALT1250_DAEMON_H__ */