Skip to content

Commit c5f0c3a

Browse files
committed
Add support for Quectel BC20
Signed-off-by: Ajay Bhargav <[email protected]>
1 parent 636716d commit c5f0c3a

22 files changed

+496
-207
lines changed

include/arpa/inet.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,29 @@
1717
/* Address indicating an error return. */
1818
#define INADDR_NONE ((in_addr_t) 0xffffffff)
1919

20+
#ifndef __socklen_t_defined
21+
typedef __socklen_t socklen_t;
22+
#define __socklen_t_defined
23+
#endif
24+
2025
/**
2126
* IPv4 Address structure.
2227
*/
2328
struct in_addr {
2429
in_addr_t s_addr; /**< IPv4 address binary format */
2530
};
2631

32+
/**
33+
* IPv6 Address structure
34+
*/
35+
struct in6_addr {
36+
union {
37+
uint32_t u32_addr[4];
38+
uint8_t u8_addr[16];
39+
} un;
40+
#define s6_addr un.u8_addr
41+
};
42+
2743
#ifdef __cplusplus
2844
extern "C" {
2945
#endif
@@ -78,6 +94,27 @@ uint32_t ntohl(uint32_t x);
7894
*/
7995
uint16_t ntohs(uint16_t x);
8096

97+
#if defined(PLATFORM_BC20) || defined(_DOXYGEN_)
98+
/**
99+
* Convert IPv4 and IPv6 addresses from binary to text form
100+
* @param af [in] Address family
101+
* @param src [in] Source buffer containing binary address
102+
* @param dst [out] destination buffer to store converted text
103+
* @param size [in] size of destination buffer
104+
* @return
105+
*/
106+
const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
107+
108+
/**
109+
* Convert IPv4 and IPv6 addresses from text to binary form
110+
* @param af [in] Address family
111+
* @param src [in] points to a character string containing an IPv4/IPv6 network address
112+
* @param dst [out] pointer to which to save the address in network order
113+
* @return
114+
*/
115+
int inet_pton(int af, const char *src, void *dst);
116+
#endif
117+
81118
#ifdef __cplusplus
82119
}
83120
#endif

include/fota.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* lib.h
3+
*
4+
*/
5+
6+
#ifndef INCLUDE_LIB_H_
7+
#define INCLUDE_LIB_H_
8+
9+
#ifdef __cplusplus
10+
extern "C" {
11+
#endif
12+
13+
/**
14+
* Start Firmware Update
15+
* @param [in] HTTP URL to download firmware
16+
* @return 0 on success, negative value on error
17+
*/
18+
int fota_start(const char *in_url);
19+
20+
/**
21+
* Get OTA status
22+
* @return Return 1 if FOTA in progress, 0 otherwise
23+
*/
24+
int ota_in_progress(void);
25+
26+
#ifdef __cplusplus
27+
}
28+
#endif

include/gpslib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ enum gpstype_e {
1616
GPS_TYPE_SIRF, /**< SIRF Star III GPS module */
1717
GPS_TYPE_MTK, /**< GPS/GNSS module based on Mediatek chipset */
1818
GPS_TYPE_STIRNSS,/**< GNSS module with IRNSS support based on STA80xx chipset (e.g. L89) */
19+
GPS_TYPE_UNICORE,/**< Default value for BC20 as onboard GNSS module */
1920
};
2021

2122
/**

include/hw/adc.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
* ADC channels
1111
*/
1212
enum adcch_e {
13-
ADC_CH0,/**< ADC channel 0 mapped to pin ADC0 */
14-
ADC_CH1,/**< ADC channel 1 mapped to @ref GPIO_1 */
15-
ADC_CH2,/**< ADC channel 2 mapped to @ref GPIO_21 */
16-
ADC_CH3,/**< ADC channel 3 mapped to @ref GPIO_31 */
13+
ADC_CH0,/**< ADC channel 0 */
14+
ADC_CH1,/**< ADC channel 1 */
15+
#ifndef PLATFORM_BC20
16+
ADC_CH2,/**< ADC channel 2 */
17+
ADC_CH3,/**< ADC channel 3 */
18+
#endif
1719
#if defined(PLATFORM_S20U) || defined(PLATFORM_M56)
18-
ADC_CH4,/**< ADC channel 4 mapped to @ref GPIO_32 */
19-
ADC_CH5,/**< ADC channel 5 mapped to pin ADC1 */
20+
ADC_CH4,/**< ADC channel 4 */
21+
ADC_CH5,/**< ADC channel 5 */
2022
#endif
2123
};
2224

