blob: 9cd6e8f294ad9e2f3a46d5c6458ba0bccd8c4121 [file] [log] [blame]
liubin281ac462023-07-19 14:22:54 +08001
2#ifndef __QL_AT_H__
3#define __QL_AT_H__
4
5//#include <stdint.h>
6#include <string.h>
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#define TRUE 1
13#define FALSE 0
14
15#define BUF_LEN 1024
16
17#define MAX_URC_EVENT_HANDLER_ARRAY_SIZE 10
18
19//typedef unsigned int size_t;
20typedef int URC_EVENT_HANDLE;
21typedef void (*ql_urc_event_handle_func_t)(const char* urc_content);
22
23typedef struct
24{
25 char* urc_event;
26 ql_urc_event_handle_func_t pfun;
27} st_urc_handle_node;
28
29//--------------------------------------------------------------------------------------------------
30/**
31 * Standard result codes.
32 *
33 * @note All error codes are negative integers. They allow functions with signed
34 * integers to return non-negative values when successful or standard error codes on failure.
35 * @deprecated the result code LE_NOT_POSSIBLE is scheduled to be removed.
36 */
37//--------------------------------------------------------------------------------------------------
38typedef enum
39{
40 E_QL_OK = 0, ///< Successful.
41 E_QL_NOT_FOUND = -1, ///< Referenced item does not exist or could not be found.
42 E_QL_NOT_POSSIBLE = -2, ///< @deprecated It is not possible to perform the requested action.
43 E_QL_OUT_OF_RANGE = -3, ///< An index or other value is out of range.
44 E_QL_NO_MEMORY = -4, ///< Insufficient memory is available.
45 E_QL_NOT_PERMITTED = -5, ///< Current user does not have permission to perform requested action.
46 E_QL_FAULT = -6, ///< Unspecified internal error.
47 E_QL_COMM_ERROR = -7, ///< Communications error.
48 E_QL_TIMEOUT = -8, ///< A time-out occurred.
49 E_QL_OVERFLOW = -9, ///< An overflow occurred or would have occurred.
50 E_QL_UNDERFLOW = -10, ///< An underflow occurred or would have occurred.
51 E_QL_WOULD_BLOCK = -11, ///< Would have blocked if non-blocking behaviour was not requested.
52 E_QL_DEADLOCK = -12, ///< Would have caused a deadlock.
53 E_QL_FORMAT_ERROR = -13, ///< Format error.
54 E_QL_DUPLICATE = -14, ///< Duplicate entry found or operation already performed.
55 E_QL_BAD_PARAMETER = -15, ///< Parameter is invalid.
56 E_QL_CLOSED = -16, ///< The resource is closed.
57 E_QL_BUSY = -17, ///< The resource is busy.
58 E_QL_UNSUPPORTED = -18, ///< The underlying resource does not support this operation.
59 E_QL_IO_ERROR = -19, ///< An IO operation failed.
60 E_QL_NOT_IMPLEMENTED = -20, ///< Unimplemented functionality.
61 E_QL_UNAVAILABLE = -21, ///< A transient or temporary loss of a service or resource.
62 E_QL_TERMINATED = -22, ///< The process, operation, data stream, session, etc. has stopped.
63}E_QL_RESULT;
64
65extern const char strDelimit[];
66
67extern st_urc_handle_node g_urc_handler[];
68
69/*
70 Specify the AT port name used for sending/receiving AT cmd.
71*/
72extern int QL_AT_PortInit(char *device_path);
73
74extern void QL_AT_PortDeinit(void);
75
76/*
77 register the URC event call back, such as "+CMT: ;+CDS: ;+CBM: ;+CMTI: ;" seperated by ";" for sms.
78*/
79extern URC_EVENT_HANDLE register_urc_callback_func(const char* urc_event, ql_urc_event_handle_func_t pfun);
80
81/*
82 unregister the URC event call back.
83*/
84extern void unregister_urc_callback_func(URC_EVENT_HANDLE h_handle);
85
86
87#ifdef __cplusplus
88}
89#endif
90
91#endif //__QL_AT_H__