• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_AT_SUPPORT_H
17 #define OHOS_AT_SUPPORT_H
18 
19 #include <ctype.h>
20 #include <pthread.h>
21 #include <unistd.h>
22 
23 #include "telephony_log_c.h"
24 
25 #define DEFAULT_LONG_TIMEOUT 50000
26 
27 typedef struct Line {
28     struct Line *next;
29     char *data;
30 } Line;
31 
32 typedef enum {
33     VENDOR_TYPE_NONE = 0, /* indicates no cell information */
34     VENDOR_TYPE_GSM,
35     VENDOR_TYPE_LTE,
36     VENDOR_TYPE_WCDMA,
37 } VendorType; // Radio Access Technology
38 
39 typedef struct {
40     int32_t success;
41     char *result;
42     Line *head;
43     Line *last;
44 } ResponseInfo;
45 
46 typedef void (*OnNotify)(const char *s, const char *s1); // onNotify
47 
48 int32_t ATStartReadLoop(int32_t fd, OnNotify func); // at_open
49 
50 void ATCloseReadLoop(void); // at_close
51 
52 void AtSetOnUnusual(void (*onAtUnusual)(void));
53 
54 void FreeResponseInfo(ResponseInfo *resp); // free ResponseResult
55 
56 int32_t SendCommandLock(const char *command, const char *prefix, long long timeout, ResponseInfo **outResponse);
57 
58 int32_t SendCommandNetWorksLock(
59     const char *command, const char *prefix, long long timeout, ResponseInfo **outResponse);
60 
61 int32_t SendCommandSmsLock(
62     const char *command, const char *smsPdu, const char *prefix, long long timeout, ResponseInfo **outResponse);
63 
64 int32_t SendCommandNoLock(const char *command, long long timeout, ResponseInfo **outResponse);
65 
66 void SetWatchFunction(void (*watchFun)(void));
67 
68 void SetAtPauseFlag(bool isNeedPause);
69 bool GetAtPauseFlag(void);
70 
71 #endif // OHOS_AT_SUPPORT_H
72