include/hw/bluetooth.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#ifndef INC_HW_BLUETOOTH_H_
77
#define INC_HW_BLUETOOTH_H_
88

9+
#ifndef PLATFORM_BC20
910
/**
1011
* Maximum length for BT device name
1112
*/
@@ -128,4 +129,6 @@ int bt_device_unpair(const char *name);
128129
*/
129130
int bt_device_unpairall(void);
130131

132+
#endif /* PLATFORM_BC20 */
133+
131134
#endif /* INC_HW_BLUETOOTH_H_ */

include/hw/gpio.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ enum gpio_trigger_e {
5252
/**
5353
* @enum gpioname_e GPIO List
5454
* Each GPIO can be configured for alternate function via Pinmux APIs, Check "See Also" section for more information
55-
* @note GPIO number after GPIO37 are available only with S56 GSM Module
5655
*/
5756
enum gpioname_e {
57+
GPIO_0,
5858
GPIO_1,
5959
GPIO_2,
6060
GPIO_3,
@@ -78,26 +78,31 @@ enum gpioname_e {
7878
GPIO_21,
7979
GPIO_22,
8080
GPIO_23,
81+
#ifdef PLATFORM_BC20
8182
GPIO_24,
83+
GPIO_25,
84+
GPIO_26,
85+
#endif
8286
#if defined (PLATFORM_MC60) || defined(PLATFORM_S20U) || defined(PLATFORM_M56)
87+
GPIO_24,
8388
GPIO_25,
8489
GPIO_26,
8590
GPIO_27,
8691
GPIO_28,
8792
GPIO_29,
8893
GPIO_30,
8994
GPIO_31,
90-
GPIO_32,
9195
#endif
9296
#if defined(PLATFORM_S20U) || defined(PLATFORM_M56)
97+
GPIO_32,
9398
GPIO_33,
9499
GPIO_34,
95100
GPIO_35,
96101
GPIO_36,
97-
GPIO_37,
98102
#endif
99103
#if defined(PLATFORM_M56)
100104
/* S56 Module, Extra GPIO */
105+
GPIO_37,
101106
GPIO_38,
102107
GPIO_39,
103108
GPIO_40,
@@ -112,7 +117,6 @@ enum gpioname_e {
112117
GPIO_49,
113118
GPIO_50,
114119
GPIO_51,
115-
GPIO_52,
116120
#endif
117121
GPIO_PIN_MAX,
118122
};

include/hw/pwm.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@
1010
* PWM Channels
1111
*/
1212
enum pwmch_e {
13-
PWM_CH0,/**< PWM Channel 0 (available on @ref GPIO_1) */
13+
PWM_CH0,/**< PWM Channel 0 */
1414
#if !defined(PLATFORM_M66)
15-
PWM_CH1,/**< PWM Channel 1 (available on @ref GPIO_36) */
15+
PWM_CH1,/**< PWM Channel 1 */
16+
#endif
17+
#ifdef PLATFORM_BC20
18+
PWM_CH2,/**< PWM Channel 2 */
19+
PWM_CH3,/**< PWM Channel 3 */
1620
#endif
1721
};
1822

include/lib.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,6 @@ void system_gettz(char *tz, int size);
8686
*/
8787
int debug(int level, const char *fmt, ...);
8888

89-
/**
90-
* Get OTA status
91-
* @return Return 1 if FOTA in progress, 0 otherwise
92-
*/
93-
int ota_in_progress(void);
94-
9589
#ifdef __cplusplus
9690
}
9791
#endif

include/netdb.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ struct hostent {
3131
#define h_addr h_addr_list[0] /**< for backward compatibility */
3232
};
3333

34+
struct addrinfo {
35+
int ai_flags; /* Input flags. */
36+
int ai_family; /* Address family of socket. */
37+
int ai_socktype; /* Socket type. */
38+
int ai_protocol; /* Protocol of socket. */
39+
socklen_t ai_addrlen; /* Length of socket address. */
40+
struct sockaddr *ai_addr; /* Socket address of socket. */
41+
char *ai_canonname; /* Canonical name of service location. */
42+
struct addrinfo *ai_next; /* Pointer to next in list. */
43+
};
44+
3445
#ifdef __cplusplus
3546
extern "C" {
3647
#endif
@@ -66,6 +77,35 @@ struct hostent *gethostbyname(const char *name);
6677
int gethostbyname_r(const char *name, struct hostent *ret, char *buf,
6778
size_t buflen, struct hostent **result, int *h_errnop);
6879

80+
#if defined(PLATFORM_BC20) || defined(_DOXYGEN_)
81+
/**
82+
* Translates the name of a service location (for example, a host name) and/or
83+
* a service name and returns a set of socket addresses and associated
84+
* information to be used in creating a socket with which to address the
85+
* specified service. Memory for the result is allocated internally and must
86+
* be freed by calling lwip_freeaddrinfo()!
87+
* Due to a limitation in @a gethostbyname, only the first address of a host
88+
* is returned. Also, service names are not supported (only port numbers)!
89+
* @param nodename [in] descriptive name or address string of the host (may be NULL -> local address)
90+
* @param servname [in] port number as string of NULL
91+
* @param hints [in,out] structure containing input values that set socktype and protocol
92+
* @param res [in,out] pointer to a pointer where to store the result (set to NULL on failure)
93+
*/
94+
int getaddrinfo(const char *nodename,
95+
const char *servname,
96+
const struct addrinfo *hints,
97+
struct addrinfo **res);
98+
99+
/**
100+
* Frees one or more addrinfo structures returned by @a getaddrinfo, along with
101+
* any additional storage associated with those structures. If the ai_next
102+
* field of the structure is not null, the entire list of structures is freed.
103+
*
104+
* @param ai [in] struct @a addrinfo to free
105+
*/
106+
void freeaddrinfo(struct addrinfo *ai);
107+
#endif
108+
69109
#ifdef __cplusplus
70110
}
71111
#endif

include/network.h

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,22 @@ enum _net_state {
2222
/**
2323
* Network parameter structure
2424
*/
25+
#ifdef PLATFORM_BC20
26+
typedef struct {
27+
uint8_t csq; /**< Signal strength RSSI value (0:-113dBm or less to 31:-55dBm or more, 99: Not detectable) */
28+
uint8_t rscp; /**< Received signal code power */
29+
uint8_t rsrp; /**< Reference signal received quality */
30+
uint8_t rsrq; /**< Reference signal received power */
31+
} cesq_t;
32+
33+
struct netparam_t {
34+
int simstate; /**< SIM CPIN status @ref Enum_SIMState */
35+
int cereg; /**< CEREG network status @ref Enum_NetworkState */
36+
int state; /**< Internal state (for debugging) */
37+
cesq_t cesq; /**< Extended Signal quality structure */
38+
const char *apn; /**< Currently used APN as null terminted string */
39+
};
40+
#else
2541
struct netparam_t {
2642
int simstate; /**< SIM CPIN status @ref Enum_SIMState */
2743
int creg; /**< CREG GSM status @ref Enum_NetworkState */
@@ -31,6 +47,7 @@ struct netparam_t {
3147
unsigned char csq; /**< Signal strength RSSI value (0:-113dBm or less to 31:-55dBm or more, 99: Not detectable) */
3248
const char *apn; /**< Currently used APN as null terminted string */
3349
};
50+
#endif
3451

3552
#ifdef __cplusplus
3653
extern "C" {
@@ -43,14 +60,6 @@ extern "C" {
4360
*/
4461
int network_getparam(struct netparam_t *param);
4562

46-
/**
47-
* Get network status.
48-
* If socket descriptor is provided, extended network status will be provided with socket status
49-
* @param sockfd [in] Socket descriptor (optional, 0 if not used)
50-
* @return network status see @ref _net_state
51-
*/
52-
int network_getstatus(int sockfd);
53-
5463
/**
5564
* Get APN configuration stored in memory
5665
* @param apn [out] Access point name (APN)
@@ -91,6 +100,26 @@ int network_setdns(const char *pri, const char *sec);
91100
*/
92101
int network_resetdns(void);
93102

103+
#if defined(PLATFORM_BC20) || defined(_DOXYGEN_)
104+
/**
105+
* Get status of network, if its ready or not for data transaction
106+
* @return returns 1 if network ready, 0 otherwise
107+
*/
108+
int network_isready(void);
109+
110+
/**
111+
* Reset and restart network
112+
*/
113+
void network_reset(void);
114+
#else
115+
/**
116+
* Get network status.
117+
* If socket descriptor is provided, extended network status will be provided with socket status
118+
* @param sockfd [in] Socket descriptor (optional, 0 if not used)
119+
* @return network status see @ref _net_state
120+
*/
121+
int network_getstatus(int sockfd);
122+
94123
/**
95124
* Enable/Disable GPRS. GPRS is enabled by default
96125
* @param enable [in] 1 to enable, 0 to disable
@@ -109,6 +138,7 @@ int network_isgprsenable(void);
109138
* @return IP Address octets
110139
*/
111140
unsigned char *network_getlocalip(void);
141+
#endif
112142

113143
/**
114144
* Get currently used APN

0 commit comments

Comments
 (0)