Mistake on this page?
Report an issue in GitHub or email us
UBLOX_AT_CellularStack.h
1 /*
2  * Copyright (c) 2018, Arm Limited and affiliates.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #ifndef UBLOX_AT_CELLULARSTACK_H_
18 #define UBLOX_AT_CELLULARSTACK_H_
19 
20 #include <chrono>
21 
22 #include "AT_CellularStack.h"
23 #include "CellularUtil.h"
24 #include "rtos/ThisThread.h"
25 #include "drivers/Timer.h"
26 
27 using namespace std::chrono;
28 
29 namespace mbed {
30 
32 public:
33  UBLOX_AT_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device);
34  virtual ~UBLOX_AT_CellularStack();
35 
36 #ifndef UBX_MDM_SARA_R41XM
37  virtual nsapi_error_t get_ip_address(SocketAddress *address);
38 #endif
39 
40  virtual nsapi_error_t gethostbyname(const char *host,
41  SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC, const char *interface_name = NULL);
42 
43 protected:
44  virtual nsapi_error_t socket_listen(nsapi_socket_t handle, int backlog);
45 
46  virtual nsapi_error_t socket_accept(nsapi_socket_t server,
47  nsapi_socket_t *handle, SocketAddress *address = 0);
48 
49  /** The profile to use (on board the modem).
50  */
51 #define PROFILE 0
52 
53  /** Socket "unused" value.
54  */
55  static const int SOCKET_UNUSED = -1;
56 
57  /** Socket timeout value in milliseconds.
58  * Note: the sockets layer above will retry the
59  * call to the functions here when they return NSAPI_ERROR_WOULD_BLOCK
60  * and the user has set a larger timeout or full blocking.
61  */
62  static constexpr seconds SOCKET_TIMEOUT = 1s;
63 
64  /** The maximum number of bytes in a packet that can be write/read from
65  * the AT interface in one go.
66  */
67  static const int UBLOX_MAX_PACKET_SIZE = 1024;
68 
69  virtual nsapi_error_t create_socket_impl(CellularSocket *socket);
70 
71  virtual nsapi_error_t socket_connect(nsapi_socket_t handle, const SocketAddress &address);
72 
73  virtual nsapi_size_or_error_t socket_sendto_impl(CellularSocket *socket, const SocketAddress &address,
74  const void *data, nsapi_size_t size);
75 
76  virtual nsapi_size_or_error_t socket_recvfrom_impl(CellularSocket *socket, SocketAddress *address,
77  void *buffer, nsapi_size_t size);
78 
79  virtual nsapi_error_t socket_close_impl(int sock_id);
80 
81 private:
82  // URC handlers
83  void UUSORD_URC();
84  void UUSORF_URC();
85  void UUSOCL_URC();
86  void UUPSDD_URC();
87 
88  /** Find a socket from the list.
89  *
90  * @param id Socket ID.
91  * @return Socket if True, otherwise NULL.
92  */
93  CellularSocket *find_socket(int id = SOCKET_UNUSED);
94 
95  /** Clear out the storage for a socket.
96  *
97  * @param id Cellular Socket.
98  * @return None
99  */
100  void clear_socket(CellularSocket *socket);
101 };
102 } // namespace mbed
103 #endif /* UBLOX_AT_CELLULARSTACK_H_ */
Class AT_CellularStack.
void * nsapi_socket_t
Opaque handle for network sockets.
Definition: nsapi_types.h:207
signed int nsapi_error_t
Type used to represent error codes.
Definition: nsapi_types.h:95
signed int nsapi_size_or_error_t
Type used to represent either a size or error passed through sockets.
Definition: nsapi_types.h:106
SocketAddress class.
Definition: SocketAddress.h:36
Class AT_CellularDevice.
unsigned int nsapi_size_t
Type used to represent the size of data passed through sockets.
Definition: nsapi_types.h:99
Definition: ATHandler.h:46
Class for sending AT commands and parsing AT responses.
Definition: ATHandler.h:70
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.