drivers: modem: update altair modem

update Altair modem with the ALT1250 implementation

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
This commit is contained in:
Alin Jerpelea 2022-10-18 08:55:15 +02:00 committed by Xiang Xiao
parent 2b0ce033d7
commit 06c8e43df9
41 changed files with 16502 additions and 5471 deletions

View file

@ -10,6 +10,7 @@
# CONFIG_MMCSD_SPI is not set
# CONFIG_MTD_SMART_WEAR_LEVEL is not set
# CONFIG_STANDARD_SERIAL is not set
CONFIG_ALLOW_MIT_COMPONENTS=y
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="spresense"
CONFIG_ARCH_BOARD_COMMON=y
@ -21,6 +22,7 @@ CONFIG_ARMV7M_USEBASEPRI=y
CONFIG_BOARD_LOOPSPERMSEC=5434
CONFIG_BOOT_RUNFROMISRAM=y
CONFIG_BUILTIN=y
CONFIG_CRYPTO_MBEDTLS=y
CONFIG_CXD56_BINARY=y
CONFIG_CXD56_I2C0=y
CONFIG_CXD56_I2C=y
@ -40,16 +42,19 @@ CONFIG_FS_SMARTFS=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_INIT_ENTRYPOINT="spresense_main"
CONFIG_MBEDTLS_APPS=y
CONFIG_MBEDTLS_VERSION="2.28.0"
CONFIG_MMCSD=y
CONFIG_MMCSD_SDIO=y
CONFIG_MODEM=y
CONFIG_MODEM_ALTMDM=y
CONFIG_MODEM_ALT1250=y
CONFIG_MTD_BYTE_WRITE=y
CONFIG_MTD_PARTITION=y
CONFIG_MTD_SMART=y
CONFIG_MTD_SMART_ENABLE_CRC=y
CONFIG_MTD_SMART_SECTOR_SIZE=4096
CONFIG_NAME_MAX=128
CONFIG_NET_UDP=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_READLINE=y

View file

@ -27,6 +27,6 @@ config MODEM_U_BLOX_DEBUG
---help---
Allow the u-blox modem driver print debug information.
source "drivers/modem/altair/Kconfig"
source "drivers/modem/alt1250/Kconfig"
endif # MODEM

View file

@ -24,7 +24,7 @@ ifeq ($(CONFIG_MODEM_U_BLOX),y)
CSRCS += u-blox.c
endif
include modem/altair/Make.defs
include modem/alt1250/Make.defs
# Include modem driver build support

View file

@ -0,0 +1,33 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
menuconfig MODEM_ALT1250
bool "ALT1250 modem support"
default n
select SPI
select NET
select NETDEV_MODEM_LTE_IOCTL
---help---
Enable driver for the ALT1250 modem.
if MODEM_ALT1250
config MODEM_ALT1250_ADDITIONAL_FUNC
bool
default n
config MODEM_ALT1250_LOG_ACCESS
bool "Enable modem log access"
default n
---help---
Enables the feature to access the modem logs.
config MODEM_ALT1250_DEBUG
bool "Enable debug mode for ALT1250 modem driver"
default n
---help---
Allow the ALT1250 modem driver print debug information.
endif

View file

@ -1,5 +1,5 @@
############################################################################
# drivers/modem/altair/Make.defs
# drivers/modem/alt1250/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
@ -20,16 +20,19 @@
ifeq ($(CONFIG_MODEM),y)
ifeq ($(CONFIG_MODEM_ALTMDM),y)
ifeq ($(CONFIG_MODEM_ALT1250),y)
CSRCS += alt1250.c
CSRCS += altcom_pkt.c
CSRCS += altcom_hdlr.c
CSRCS += altcom_lwm2m_hdlr.c
CSRCS += altmdm.c
CSRCS += altmdm_event.c
CSRCS += altmdm_spi.c
CSRCS += altmdm_pm.c
CSRCS += altmdm_pm_state.c
CSRCS += altmdm_sys.c
CSRCS += altmdm_timer.c
endif
DEPPATH += --dep-path modem$(DELIM)altair
VPATH += :modem$(DELIM)altair
CFLAGS += ${shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)drivers$(DELIM)modem}
DEPPATH += --dep-path modem$(DELIM)alt1250
VPATH += :modem$(DELIM)alt1250
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)drivers$(DELIM)modem}
endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,59 @@
/****************************************************************************
* drivers/modem/alt1250/alt1250.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 __DRIVERS_MODEM_ALT1250_ALT1250_H
#define __DRIVERS_MODEM_ALT1250_ALT1250_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/wireless/lte/lte_ioctl.h>
#include <stdbool.h>
#include <stdint.h>
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: get_event_lapibuffer
*
* Description:
* Gets the buffer used in the LAPI event.
*
* Input Parameters:
* dev - An device instance of the ALT11250 driver.
* lapicmdid - ID of the LAPI command.
* inst - A pointer to an instance of the LAPI event buffer.
*
* Returned Value:
* Returns a bitmap indicating the location of the LAPI event buffer.
* If the buffer associated with the specified lapicmdid does not exist,
* NULL is returned.
*
****************************************************************************/
uint64_t get_event_lapibuffer(FAR struct alt1250_dev_s *dev,
uint32_t lapicmdid, alt_evtbuf_inst_t **inst);
#endif /* __DRIVERS_MODEM_ALT1250_ALT1250_H */

View file

@ -0,0 +1,965 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_cmd.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 __DRIVERS_MODEM_ALT1250_ALTCOM_CMD_H
#define __DRIVERS_MODEM_ALT1250_ALTCOM_CMD_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <stdbool.h>
#include <stdint.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define APICMD_ACTIVATEPDN_APNNAME_MAXLEN (101)
#define APICMD_ACTIVATEPDN_USERNAME_MAXLEN (64)
#define APICMD_ACTIVATEPDN_PASSWORD_MAXLEN (32)
#define APICMD_CELLINFO_CELLID_MIN (0)
#define APICMD_CELLINFO_CELLID_MAX (503)
#define APICMD_CELLINFO_EARFCN_MIN (0)
#define APICMD_CELLINFO_EARFCN_MAX (262143)
#define APICMD_CELLINFO_DIGIT_NUM_MIN (0)
#define APICMD_CELLINFO_DIGIT_NUM_MAX (9)
#define APICMD_CELLINFO_MCC_DIGIT (3)
#define APICMD_CELLINFO_MNC_DIGIT_MIN (2)
#define APICMD_CELLINFO_MNC_DIGIT_MAX (3)
#define APICMD_CELLINFO_GCID_MAX (16)
#define APICMD_CELLINFO_TIMEDIFF_INDEX_MAX (4095)
#define APICMD_CELLINFO_TA_MAX (1282)
#define APICMD_CELLINFO_SFN_MAX (0x03FF)
#define APICMD_CELLINFO_NEIGHBOR_CELL_NUM_MAX (32)
#define APICMD_CELLINFO_VALID_TIMEDIFFIDX (1 << 1)
#define APICMD_CELLINFO_VALID_TA (1 << 2)
#define APICMD_CELLINFO_VALID_SFN (1 << 3)
#define APICMD_CELLINFO_VALID_RSRP (1 << 4)
#define APICMD_CELLINFO_VALID_RSRQ (1 << 5)
#define APICMD_DATAALLOW_DATAALLOW_ALLOW (0)
#define APICMD_DATAALLOW_DATAALLOW_DISALLOW (1)
#define APICMD_DATAALLOW_DATAROAMALLOW_ALLOW (0)
#define APICMD_DATAALLOW_DATAROAMALLOW_DISALLOW (1)
#define APICMD_DEACTIVATEPDN_SESSIONID_MIN (0)
#define APICMD_DEACTIVATEPDN_SESSIONID_MAX (255)
#define APICMD_EDRX_ACTTYPE_NOTUSE (0) /* eDRX is not running */
#define APICMD_EDRX_ACTTYPE_ECGSMIOT (1) /* EC-GSM-IoT (A/Gb mode) */
#define APICMD_EDRX_ACTTYPE_GSM (2) /* GSM (A/Gb mode) */
#define APICMD_EDRX_ACTTYPE_IU (3) /* UTRAN (Iu mode) */
#define APICMD_EDRX_ACTTYPE_WBS1 (4) /* E-UTRAN (WB-S1 mode) */
#define APICMD_EDRX_ACTTYPE_NBS1 (5) /* E-UTRAN (NB-S1 mode) */
#define APICMD_ENTERPIN_NEWPINCODE_UNUSE (0)
#define APICMD_ENTERPIN_NEWPINCODE_USE (1)
#define APICMD_ENTERPIN_PINCODE_LEN 9
#define APICMD_ERRINFO_ERRSTR_MAX_LEN (64)
#define APICMD_IMSCAP_ENABLE (0)
#define APICMD_IMSCAP_DISABLE (1)
#define APICMD_GETSIMINFO_MCC_DIXIT_MAX (3)
#define APICMD_GETSIMINFO_MNC_DIXIT_MAX (3)
#define APICMD_GETSIMINFO_SPN_MAX_LEN (16)
#define APICMD_GETSIMINFO_ICCID_MAX_LEN (10)
#define APICMD_GETSIMINFO_IMSI_LEN (15)
#define APICMD_GETSIMINFO_GID_LEN (128)
#define APICMD_IMEI_LEN 16
#define APICMD_IMSI_LEN 16
#define APICMD_NETINFO_PDNCOUNT_MAX (5)
#define APICMD_OPERATOR_LEN 17
#define APICMD_OPERATOR_LEN_V4 33
#define APICMD_PDN_IMS_REG (0)
#define APICMD_PDN_IMS_UNREG (1)
#define APICMD_PDN_DATAALLOW_ALLOW (0)
#define APICMD_PDN_DATAALLOW_DISALLOW (1)
#define APICMD_PDN_DATAROAMALLOW_ALLOW (0)
#define APICMD_PDN_DATAROAMALLOW_DISALLOW (1)
#define APICMD_PDN_IPCOUNT_MAX (2)
#define APICMD_PDN_IPADDR_MAXLEN (40)
#define APICMD_PDN_DNSCOUNT_MAX (4)
#define APICMD_PHONENO_LEN 41
#define APICMD_PSM_TIMER_MIN (1)
#define APICMD_PSM_TIMER_MAX (31)
#define APICMD_QUALITY_DISABLE (0)
#define APICMD_QUALITY_ENABLE (1)
#define APICMD_QUALITY_RSRP_MIN (-140)
#define APICMD_QUALITY_RSRP_MAX (0)
#define APICMD_QUALITY_RSRQ_MIN (-60)
#define APICMD_QUALITY_RSRQ_MAX (0)
#define APICMD_QUALITY_SINR_MIN (-128)
#define APICMD_QUALITY_SINR_MAX (40)
#define APICMD_RAT_RES_OK (0)
#define APICMD_RAT_RES_ERR (1)
#define APICMD_RAT_RAT_DEFAULT (1)
#define APICMD_RAT_RAT_CATM (2)
#define APICMD_RAT_RAT_NBIOT (3)
#define APICMD_RAT_RAT_GSM (4)
#define APICMD_RAT_RAT_C2D (5)
#define APICMD_RAT_RAT_N2D (6)
#define APICMD_RAT_RAT_G2D (7)
#define APICMD_RAT_NOT_PERSIS (0)
#define APICMD_RAT_PERSIS (1)
#define APICMD_RAT_RAT_MODE_SINGLE (0)
#define APICMD_RAT_RAT_MODE_MULTIPLE (1)
#define APICMD_RAT_SOURCE_NONE (0)
#define APICMD_RAT_SOURCE_HOST (1)
#define APICMD_RAT_SOURCE_LWM2M (2)
#define APICMD_SET_REPCELLINFO_INTERVAL_MIN (1)
#define APICMD_SET_REPCELLINFO_INTERVAL_MAX (4233600)
#define APICMD_SET_REP_EVT_DISABLE (0)
#define APICMD_SET_REP_EVT_ENABLE (1)
#define APICMD_SET_REP_EVT_LTIME (1 << 0)
#define APICMD_SET_REP_EVT_SIMD (1 << 1)
#define APICMD_SET_REP_EVT_SIMSTATE (1 << 2)
#define APICMD_SET_REP_EVT_REGSTATE (1 << 3)
#define APICMD_SET_REP_EVT_PSMSTATE (1 << 4)
#define APICMD_SET_REP_EVT_DYNPSM (1 << 5)
#define APICMD_SET_REP_EVT_DYNEDRX (1 << 6)
#define APICMD_SET_REP_EVT_CONNPHASE (1 << 7)
#define APICMD_SET_REP_EVT_ANTITAMPER (1 << 8)
#define APICMD_SET_REP_EVT_MAX (1 << 15)
#define APICMD_SET_REP_EVT_RES_OK (0)
#define APICMD_SET_REP_EVT_RES_ERR (1)
#define APICMD_REPORT_EVT_TYPE_LTIME (0)
#define APICMD_REPORT_EVT_TYPE_SIMD (1)
#define APICMD_REPORT_EVT_TYPE_SIMSTATE (2)
#define APICMD_REPORT_EVT_TYPE_REGSTATE (3)
#define APICMD_REPORT_EVT_TYPE_PSMSTATE (4)
#define APICMD_REPORT_EVT_TYPE_DYNPSM (5)
#define APICMD_REPORT_EVT_TYPE_DYNEDRX (6)
#define APICMD_REPORT_EVT_TYPE_CONNPHASE (7)
#define APICMD_REPORT_EVT_TYPE_ANTITAMPER (8)
#define APICMD_REPORT_EVT_SIMD_REMOVAL (0)
#define APICMD_REPORT_EVT_SIMD_INSERTION (1)
#define APICMD_REPORT_EVT_SIMSTATE_DEACTIVATED (0)
#define APICMD_REPORT_EVT_SIMSTATE_SIM_INIT_WAIT_PIN_UNLOCK (1)
#define APICMD_REPORT_EVT_SIMSTATE_PERSONALIZATION_FAILED (2)
#define APICMD_REPORT_EVT_SIMSTATE_ACTIVATION_COMPLETED (3)
#define APICMD_REPORT_EVT_ALERTU_TEMP (0)
#define APICMD_REPORT_EVT_ALERTU_ANTIAMPER (1)
#define APICMD_REP_PSMST_NOT_ACTIVE (0)
#define APICMD_REP_PSMST_ACTIVE (1)
#define APICMD_REP_PSMST_ACTIVE_AND_CAMPED (2)
#define APICMD_REP_PSMST_CAMP_INTERRUPTED (3)
#define APICMD_REP_CONNPHASE_START_SCAN (0)
#define APICMD_REP_CONNPHASE_FAIL_SCAN (1)
#define APICMD_REP_CONNPHASE_ENTER_CAMPED (2)
#define APICMD_REP_CONNPHASE_CONNECTION_ESTABLISHMENT (3)
#define APICMD_REP_CONNPHASE_START_RESCAN (4)
#define APICMD_REP_CONNPHASE_ENTER_CONNECTED (5)
#define APICMD_REP_CONNPHASE_NO_SUITABLE_CELL (6)
#define APICMD_REP_CONNPHASE_REG_ATTEMPT_FAILED (7)
#define APICMD_REP_CONNPHASE_NOT_AVAIL (99)
#define APICMD_REP_CONPHASE_RAT_CATM (0)
#define APICMD_REP_CONPHASE_RAT_NBIOT (1)
#define APICMD_REP_CONPHASE_RAT_GSM (3)
#define APICMD_REP_CONPHASE_RAT_NOT_AVAIL (99)
#define APICMD_REP_CONPHASE_SCAN_MRU_ONLY (0)
#define APICMD_REP_CONPHASE_SCAN_MRU_AND_FULL_SCAN (1)
#define APICMD_REP_CONPHASE_SCAN_MRU_AND_COUNTRY_SCAN (2)
#define APICMD_REP_CONPHASE_SCAN_MRU_AND_LS (3)
#define APICMD_REP_CONPHASE_SCAN_MRU_NOT_AVAIL (99)
#define APICMD_REP_CONPHASE_SCAN_REASON_INIT_SCAN (0)
#define APICMD_REP_CONPHASE_SCAN_REASON_OUT_OF_COVERAGE (1)
#define APICMD_REP_CONPHASE_SCAN_REASON_HIGH_PRIORITY (2)
#define APICMD_REP_CONPHASE_SCAN_REASON_LIMITED_SERVICE (3)
#define APICMD_REP_CONPHASE_SCAN_REASON_COPS (4)
#define APICMD_REP_CONPHASE_SCAN_REASON_OTHER (5)
#define APICMD_REP_CONPHASE_SCAN_REASON_NOT_AVAIL (99)
#define APICMD_REPNETINFO_RES_OK (0)
#define APICMD_REPNETINFO_RES_ERR (1)
#define APICMD_REPNETINFO_REPORT_ENABLE (0)
#define APICMD_REPNETINFO_REPORT_DISABLE (1)
#define APICMD_REPNETINFO_NWSTAT_ATCH (0)
#define APICMD_REPNETINFO_NWSTAT_DTCH (1)
#define APICMD_SET_REPQUALITY_DISABLE (0)
#define APICMD_SET_REPQUALITY_ENABLE (1)
#define APICMD_SET_REPQUALITY_INTERVAL_MIN (1)
#define APICMD_SET_REPQUALITY_INTERVAL_MAX (4233600)
#define APICMD_SETPINCODE_PINCODE_LEN 9
#define APICMD_SETPINCODE_CHGTYPE_PIN (1)
#define APICMD_SETPINCODE_CHGTYPE_PIN2 (2)
#define APICMD_SETPINLOCK_PINCODE_LEN 9
#define APICMD_VERSION_RES_BB_PRODUCT_LEN 5
#define APICMD_VERSION_RES_NP_PACKAGE_LEN 32
#define APICMD_FW_INJECTDATA_MAXLEN (4096)
#define APICMD_FW_INJECTDATA_MAXLEN_V4 (3000)
#define APICMD_IPV4_LEN (4)
#define APICMD_IPV6_LEN (16)
/****************************************************************************
* Public Types
****************************************************************************/
/* structure for common */
begin_packed_struct struct apicmd_ipaddr_s
{
uint8_t iptype;
uint8_t address[APICMD_PDN_IPADDR_MAXLEN];
} end_packed_struct;
begin_packed_struct struct apicmd_pdnset_s
{
uint8_t session_id;
uint8_t activate;
uint32_t apntype;
uint8_t ipaddr_num;
struct apicmd_ipaddr_s
ip_address[APICMD_PDN_IPCOUNT_MAX];
uint8_t imsregister;
uint8_t dataallow;
uint8_t dararoamingallow;
} end_packed_struct;
begin_packed_struct struct apicmd_pdnset_v4_s
{
uint8_t session_id;
uint8_t activate;
uint32_t apntype;
uint8_t ipaddr_num;
struct apicmd_ipaddr_s
ip_address[APICMD_PDN_IPCOUNT_MAX];
uint8_t imsregister;
uint8_t dataallow;
uint8_t dararoamingallow;
uint8_t dnsaddr_num;
struct apicmd_ipaddr_s
dns_address[APICMD_PDN_DNSCOUNT_MAX];
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_neighbor_cell_s
{
uint8_t valid;
uint32_t cell_id;
uint32_t earfcn;
uint16_t sfn;
int16_t rsrp;
int16_t rsrq;
} end_packed_struct;
begin_packed_struct struct apicmd_edrxset_s
{
uint8_t acttype;
uint8_t enable;
uint8_t edrx_cycle;
uint8_t ptw_val;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_ltime_s
{
uint8_t year;
uint8_t month;
uint8_t day;
uint8_t hour;
uint8_t minutes;
uint8_t seconds;
int32_t timezone;
} end_packed_struct;
begin_packed_struct struct apicmd_netinfo_rejectcause_s
{
uint8_t category;
uint8_t value;
} end_packed_struct;
begin_packed_struct struct apicmd_netinfo_nwerrinfo_s
{
uint8_t err_type;
struct apicmd_netinfo_rejectcause_s reject_cause;
} end_packed_struct;
begin_packed_struct struct apicmd_netinfo_s
{
uint8_t nw_stat;
uint8_t pdn_count;
struct apicmd_netinfo_nwerrinfo_s err_info;
struct apicmd_pdnset_s pdn[APICMD_NETINFO_PDNCOUNT_MAX];
} end_packed_struct;
begin_packed_struct struct apicmd_netinfo_v4_s
{
uint8_t nw_stat;
uint8_t pdn_count;
struct apicmd_netinfo_nwerrinfo_s err_info;
struct apicmd_pdnset_v4_s pdn[APICMD_NETINFO_PDNCOUNT_MAX];
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_psm_timeval_s
{
uint8_t unit;
uint8_t time_val;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_psm_set_s
{
uint8_t enable;
struct apicmd_cmddat_psm_timeval_s rat_time;
struct apicmd_cmddat_psm_timeval_s tau_time;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_quality_s
{
uint8_t enability;
int16_t rsrp;
int16_t rsrq;
int16_t sinr;
int16_t rssi;
} end_packed_struct;
/* structure for APICMDID_ACTIVATE_PDN */
begin_packed_struct struct apicmd_cmddat_activatepdn_s
{
uint32_t apntype;
uint8_t iptype;
uint8_t apnname[APICMD_ACTIVATEPDN_APNNAME_MAXLEN];
uint8_t authtype;
uint8_t username[APICMD_ACTIVATEPDN_USERNAME_MAXLEN];
uint8_t password[APICMD_ACTIVATEPDN_PASSWORD_MAXLEN];
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_activatepdnres_s
{
uint8_t result;
struct apicmd_pdnset_s pdnset;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_activatepdnres_v4_s
{
uint8_t result;
struct apicmd_pdnset_v4_s pdnset;
} end_packed_struct;
/* structure for APICMDID_ACTIVATE_PDN_CANCEL */
begin_packed_struct struct apicmd_cmddat_activatepdn_cancel_res_s
{
uint8_t result;
} end_packed_struct;
/* structure for APICMDID_GET_CELLINFO */
begin_packed_struct struct apicmd_cmddat_cellinfo_s
{
uint8_t valid;
uint32_t cell_id;
uint32_t earfcn;
uint8_t mcc[APICMD_CELLINFO_MCC_DIGIT];
uint8_t mnc_digit;
uint8_t mnc[APICMD_CELLINFO_MNC_DIGIT_MAX];
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_cellinfo_v4_s
{
uint8_t enability;
uint32_t cell_id;
uint32_t earfcn;
uint8_t mcc[APICMD_CELLINFO_MCC_DIGIT];
uint8_t mnc_digit;
uint8_t mnc[APICMD_CELLINFO_MNC_DIGIT_MAX];
uint8_t cgid[APICMD_CELLINFO_GCID_MAX + 1];
uint16_t tac;
uint16_t time_diffidx;
uint16_t ta;
uint16_t sfn;
int16_t rsrp;
int16_t rsrq;
uint8_t neighbor_num;
struct apicmd_cmddat_neighbor_cell_s
neighbor_cell[APICMD_CELLINFO_NEIGHBOR_CELL_NUM_MAX];
} end_packed_struct;
/* structure for APICMDID_DATA_ALLOW */
begin_packed_struct struct apicmd_cmddat_dataallow_s
{
uint8_t session_id;
uint8_t data_allow;
uint8_t dataroam_allow;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_dataallowres_s
{
uint8_t result;
} end_packed_struct;
/* structure for APICMDID_DEACTIVATE_PDN */
begin_packed_struct struct apicmd_cmddat_deactivatepdn_s
{
uint8_t session_id;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_deactivatepdnres_s
{
uint8_t result;
uint8_t errcause;
} end_packed_struct;
/* structure for APICMDID_ENTER_PIN */
begin_packed_struct struct apicmd_cmddat_enterpin_s
{
uint8_t pincode[APICMD_ENTERPIN_PINCODE_LEN];
uint8_t newpincodeuse;
uint8_t newpincode[APICMD_ENTERPIN_PINCODE_LEN];
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_enterpinres_s
{
uint8_t result;
uint8_t simstat;
uint8_t attemptsleft;
} end_packed_struct;
/* structure for APICMDID_ERRINFO */
begin_packed_struct struct apicmd_cmddat_errinfo_s
{
uint8_t indicator;
int32_t err_code;
int32_t err_no;
uint8_t err_str[APICMD_ERRINFO_ERRSTR_MAX_LEN];
} end_packed_struct;
/* structure for APICMDID_GET_CE */
begin_packed_struct struct apicmd_cmddat_getceres_s
{
uint8_t result;
uint8_t mode_a_enable;
uint8_t mode_b_enable;
} end_packed_struct;
/* structure for APICMDID_GET_CELLINFO */
begin_packed_struct struct apicmd_cmddat_getcellinfores_v4_s
{
struct apicmd_cmddat_cellinfo_v4_s cellinfo;
} end_packed_struct;
/* structure for APICMDID_GET_DYNAMICEDRX */
begin_packed_struct struct apicmd_cmddat_getdynamicedrxres_s
{
uint8_t result;
struct apicmd_edrxset_s set;
} end_packed_struct;
/* structure for APICMDID_GET_DYNAMICPSM */
begin_packed_struct struct apicmd_cmddat_getdynamicpsmres_s
{
uint8_t result;
struct apicmd_cmddat_psm_set_s set;
} end_packed_struct;
/* structure for APICMDID_GET_EDRX */
begin_packed_struct struct apicmd_cmddat_getedrx_v4_s
{
uint8_t type;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_getedrxres_s
{
uint8_t result;
struct apicmd_edrxset_s set;
} end_packed_struct;
/* structure for APICMDID_GET_IMS_CAP */
begin_packed_struct struct apicmd_cmddat_getimscapres_s
{
uint8_t result;
uint8_t ims_cap;
} end_packed_struct;
/* structure for APICMDID_GET_NETINFO */
begin_packed_struct struct apicmd_cmddat_getnetinfores_s
{
uint8_t result;
struct apicmd_netinfo_s netinfo;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_getnetinfores_v4_s
{
uint8_t result;
struct apicmd_netinfo_v4_s netinfo;
} end_packed_struct;
/* structure for APICMDID_GET_PINSET */
begin_packed_struct struct apicmd_cmddat_getpinsetres_s
{
uint8_t result;
uint8_t active;
uint8_t status;
uint8_t pin_attemptsleft;
uint8_t puk_attemptsleft;
uint8_t pin2_attemptsleft;
uint8_t puk2_attemptsleft;
} end_packed_struct;
/* structure for APICMDID_GET_PSM */
begin_packed_struct struct apicmd_cmddat_getpsm_v4_s
{
uint8_t type;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_getpsmres_s
{
uint8_t result;
struct apicmd_cmddat_psm_set_s set;
} end_packed_struct;
/* structure for APICMDID_GET_QUALITY */
begin_packed_struct struct apicmd_cmddat_getqualityres_s
{
uint8_t result;
struct apicmd_cmddat_quality_s quality;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_getqualityres_v4_s
{
struct apicmd_cmddat_quality_s quality;
} end_packed_struct;
/* structure for APICMDID_GET_SIMINFO */
begin_packed_struct struct apicmd_cmddat_getsiminfo_s
{
uint32_t option;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_getsiminfo_res_s
{
uint8_t result;
uint32_t option;
uint8_t mcc[APICMD_GETSIMINFO_MCC_DIXIT_MAX];
uint8_t mnc_digit;
uint8_t mnc[APICMD_GETSIMINFO_MNC_DIXIT_MAX];
uint8_t spn_len;
uint8_t spn[APICMD_GETSIMINFO_SPN_MAX_LEN];
uint8_t iccid_len;
uint8_t iccid[APICMD_GETSIMINFO_ICCID_MAX_LEN];
uint8_t imsi_len;
uint8_t imsi[APICMD_GETSIMINFO_IMSI_LEN];
uint8_t gid1_len;
uint8_t gid1[APICMD_GETSIMINFO_GID_LEN];
uint8_t gid2_len;
uint8_t gid2[APICMD_GETSIMINFO_GID_LEN];
} end_packed_struct;
/* structure for APICMDID_GET_IMEI */
begin_packed_struct struct apicmd_cmddat_getimeires_s
{
uint8_t result;
uint8_t imei[APICMD_IMEI_LEN];
} end_packed_struct;
/* structure for APICMDID_GET_IMSI */
begin_packed_struct struct apicmd_cmddat_getimsires_s
{
uint8_t result;
uint8_t errcause;
uint8_t imsi[APICMD_IMSI_LEN];
} end_packed_struct;
/* structure for APICMDID_GET_LTIME */
begin_packed_struct struct apicmd_cmddat_getltimeres_s
{
uint8_t result;
struct apicmd_cmddat_ltime_s ltime;
} end_packed_struct;
/* structure for APICMDID_GET_OPERATOR */
begin_packed_struct struct apicmd_cmddat_getoperatorres_s
{
uint8_t result;
uint8_t oper[APICMD_OPERATOR_LEN];
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_getoperatorres_v4_s
{
uint8_t result;
uint8_t oper[APICMD_OPERATOR_LEN_V4];
} end_packed_struct;
/* structure for APICMDID_GET_PHONENO */
begin_packed_struct struct apicmd_cmddat_phonenores_s
{
uint8_t result;
uint8_t errcause;
uint8_t phoneno[APICMD_PHONENO_LEN];
} end_packed_struct;
/* structure for APICMDID_RADIO_OFF */
begin_packed_struct struct apicmd_cmddat_radiooffres_s
{
uint8_t result;
} end_packed_struct;
/* structure for APICMDID_RADIO_ON */
begin_packed_struct struct apicmd_cmddat_radioonres_s
{
uint8_t result;
} end_packed_struct;
/* structure for APICMDID_SET_RAT */
begin_packed_struct struct apicmd_cmddat_setrat_s
{
uint8_t rat;
uint8_t persistency;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_setratres_s
{
uint8_t result;
} end_packed_struct;
/* structure for APICMDID_GET_RAT */
begin_packed_struct struct apicmd_cmddat_getratres_s
{
uint8_t result;
uint8_t rat;
uint8_t rat_mode;
uint8_t source;
} end_packed_struct;
/* structure for APICMDID_SET_REP_CELLINFO */
begin_packed_struct struct apicmd_cmddat_setrepcellinfo_s
{
uint8_t enability;
uint32_t interval;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_setrepcellinfo_res_s
{
uint8_t result;
} end_packed_struct;
/* structure for APICMDID_SET_REP_EVT */
begin_packed_struct struct apicmd_cmddat_setrepevt_s
{
uint8_t event;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_setrepevt_v4_s
{
uint16_t event;
uint8_t enability;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_setrepevtres_s
{
uint8_t result;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_setrepevtres_v4_s
{
uint8_t result;
uint16_t event;
} end_packed_struct;
/* structure for APICMDID_REPORT_EVT */
begin_packed_struct struct apicmd_cmddat_repevt_simd_s
{
uint8_t status;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_repevt_simstate_s
{
uint8_t state;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_repregstate_s
{
uint8_t state;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_reppsmstate_s
{
uint8_t state;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_repantitamper_s
{
uint8_t data;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_repdynpsm_s
{
struct apicmd_cmddat_psm_timeval_s at_val;
struct apicmd_cmddat_psm_timeval_s tau_val;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_repdynedrx_s
{
uint8_t acttype;
uint8_t edrx_cycle;
uint8_t ptw_val;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_repconnphase_s
{
uint8_t state;
uint8_t rat;
uint8_t scantype;
uint8_t scanreason;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_repevt_s
{
uint8_t type;
union
{
struct apicmd_cmddat_ltime_s ltime;
struct apicmd_cmddat_repevt_simd_s simd;
struct apicmd_cmddat_repevt_simstate_s simstate;
} u;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_repevt_v4_s
{
uint16_t type;
union
{
struct apicmd_cmddat_ltime_s ltime;
struct apicmd_cmddat_repevt_simd_s simd;
struct apicmd_cmddat_repevt_simstate_s simstate;
struct apicmd_cmddat_repregstate_s regstate;
struct apicmd_cmddat_reppsmstate_s psmstate;
struct apicmd_cmddat_repdynpsm_s dynpsm;
struct apicmd_cmddat_repdynedrx_s dynedrx;
struct apicmd_cmddat_repconnphase_s connphase;
struct apicmd_cmddat_repantitamper_s antitamper;
} u;
} end_packed_struct;
/* structure for APICMDID_SETREP_NETINFO */
begin_packed_struct struct apicmd_cmddat_set_repnetinfo_s
{
uint8_t report;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_set_repnetinfores_s
{
uint8_t result;
} end_packed_struct;
/* structure for APICMDID_REPORT_NETINFO */
begin_packed_struct struct apicmd_cmddat_rep_netinfo_s
{
struct apicmd_netinfo_s netinfo;
uint8_t dnsaddrv4[APICMD_IPV4_LEN];
uint8_t dnsaddrv6[APICMD_IPV6_LEN];
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_rep_netinfo_v4_s
{
struct apicmd_netinfo_v4_s netinfo;
} end_packed_struct;
/* structure for APICMDID_SET_REP_QUALITY */
begin_packed_struct struct apicmd_cmddat_setrepquality_s
{
uint8_t enability;
uint32_t interval;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_setrepquality_res_s
{
uint8_t result;
} end_packed_struct;
/* structure for APICMDID_SET_CE */
begin_packed_struct struct apicmd_cmddat_setce_s
{
uint8_t mode_a_enable;
uint8_t mode_b_enable;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_setceres_s
{
uint8_t result;
} end_packed_struct;
/* structure for APICMDID_SET_EDRX */
begin_packed_struct struct apicmd_cmddat_setedrx_s
{
uint8_t acttype;
uint8_t enable;
uint8_t edrx_cycle;
uint8_t ptw_val;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_setedrxres_s
{
uint8_t result;
} end_packed_struct;
/* structure for APICMDID_SET_PIN_CODE */
begin_packed_struct struct apicmd_cmddat_setpincode_s
{
uint8_t chgtype;
uint8_t pincode[APICMD_SETPINCODE_PINCODE_LEN];
uint8_t newpincode[APICMD_SETPINCODE_PINCODE_LEN];
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_setpincoderes_s
{
uint8_t result;
uint8_t attemptsleft;
} end_packed_struct;
/* structure for APICMDID_SET_PIN_LOCK */
begin_packed_struct struct apicmd_cmddat_setpinlock_s
{
uint8_t mode;
uint8_t pincode[APICMD_SETPINLOCK_PINCODE_LEN];
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_setpinlockres_s
{
uint8_t result;
uint8_t attemptsleft;
} end_packed_struct;
/* structure for APICMDID_SET_PSM */
begin_packed_struct struct apicmd_cmddat_setpsm_s
{
struct apicmd_cmddat_psm_set_s set;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_setpsmres_s
{
uint8_t result;
} end_packed_struct;
/* structure for APICMDID_GET_VERSION */
begin_packed_struct struct apicmd_cmddat_getverres_s
{
uint8_t result;
uint8_t bb_product[APICMD_VERSION_RES_BB_PRODUCT_LEN];
uint8_t np_package[APICMD_VERSION_RES_NP_PACKAGE_LEN];
} end_packed_struct;
/* structure for APICMDID_FW_INJECTDELTAIMG */
begin_packed_struct struct apicmd_cmddat_fw_injectdeltaimg_s
{
uint8_t data[APICMD_FW_INJECTDATA_MAXLEN];
uint32_t data_len;
uint8_t inject_mode;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_fw_injectdeltaimg_v4_s
{
uint8_t inject_mode;
uint32_t data_len;
/* Variable length array */
uint8_t data[1];
} end_packed_struct;
/* structure for APICMDID_FW_INJECTDELTAIMG_RES,
* APICMDID_FW_GETDELTAIMGLEN_RES, APICMDID_FW_EXECDELTAUPDATE_RES,
* APICMDID_FW_GETUPDATERESULT_RES
*/
begin_packed_struct struct apicmd_cmddat_fw_deltaupcommres_s
{
int32_t api_result;
uint16_t ltefw_result;
} end_packed_struct;
#endif /* __DRIVERS_MODEM_ALT1250_ALTCOM_CMD_H */

View file

@ -0,0 +1,123 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_cmd_log.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 __DRIVERS_MODEM_ALT1250_ALTCOM_CMD_LOG_H
#define __DRIVERS_MODEM_ALT1250_ALTCOM_CMD_LOG_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <nuttx/modem/alt1250.h>
#include <nuttx/wireless/lte/lte.h>
#include <stdbool.h>
#include <stdint.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define ALTCOM_LOGSPATH "logs/"
#define ALTCOM_PATH_LEN_MAX (LTE_LOG_NAME_LEN + 5)
#define ALTCOM_LIST_LEN_MAX (LTE_LOG_LIST_SIZE * ALTCOM_PATH_LEN_MAX)
#define ALTCOM_LOG_ACCESS_PATH_LEN_MAX (256)
#define ALTCOM_LOG_READ_LEN_MAX (2000)
#define ALTCOM_LOG_OPEN_FLAGS (0x1)
#define ALTCOM_LOG_SEEK_SET (0)
#define ALTCOM_LOG_SEEK_CUR (1)
#define ALTCOM_LOG_SEEK_END (2)
/****************************************************************************
* Public Types
****************************************************************************/
begin_packed_struct struct apicmd_cmddat_clogs_s
{
uint8_t pathlen;
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_clogsres_s
{
int32_t altcom_result;
uint8_t pathlen;
char path[ALTCOM_PATH_LEN_MAX];
} end_packed_struct;
begin_packed_struct struct apicmddbg_getloglist_s
{
uint8_t listsize;
uint8_t pathlen;
} end_packed_struct;
begin_packed_struct struct apicmddbg_getloglistres_s
{
int32_t altcom_result;
uint8_t listsize;
uint8_t pathlen;
char list[ALTCOM_LIST_LEN_MAX];
} end_packed_struct;
begin_packed_struct struct apicmd_logopen_s
{
char path[ALTCOM_LOG_ACCESS_PATH_LEN_MAX];
int32_t flags;
int32_t mode;
} end_packed_struct;
begin_packed_struct struct apicmd_logcommonres_s
{
int32_t altcom_result;
int32_t unused;
} end_packed_struct;
begin_packed_struct struct apicmd_logclose_s
{
int32_t fd;
} end_packed_struct;
begin_packed_struct struct apicmd_logread_s
{
int32_t fd;
int32_t readlen;
} end_packed_struct;
begin_packed_struct struct apicmd_logreadres_s
{
int32_t altcom_result;
int32_t unused;
char readdata[ALTCOM_LOG_READ_LEN_MAX];
} end_packed_struct;
begin_packed_struct struct apicmd_logremove_s
{
char path[ALTCOM_LOG_ACCESS_PATH_LEN_MAX];
} end_packed_struct;
begin_packed_struct struct apicmd_loglseek_s
{
int32_t fd;
int32_t offset;
int32_t whence;
} end_packed_struct;
#endif /* __DRIVERS_MODEM_ALT1250_ALTCOM_CMD_LOG_H */

View file

@ -0,0 +1,212 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_cmd_sms.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 __DRIVERS_MODEM_ALT1250_ALTCOM_CMD_SMS_H
#define __DRIVERS_MODEM_ALT1250_ALTCOM_CMD_SMS_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <nuttx/modem/alt1250.h>
#include <nuttx/net/sms.h>
#include <stdbool.h>
#include <stdint.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define ALTCOM_SMS_MSG_VALID_UD (0x01 << 0)
#define ALTCOM_SMS_MSG_VALID_SRR (0x01 << 1)
#define ALTCOM_SMS_MSG_VALID_CONCAT_HDR (0x01 << 3)
#define ALTCOM_SMS_MSG_VALID_TOA (0x01 << 4)
#define ALTCOM_SMS_DELIVERY_STAT_CAT_MASK (0x60)
#define ALTCOM_SMS_DELIVERY_STAT_CAT_OK (0x00)
#define ALTCOM_SMS_DELIVERY_STAT_CAT_PEND (0x01 << 6)
#define ALTCOM_SMS_DELIVERY_STAT_CAT_FAIL (0x01 << 7)
#define ALTCOM_SMS_MSG_TYPE_SEND (0x01 << 0)
#define ALTCOM_SMS_MSG_TYPE_RECV (0x01 << 1)
#define ALTCOM_SMS_MSG_TYPE_DELIVER_REPORT (0x01 << 2)
#define ALTCOM_SMS_CHSET_GSM7 0
#define ALTCOM_SMS_CHSET_BINARY 1
#define ALTCOM_SMS_CHSET_UCS2 2
/****************************************************************************
* Public Types
****************************************************************************/
begin_packed_struct struct apicmd_sms_time_s
{
uint8_t year; /* Years (0-99) */
uint8_t mon; /* Month (1-12) */
uint8_t mday; /* Day of the month (1-31) */
uint8_t hour; /* Hours (0-23) */
uint8_t min; /* Minutes (0-59) */
uint8_t sec; /* Seconds (0-59) */
int8_t tz; /* Time zone in hour (-24 - +24) */
} end_packed_struct;
begin_packed_struct struct apicmd_sms_addr_s
{
/* Type of address is reserved. */
uint8_t toa;
uint8_t length;
uint16_t address[SMS_MAX_ADDRLEN];
} end_packed_struct;
begin_packed_struct struct apicmd_sms_concat_hdr_s
{
/* Contain a modulo 256 counter indicating the reference number
* for a particular concatenated short message.
*/
uint8_t ref_num;
/* Contain a value in the range 0 to 255 indicating the total number of
* short messages within the concatenated short message.
*/
uint8_t max_num;
/* Contain a value in the range 0 to 255 indicating the sequence number
* of a particular short message within the concatenated short message.
*/
uint8_t seq_num;
} end_packed_struct;
begin_packed_struct struct apicmd_sms_userdata_s
{
/* Set the character set used for SMS */
uint8_t chset;
/* Buffer length of User-Data field. */
uint16_t data_len;
/* User data in utf-8 format. */
uint8_t *data;
} end_packed_struct;
begin_packed_struct struct apicmd_sms_msg_s
{
uint8_t type;
union
{
/* SMS-DELIVER */
struct
{
uint8_t valid_indicator;
struct apicmd_sms_addr_s src_addr;
struct apicmd_sms_time_s sc_time;
struct apicmd_sms_concat_hdr_s concat_hdr;
struct apicmd_sms_userdata_s userdata;
/* Variable length array */
uint16_t user_data[0];
} recv;
/* SMS-STATUS-REPORT */
struct
{
uint8_t status;
struct apicmd_sms_time_s sc_time;
uint8_t ref_id;
struct apicmd_sms_time_s discharge_time;
} delivery_report;
} u;
} end_packed_struct;
/* Command format for these response
* APICMDID_SMS_INIT, APICMDID_SMS_FIN, APICMDID_SMS_REPORT_RECV,
* APICMDID_SMS_DELETE
*/
begin_packed_struct struct apicmd_sms_res_s
{
int32_t result;
} end_packed_struct;
/* Command format for APICMDID_SMS_INIT request */
begin_packed_struct struct apicmd_sms_init_req_s
{
uint8_t types;
uint8_t storage_use;
} end_packed_struct;
/* Command format for APICMDID_SMS_SEND request */
begin_packed_struct struct apicmd_sms_send_req_s
{
struct apicmd_sms_addr_s sc_addr;
/* SMS-SUBMIT */
uint8_t valid_indicator;
struct apicmd_sms_addr_s dest_addr;
struct apicmd_sms_userdata_s userdata;
/* Variable length array */
uint16_t user_data[0];
} end_packed_struct;
/* Command format for APICMDID_SMS_SEND response */
begin_packed_struct struct apicmd_sms_sendres_s
{
int32_t result;
uint8_t mr_num;
uint8_t mr_list[SMS_CONCATENATE_MAX];
} end_packed_struct;
/* Command format for APICMDID_SMS_REPORT_RECV request */
begin_packed_struct struct apicmd_sms_reprecv_s
{
uint16_t index;
struct apicmd_sms_addr_s sc_addr;
struct apicmd_sms_msg_s msg;
} end_packed_struct;
/* Command format for APICMDID_SMS_DELETE request */
begin_packed_struct struct apicmd_sms_delete_s
{
uint16_t index;
uint8_t types;
} end_packed_struct;
#endif /* __DRIVERS_MODEM_ALT1250_ALTCOM_CMD_SMS_H */

View file

@ -0,0 +1,509 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_cmd_sock.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 __DRIVERS_MODEM_ALT1250_ALTCOM_CMD_SOCK_H
#define __DRIVERS_MODEM_ALT1250_ALTCOM_CMD_SOCK_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <nuttx/modem/alt1250.h>
#include <stdbool.h>
#include <stdint.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define APICMD_NAME_LENGTH (256)
#define APICMD_SERVNAME_LENGTH (32)
#define APICMD_H_ADDR_LENGTH (16)
#define APICMD_OPTVAL_LENGTH (16)
#define APICMD_DATA_LENGTH (1500)
#define APICMD_AI_COUNT (2)
#define APICMD_SELECT_NONBLOCK (0)
#define APICMD_SELECT_BLOCK (1)
#define APICMD_SELECT_BLOCKCANCEL (2)
#define APICMD_SELECT_READ_BIT (1 << 0)
#define APICMD_SELECT_WRITE_BIT (1 << 1)
#define APICMD_SELECT_EXCEPT_BIT (1 << 2)
/* Using for socket: Address family
* Referenced from socket.h of lwIP-v2.02
*/
#define ALTCOM_AF_UNSPEC 0 /* Refer to AF_UNSPEC on lwIP */
#define ALTCOM_AF_INET 2 /* Refer to AF_INET on lwIP */
#define ALTCOM_AF_INET6 10 /* Refer to AF_INET6 on lwIP */
#define ALTCOM_PF_INET ALTCOM_AF_INET /* Refer to PF_INET on lwIP */
#define ALTCOM_PF_INET6 ALTCOM_AF_INET6 /* Refer to PF_INET6 on lwIP */
#define ALTCOM_PF_UNSPEC ALTCOM_AF_UNSPEC /* Refer to PF_UNSPEC on lwIP */
/* Using for socket: Socket protocol type
* Referenced from socket.h of lwIP-v2.02
*/
#define ALTCOM_SOCK_STREAM 1 /* Refer to SOCK_STREAM on lwIP */
#define ALTCOM_SOCK_DGRAM 2 /* Refer to SOCK_DGRAM on lwIP */
#define ALTCOM_SOCK_RAW 3 /* Refer to SOCK_RAW on lwIP */
#define ALTCOM_SOCK_DGRAM_DTLS 130 /* Refer to SOCK_DGRAM_DTLS on lwIP */
/* Using for socket: Protocol
* Referenced from socket.h of lwIP-v2.02
*/
#define ALTCOM_IPPROTO_IP 0 /* Refer to IPPROTO_IP on lwIP */
#define ALTCOM_IPPROTO_ICMP 1 /* Refer to IPPROTO_ICMP on lwIP */
#define ALTCOM_IPPROTO_TCP 6 /* Refer to IPPROTO_TCP on lwIP */
#define ALTCOM_IPPROTO_UDP 17 /* Refer to IPPROTO_UDP on lwIP */
#define ALTCOM_IPPROTO_IPV6 41 /* Refer to IPPROTO_IPV6 on lwIP */
#define ALTCOM_IPPROTO_ICMPV6 58 /* Refer to IPPROTO_ICMPV6 on lwIP */
#define ALTCOM_IPPROTO_UDPLITE 136 /* Refer to IPPROTO_UDPLITE on lwIP */
#define ALTCOM_IPPROTO_RAW 255 /* Refer to IPPROTO_RAW on lwIP */
/* Using for recvfrom/sendto: Flags
* Referenced from socket.h of lwIP-v2.02
*/
#define ALTCOM_MSG_PEEK 0x01 /* Refer to MSG_PEEK on lwIP */
#define ALTCOM_MSG_WAITALL 0x02 /* Refer to MSG_WAITALL on lwIP */
#define ALTCOM_MSG_OOB 0x04 /* Refer to MSG_OOB on lwIP */
#define ALTCOM_MSG_DONTWAIT 0x08 /* Refer to MSG_DONTWAIT on lwIP */
#define ALTCOM_MSG_MORE 0x10 /* Refer to MSG_MORE on lwIP */
/* Using for setsockopt/getsockopt: Level
* Referenced from socket.h of lwIP-v2.02
*/
#define ALTCOM_SOL_SOCKET 0xfff /* Refer to SOL_SOCKET on lwIP */
/* Using for setsockopt/getsockopt: Option flags per-socket
* Referenced from socket.h of lwIP-v2.02
*/
#define ALTCOM_SO_REUSEADDR 0x0004 /* Refer to SO_REUSEADDR on lwIP */
#define ALTCOM_SO_KEEPALIVE 0x0008 /* Refer to SO_KEEPALIVE on lwIP */
#define ALTCOM_SO_BROADCAST 0x0020 /* Refer to SO_BROADCAST on lwIP */
/* Using for setsockopt/getsockopt:
* Additional options, not kept in so_options
* Referenced from socket.h of lwIP-v2.02
*/
#define ALTCOM_SO_ACCEPTCONN 0x0002 /* Refer to SO_ACCEPTCONN on lwIP */
#define ALTCOM_SO_LINGER 0x0080 /* Refer to SO_LINGER on lwIP */
#define ALTCOM_SO_RCVBUF 0x1002 /* Refer to SO_RCVBUF on lwIP */
#define ALTCOM_SO_SNDTIMEO 0x1005 /* Refer to SO_SNDTIMEO on lwIP */
#define ALTCOM_SO_RCVTIMEO 0x1006 /* Refer to SO_RCVTIMEO on lwIP */
#define ALTCOM_SO_ERROR 0x1007 /* Refer to SO_ERROR on lwIP */
#define ALTCOM_SO_TYPE 0x1008 /* Refer to SO_TYPE on lwIP */
#define ALTCOM_SO_NO_CHECK 0x100a /* Refer to SO_NO_CHECK on lwIP ss*/
/* Options for level IPPROTO_IP
* Referenced from socket.h of lwIP-v2.02
*/
#define ALTCOM_IP_TOS 1 /* Refer to IP_TOS on lwIP */
#define ALTCOM_IP_TTL 2 /* Refer to IP_TTL on lwIP */
/* Options and types related to multicast membership
* Referenced from socket.h of lwIP-v2.02
*/
#define ALTCOM_IP_ADD_MEMBERSHIP 3 /* Refer to IP_ADD_MEMBERSHIP on lwIP */
#define ALTCOM_IP_DROP_MEMBERSHIP 4 /* Refer to IP_DROP_MEMBERSHIP on lwIP */
/* Options and types for UDP multicast traffic handling
* Referenced from socket.h of lwIP-v2.02
*/
#define ALTCOM_IP_MULTICAST_TTL 5 /* Refer to IP_MULTICAST_TTL on lwIP */
#define ALTCOM_IP_MULTICAST_IF 6 /* Refer to IP_MULTICAST_IF on lwIP */
#define ALTCOM_IP_MULTICAST_LOOP 7 /* Refer to IP_MULTICAST_LOOP on lwIP */
/* Options for level ALTCOM_IPPROTO_TCP
* Referenced from socket.h of lwIP-v2.02
*/
#define ALTCOM_TCP_NODELAY 0x01 /* Refer to TCP_NODELAY on lwIP */
#define ALTCOM_TCP_KEEPALIVE 0x02 /* Refer to TCP_KEEPALIVE on lwIP */
#define ALTCOM_TCP_KEEPIDLE 0x03 /* Refer to TCP_KEEPIDLE on lwIP */
#define ALTCOM_TCP_KEEPINTVL 0x04 /* Refer to TCP_KEEPINTVL on lwIP */
#define ALTCOM_TCP_KEEPCNT 0x05 /* Refer to TCP_KEEPCNT on lwIP */
/* Options for level ALTCOM_IPPROTO_IPV6
* Referenced from socket.h of lwIP-v2.02
*/
#define ALTCOM_IPV6_V6ONLY 27 /* Refer to IPV6_V6ONLY on lwIP */
/****************************************************************************
* Public Types
****************************************************************************/
typedef uint8_t altcom_sa_family_t;
typedef uint32_t altcom_socklen_t;
typedef uint16_t altcom_in_port_t;
typedef uint32_t altcom_in_addr_t;
struct altcom_in_addr
{
altcom_in_addr_t s_addr;
};
struct altcom_in6_addr
{
union
{
uint32_t u32_addr[4];
uint16_t u16_addr[8];
uint8_t u8_addr[16];
} un;
#define altcom_s6_addr un.u8_addr
};
struct altcom_sockaddr_storage
{
uint8_t s2_len;
altcom_sa_family_t ss_family;
char s2_data1[2];
uint32_t s2_data2[3];
uint32_t s2_data3[3];
};
struct altcom_sockaddr_in
{
uint8_t sin_len;
altcom_sa_family_t sin_family;
altcom_in_port_t sin_port;
struct altcom_in_addr sin_addr;
#define ALTCOM_SIN_ZERO_LEN 8
char sin_zero[ALTCOM_SIN_ZERO_LEN];
};
struct altcom_sockaddr_in6
{
uint8_t sin6_len;
altcom_sa_family_t sin6_family;
altcom_in_port_t sin6_port;
uint32_t sin6_flowinfo;
struct altcom_in6_addr sin6_addr;
uint32_t sin6_scope_id;
};
struct altcom_ip_mreq
{
struct altcom_in_addr imr_multiaddr;
struct altcom_in_addr imr_interface;
};
struct altcom_linger
{
int l_onoff;
int l_linger;
};
/* structure for APICMDID_SOCK_ACCEPT and APICMDID_SOCK_GETSOCKNAME */
begin_packed_struct struct altmdmpkt_sockaddrlen_s
{
int32_t sockfd;
uint32_t addrlen;
} end_packed_struct;
/* structure for APICMDID_SOCK_BIND and APICMDID_SOCK_CONNECT */
begin_packed_struct struct altmdmpkt_sockaddr_s
{
int32_t sockfd;
uint32_t namelen;
struct altcom_sockaddr_storage name;
} end_packed_struct;
/* structure for APICMDID_SOCK_CLOSE */
begin_packed_struct struct apicmd_close_s
{
int32_t sockfd;
} end_packed_struct;
/* structure for APICMDID_SOCK_FCNTL */
begin_packed_struct struct apicmd_fcntl_s
{
int32_t sockfd;
int32_t cmd;
int32_t val;
} end_packed_struct;
/* structure for APICMDID_SOCK_GETADDRINFO */
begin_packed_struct struct apicmd_getaddrinfo_s
{
uint32_t nodenamelen;
int8_t nodename[APICMD_NAME_LENGTH];
uint32_t servnamelen;
int8_t servname[APICMD_SERVNAME_LENGTH];
int32_t hints_flag;
int32_t ai_flags;
int32_t ai_family;
int32_t ai_socktype;
int32_t ai_protocol;
} end_packed_struct;
/* structure for APICMDID_SOCK_GETHOSTBYNAME */
begin_packed_struct struct apicmd_gethostbyname_s
{
uint32_t namelen;
int8_t name[APICMD_NAME_LENGTH];
} end_packed_struct;
/* structure for APICMDID_SOCK_GETHOSTBYNAMER */
begin_packed_struct struct apicmd_gethostbynamer_s
{
uint32_t namelen;
int8_t name[APICMD_NAME_LENGTH];
int32_t buflen;
} end_packed_struct;
/* structure for APICMDID_SOCK_GETSOCKOPT */
begin_packed_struct struct apicmd_getsockopt_s
{
int32_t sockfd;
int32_t level;
int32_t optname;
int32_t optlen;
} end_packed_struct;
/* structure for APICMDID_SOCK_LISTEN */
begin_packed_struct struct apicmd_listen_s
{
int32_t sockfd;
int32_t backlog;
} end_packed_struct;
/* structure for APICMDID_SOCK_RECV */
begin_packed_struct struct apicmd_recv_s
{
int32_t sockfd;
int32_t recvlen;
int32_t flags;
} end_packed_struct;
/* structure for APICMDID_SOCK_RECVFROM */
begin_packed_struct struct apicmd_recvfrom_s
{
int32_t sockfd;
int32_t recvlen;
int32_t flags;
uint32_t fromlen;
} end_packed_struct;
/* structure for APICMDID_SOCK_SELECT */
begin_packed_struct struct apicmd_select_s
{
int32_t request;
int32_t id;
int32_t maxfds;
uint16_t used_setbit;
altcom_fd_set readset;
altcom_fd_set writeset;
altcom_fd_set exceptset;
} end_packed_struct;
/* structure for APICMDID_SOCK_SEND */
begin_packed_struct struct apicmd_send_s
{
int32_t sockfd;
int32_t flags;
int32_t datalen;
int8_t senddata[APICMD_DATA_LENGTH];
} end_packed_struct;
/* structure for APICMDID_SOCK_SENDTO */
begin_packed_struct struct apicmd_sendto_s
{
int32_t sockfd;
int32_t flags;
int32_t datalen;
uint32_t tolen;
struct altcom_sockaddr_storage to;
int8_t senddata[APICMD_DATA_LENGTH];
} end_packed_struct;
/* structure for APICMDID_SOCK_SETSOCKOPT */
begin_packed_struct struct apicmd_setsockopt_s
{
int32_t sockfd;
int32_t level;
int32_t optname;
int32_t optlen;
int8_t optval[APICMD_OPTVAL_LENGTH];
} end_packed_struct;
/* structure for APICMDID_SOCK_SHUTDOWN */
begin_packed_struct struct apicmd_shutdown_s
{
int32_t sockfd;
int32_t how;
} end_packed_struct;
/* structure for APICMDID_SOCK_SOCKET */
begin_packed_struct struct apicmd_socket_s
{
int32_t domain;
int32_t type;
int32_t protocol;
} end_packed_struct;
/****************************************************************************/
/* structure for APICMDID_SOCK_BIND and APICMDID_SOCK_CLOSE,
* APICMDID_SOCK_CONNECT, APICMDID_SOCK_FCNTL, APICMDID_SOCK_LISTEN,
* APICMDID_SOCK_SEND, APICMDID_SOCK_SENDTO, APICMDID_SOCK_SETSOCKOPT,
* APICMDID_SOCK_SHUTDOWN, APICMDID_SOCK_SOCKET
*/
begin_packed_struct struct altmdmpktr_sockcomm_s
{
int32_t ret_code;
int32_t err_code;
} end_packed_struct;
/* structure for APICMDID_SOCK_ACCEPT and APICMDID_SOCK_GETSOCKNAME */
begin_packed_struct struct altmdmpktr_sockaddr_s
{
int32_t ret_code;
int32_t err_code;
uint32_t addrlen;
struct altcom_sockaddr_storage address;
} end_packed_struct;
/* structure for APICMDID_SOCK_GETADDRINFO */
begin_packed_struct struct apicmd_getaddrinfo_ai_s
{
int32_t ai_flags;
int32_t ai_family;
int32_t ai_socktype;
int32_t ai_protocol;
altcom_socklen_t ai_addrlen;
struct altcom_sockaddr_storage ai_addr;
uint32_t ai_cnamelen;
int8_t ai_canonname[APICMD_NAME_LENGTH];
} end_packed_struct;
/* structure for APICMDID_SOCK_GETADDRINFO */
begin_packed_struct struct apicmd_getaddrinfores_s
{
int32_t ret_code;
uint32_t ai_num;
struct apicmd_getaddrinfo_ai_s ai[APICMD_AI_COUNT];
} end_packed_struct;
/* structure for APICMDID_SOCK_GETHOSTBYNAME */
begin_packed_struct struct apicmd_gethostbynameres_s
{
int32_t ret_code;
int8_t h_name[APICMD_NAME_LENGTH];
int8_t h_aliases[APICMD_NAME_LENGTH];
int32_t h_addrtype;
int32_t h_length;
int8_t h_addr_list[APICMD_H_ADDR_LENGTH];
} end_packed_struct;
/* structure for APICMDID_SOCK_GETHOSTBYNAMER */
begin_packed_struct struct apicmd_gethostbynamer_res_s
{
int32_t ret_code;
int32_t err_code;
int8_t h_name[APICMD_NAME_LENGTH];
int8_t h_aliases[APICMD_NAME_LENGTH];
int32_t h_addrtype;
int32_t h_length;
int8_t h_addr_list[APICMD_H_ADDR_LENGTH];
} end_packed_struct;
/* structure for APICMDID_SOCK_GETSOCKOPT */
begin_packed_struct struct apicmd_getsockoptres_s
{
int32_t ret_code;
int32_t err_code;
int32_t optlen;
int8_t optval[APICMD_OPTVAL_LENGTH];
} end_packed_struct;
/* structure for APICMDID_SOCK_RECV */
begin_packed_struct struct apicmd_recvres_s
{
int32_t ret_code;
int32_t err_code;
int8_t recvdata[APICMD_DATA_LENGTH];
} end_packed_struct;
/* structure for APICMDID_SOCK_RECVFROM */
begin_packed_struct struct apicmd_recvfromres_s
{
int32_t ret_code;
int32_t err_code;
uint32_t fromlen;
struct altcom_sockaddr_storage from;
int8_t recvdata[APICMD_DATA_LENGTH];
} end_packed_struct;
/* structure for APICMDID_SOCK_SELECT */
begin_packed_struct struct apicmd_selectres_s
{
int32_t ret_code;
int32_t err_code;
int32_t id;
uint16_t used_setbit;
altcom_fd_set readset;
altcom_fd_set writeset;
altcom_fd_set exceptset;
} end_packed_struct;
#endif /* __DRIVERS_MODEM_ALT1250_ALTCOM_CMD_SOCK_H */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,72 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_hdlr.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 __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_H
#define __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/modem/alt1250.h>
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: alt1250_composehdlr
*
* Description:
* Get the function pointer of the compose handler associated with the
* LAPI command ID.
*
* Input Parameters:
* cmdid - ID of the LAPI command.
*
* Returned Value:
* Returns a function pointer for the compose handler. If there is no
* compose handler associated with the LAPI command ID, NULL is returned.
*
****************************************************************************/
compose_handler_t alt1250_composehdlr(uint32_t cmdid);
/****************************************************************************
* Name: alt1250_parsehdlr
*
* Description:
* Get the function pointer of the parse handler associated with the
* ALTCOM command ID.
*
* Input Parameters:
* altcid - ID of the ALTCOM command.
* altver - Version of the ALTCOM command.
*
* Returned Value:
* Returns a function pointer for the parse handler. If there is no
* parse handler associated with the ALTCOM command ID, NULL is returned.
*
****************************************************************************/
parse_handler_t alt1250_parsehdlr(uint16_t altcid, uint8_t altver);
#endif /* __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_H */

View file

@ -0,0 +1,412 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_lwm2m_hdlr.c
*
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <nuttx/wireless/lte/lte_ioctl.h>
#include "altcom_lwm2m_hdlr.h"
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static int32_t read_request_hndl(FAR uint8_t *pktbuf, size_t pktsz,
FAR void **cb_args, size_t arglen);
static int32_t write_request_hndl(FAR uint8_t *pktbuf, size_t pktsz,
FAR void **cb_args, size_t arglen);
static int32_t exec_request_hndl(FAR uint8_t *pktbuf, size_t pktsz,
FAR void **cb_args, size_t arglen);
static int32_t start_ov_request_hndl(FAR uint8_t *pktbuf, size_t pktsz,
FAR void **cb_args, size_t arglen);
static int32_t stop_ov_request_hndl(FAR uint8_t *pktbuf, size_t pktsz,
FAR void **cb_args, size_t arglen);
static int32_t fwupdate_notice_hndl(FAR uint8_t *pktbuf, size_t pktsz,
FAR void **cb_args, size_t arglen);
static int32_t server_op_notice_hndl(FAR uint8_t *pktbuf, size_t pktsz,
FAR void **cb_args, size_t arglen);
/****************************************************************************
* Private Types
****************************************************************************/
struct urc_hdltbl_s
{
FAR const char *head;
uint32_t lcmdid;
lwm2mstub_hndl_t hdlr;
};
struct lwm2mstub_instance_s
{
int object_id;
int object_inst;
int res_id;
int res_inst;
};
struct lwm2mstub_ovcondition_s
{
uint8_t valid_mask;
unsigned int min_period;
unsigned int max_period;
double gt_cond;
double lt_cond;
double step_val;
};
/****************************************************************************
* Private Data
****************************************************************************/
static struct urc_hdltbl_s urc_idhandles[] =
{
{ "%LWM2MOBJCMDU: \"READ\",",
LTE_CMDID_LWM2M_READ_EVT, read_request_hndl },
{ "%LWM2MOBJCMDU: \"WRITE\",",
LTE_CMDID_LWM2M_WRITE_EVT, write_request_hndl },
{ "%LWM2MOBJCMDU: \"EXE\",",
LTE_CMDID_LWM2M_EXEC_EVT, exec_request_hndl },
{ "%LWM2MOBJCMDU: \"OBSERVE_START\",",
LTE_CMDID_LWM2M_OVSTART_EVT, start_ov_request_hndl },
{ "%LWM2MOBJCMDU: \"OBSERVE_STOP\",",
LTE_CMDID_LWM2M_OVSTOP_EVT, stop_ov_request_hndl },
{ "%LWM2MOPEV: ",
LTE_CMDID_LWM2M_SERVEROP_EVT, server_op_notice_hndl },
{ "%LWM2MEV: ",
LTE_CMDID_LWM2M_FWUP_EVT, fwupdate_notice_hndl },
{
NULL, 0, NULL
},
};
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* name: skip_until
****************************************************************************/
static FAR uint8_t *skip_until(FAR uint8_t *stream, FAR char *delim)
{
for (; *stream && !strchr(delim, *stream); stream++);
for (; *stream && strchr(delim, *stream); stream++);
if (*stream == '\0')
{
stream = NULL;
}
return stream;
}
/****************************************************************************
* name: strcpy_until
****************************************************************************/
static FAR char strcpy_until(char *dst, int n, char **src, char *delim)
{
char *tmp = *src;
if (dst)
{
dst[n - 1] = '\0';
n--;
}
while (*tmp && !strchr(delim, *tmp))
{
if (dst && (n > 0))
{
*dst++ = *tmp;
n--;
}
tmp++;
}
if (dst && (n > 0))
{
*dst = '\0';
}
*src = tmp + 1;
return *tmp;
}
/****************************************************************************
* name: parse_instance
****************************************************************************/
static FAR uint8_t *parse_instance(uint8_t *pktbuf, int *seq_no, int *srv_id,
struct lwm2mstub_instance_s *inst)
{
*seq_no = atoi((char *)pktbuf); /* for seq_no */
pktbuf = skip_until(pktbuf, ",");
*srv_id = atoi((char *)pktbuf); /* for srv_id */
pktbuf = skip_until(pktbuf, ",");
/* Parse URI like /objid/objinst/resid */
pktbuf = skip_until(pktbuf, "/");
inst->object_id = atoi((char *)pktbuf);
pktbuf = skip_until(pktbuf, "/");
inst->object_inst = atoi((char *)pktbuf);
pktbuf = skip_until(pktbuf, "/");
inst->res_id = atoi((char *)pktbuf);
inst->res_inst = -1;
if (skip_until(pktbuf, "/") != NULL)
{
pktbuf = skip_until(pktbuf, "/");
inst->res_inst = atoi((char *)pktbuf);
}
pktbuf = skip_until(pktbuf, ",/\r\n");
return pktbuf;
}
/****************************************************************************
* name: read_request_hndl
****************************************************************************/
static int32_t read_request_hndl(FAR uint8_t *pktbuf, size_t pktsz,
FAR void **cb_args, size_t arglen)
{
parse_instance(pktbuf, (int *)&cb_args[0], (int *)&cb_args[1],
(struct lwm2mstub_instance_s *)(cb_args[2]));
return 0;
}
/****************************************************************************
* name: write_request_hndl
****************************************************************************/
static int32_t write_request_hndl(FAR uint8_t *pktbuf, size_t pktsz,
FAR void **cb_args, size_t arglen)
{
if (!cb_args[3] && ((int)cb_args[5]) <= 0)
{
return -1;
}
pktbuf = parse_instance(pktbuf, (int *)&cb_args[0], (int *)&cb_args[1],
(struct lwm2mstub_instance_s *)(cb_args[2]));
if (*pktbuf == '\"')
{
pktbuf++;
}
strcpy_until((char *)cb_args[3], (int)cb_args[5], (char **)&pktbuf,
"\",\r\n");
cb_args[4] = (void *)strlen((char *)cb_args[3]);
return 0;
}
/****************************************************************************
* name: exec_request_hndl
****************************************************************************/
static int32_t exec_request_hndl(FAR uint8_t *pktbuf, size_t pktsz,
FAR void **cb_args, size_t arglen)
{
parse_instance(pktbuf, (int *)&cb_args[0], (int *)&cb_args[1],
(struct lwm2mstub_instance_s *)(cb_args[2]));
return 0;
}
/****************************************************************************
* name: parse_observe
****************************************************************************/
static uint8_t *parse_observe(uint8_t *pktbuf, int *seq_no, int *srv_id,
int tksize, char *token,
struct lwm2mstub_instance_s *inst)
{
*seq_no = atoi((char *)pktbuf); /* for seq_no */
pktbuf = skip_until(pktbuf, ",");
*srv_id = atoi((char *)pktbuf); /* for server id */
pktbuf = skip_until(pktbuf, "\"");
strcpy_until(token, tksize, (char **)&pktbuf, "\"");
pktbuf = skip_until(pktbuf, ",");
pktbuf = skip_until(pktbuf, "/");
inst->object_id = -1;
inst->object_inst = -1;
inst->res_id = -1;
inst->res_inst = -1;
inst->object_id = atoi((char *)pktbuf);
if (strcpy_until(NULL, 0, (char **)&pktbuf, "/\",") == '/')
{
inst->object_inst = atoi((char *)pktbuf);
if (strcpy_until(NULL, 0, (char **)&pktbuf, "/\",") == '/')
{
inst->res_id = atoi((char *)pktbuf);
if (strcpy_until(NULL, 0, (char **)&pktbuf, "/\",") == '/')
{
inst->res_inst = atoi((char *)pktbuf);
}
}
}
return pktbuf;
}
/****************************************************************************
* name: start_ov_request_hndl
****************************************************************************/
static int32_t start_ov_request_hndl(FAR uint8_t *pktbuf, size_t pktsz,
FAR void **cb_args, size_t arglen)
{
struct lwm2mstub_ovcondition_s *cond
= (struct lwm2mstub_ovcondition_s *)cb_args[5];
parse_observe(pktbuf,
(int *)&cb_args[0], (int *)&cb_args[1],
(int)cb_args[4], (char *)cb_args[3],
(struct lwm2mstub_instance_s *)cb_args[2]);
cond->valid_mask = 0;
return 0;
}
/****************************************************************************
* name: stop_ov_request_hndl
****************************************************************************/
static int32_t stop_ov_request_hndl(FAR uint8_t *pktbuf, size_t pktsz,
FAR void **cb_args, size_t arglen)
{
parse_observe(pktbuf,
(int *)&cb_args[0], (int *)&cb_args[1],
(int)cb_args[4], (char *)cb_args[3],
(struct lwm2mstub_instance_s *)cb_args[2]);
return 0;
}
/****************************************************************************
* name: fwup_srvop_handle
****************************************************************************/
static int32_t fwup_srvop_handle(FAR uint8_t *pktbuf, size_t pktsz,
FAR void **cb_args, size_t arglen)
{
uint8_t *ep;
FAR int *event = (FAR int *)&cb_args[0];
/* Expected unsolicited event
* %LWM2MOPEV: <event>[,....
* %LWM2MEV: <event>[,....
*/
*event = strtol((const char *)pktbuf, (char **)&ep, 10);
if ((*event == 0) && (pktbuf == ep))
{
return -1;
}
return 1;
}
/****************************************************************************
* name: fwupdate_notice_hndl
****************************************************************************/
static int32_t fwupdate_notice_hndl(FAR uint8_t *pktbuf, size_t pktsz,
FAR void **cb_args, size_t arglen)
{
return fwup_srvop_handle(pktbuf, pktsz, cb_args, arglen);
}
/****************************************************************************
* name: server_op_notice_hndl
****************************************************************************/
static int32_t server_op_notice_hndl(FAR uint8_t *pktbuf, size_t pktsz,
FAR void **cb_args, size_t arglen)
{
return fwup_srvop_handle(pktbuf, pktsz, cb_args, arglen);
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* name: lwm2mstub_get_handler
****************************************************************************/
lwm2mstub_hndl_t lwm2mstub_get_handler(FAR uint8_t **pktbuf, size_t *pktsz,
uint32_t *lcmdid)
{
char *head_pos;
struct urc_hdltbl_s *tbl;
size_t shift_size = 0;
*lcmdid = 0;
tbl = urc_idhandles;
while (tbl->head)
{
head_pos = strstr((char *)*pktbuf, tbl->head);
if (head_pos)
{
shift_size = head_pos - (char *)*pktbuf + strlen(tbl->head);
/* Follow shift_size to advance them */
*pktbuf += shift_size;
*pktsz -= shift_size;
*lcmdid = tbl->lcmdid;
return tbl->hdlr;
}
tbl++;
}
return NULL;
}

View file

@ -1,5 +1,5 @@
/****************************************************************************
* drivers/modem/altair/altmdm_pm_state.h
* drivers/modem/alt1250/altcom_lwm2m_hdlr.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@ -18,54 +18,48 @@
*
****************************************************************************/
#ifndef __DRIVERS_MODEM_ALTAIR_ALTMDM_PM_STATE_H
#define __DRIVERS_MODEM_ALTAIR_ALTMDM_PM_STATE_H
#if defined(CONFIG_MODEM_ALTMDM)
#ifndef __DRIVERS_MODEM_ALT1250_ALTCOM_LWM2M_HDLR_H
#define __DRIVERS_MODEM_ALT1250_ALTCOM_LWM2M_HDLR_H
/****************************************************************************
* Pre-processor Definitions
* Included Files
****************************************************************************/
#define MODEM_PM_INTERNAL_STATE_SLEEP (0)
#define MODEM_PM_INTERNAL_STATE_GOING_TO_WAKE (1)
#define MODEM_PM_INTERNAL_STATE_WAKE (2)
#define MODEM_PM_INTERNAL_STATE_GOING_TO_SLEEP (3)
#define MODEM_PM_INTERNAL_STATE_MAX (4)
#include <nuttx/config.h>
#include <stdbool.h>
#include <stdint.h>
/****************************************************************************
* Public Types
****************************************************************************/
typedef CODE int32_t (*lwm2mstub_hndl_t)(FAR uint8_t *, size_t,
FAR void **, size_t);
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: altmdm_pm_getstate
* Name: lwm2mstub_get_handler
*
* Description:
* Get current modem state.
* Get handler for lwm2m stub.
*
* Input Parameters:
* pktbuf - Pointer to the received packet.
* pktsz - Pointer to the data size after parsing the received packet.
* lcmdid - Pointer to a variable that stores the lwm2m LAPI command ID.
*
* Returned Value:
* If a lwm2m handler associated with the received packet is found, the
* function pointer of the handler is returned. If not found, returns NULL.
*
****************************************************************************/
uint32_t altmdm_pm_getstate(void);
lwm2mstub_hndl_t lwm2mstub_get_handler(FAR uint8_t **pktbuf,
FAR size_t *pktsz,
uint32_t *lcmdid);
/****************************************************************************
* Name: altmdm_pm_getinternalstate
*
* Description:
* Get internal modem state.
*
****************************************************************************/
uint32_t altmdm_pm_getinternalstate(void);
/****************************************************************************
* Name: altmdm_pm_setinternalstate
*
* Description:
* Set internal modem state.
*
****************************************************************************/
void altmdm_pm_setinternalstate(uint32_t state);
#endif
#endif /* __DRIVERS_MODEM_ALTAIR_ALTMDM_PM_STATE_H */
#endif /* __DRIVERS_MODEM_ALT1250_ALTCOM_LWM2M_HDLR_H */

View file

@ -0,0 +1,433 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_pkt.c
*
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/modem/alt1250.h>
#include <assert.h>
#include "altcom_pkt.h"
/****************************************************************************
* Private Types
****************************************************************************/
struct calculated_checksum
{
uint16_t header_checksum;
uint16_t body_checksum;
};
/****************************************************************************
* Private Data
****************************************************************************/
static uint8_t g_poweron_cmd[sizeof(struct altcom_cmdhdr_s) +
sizeof(struct altcom_cmdfooter_s)];
static uint8_t g_seqid;
static uint16_t g_transid;
/****************************************************************************
* Private Functions
****************************************************************************/
static uint16_t calc_checksum_v1(FAR uint8_t *ptr, uint16_t len)
{
uint32_t ret = 0x00;
uint16_t calctmp = 0x00;
uint16_t i;
int is_odd = len & 0x01;
for (i = 0; i < (len & 0xfffe); i += sizeof(uint16_t))
{
calctmp = *((uint16_t *)(ptr + i));
ret += ntohs(calctmp);
}
if (is_odd)
{
ret += *(ptr + i) << 8;
}
ret = ~((ret & 0xffff) + (ret >> 16));
return (uint16_t)ret;
}
static uint16_t calc_checksum_v4(FAR uint8_t *ptr, uint16_t len)
{
uint32_t ret = 0x00;
uint32_t calctmp = 0x00;
uint16_t i;
/* Data accumulating */
for (i = 0; i < len; i++)
{
calctmp += ptr[i];
}
ret = ~((calctmp & 0xffff) + (calctmp >> 16));
return (uint16_t)ret;
}
static inline void set_header_top(FAR struct altcom_cmdhdr_s *hdr,
uint8_t ver, uint16_t cid)
{
hdr->magic = htonl(ALTCOM_HDR_MAGICNUMBER);
hdr->ver = ver;
hdr->seqid = g_seqid++;
hdr->cmdid = htons(cid);
hdr->transid = htons(g_transid++);
hdr->datalen = 0;
}
static struct calculated_checksum convert_ntoh(
FAR struct altcom_cmdhdr_s *hdr)
{
struct calculated_checksum checksum;
hdr->cmdid = ntohs(hdr->cmdid);
hdr->transid = ntohs(hdr->transid);
hdr->datalen = ntohs(hdr->datalen);
if (hdr->ver == ALTCOM_VER1)
{
/* Only V1 has footer */
hdr->v1_options = ntohs(hdr->v1_options);
hdr->v1_checksum = ntohs(hdr->v1_checksum);
struct altcom_cmdfooter_s *footer
= (struct altcom_cmdfooter_s *)&hdr->payload[hdr->datalen];
checksum.body_checksum = calc_checksum_v1(&hdr->payload[0],
sizeof(struct altcom_cmdfooter_s)-2 + hdr->datalen);
footer->reserve = ntohs(footer->reserve);
footer->checksum = ntohs(footer->checksum);
}
else
{
hdr->v4_hdr_cksum = ntohs(hdr->v4_hdr_cksum);
checksum.body_checksum = calc_checksum_v4(&hdr->payload[0],
hdr->datalen);
hdr->v4_data_cksum = ntohs(hdr->v4_data_cksum);
}
return checksum;
}
static int check_valid_pkt(FAR struct altcom_cmdhdr_s *hdr,
uint16_t body_checksum)
{
int valid_version = ALTCOM_VERX;
if (hdr->ver == ALTCOM_VER1)
{
struct altcom_cmdfooter_s *footer
= (struct altcom_cmdfooter_s *)&hdr->payload[hdr->datalen];
if (footer->checksum == body_checksum)
{
valid_version = ALTCOM_VER1;
}
else
{
m_err("[V1] cmdid: 0x%04x cmdlen: %d, "
"body checksum: 0x%04x/0x%04x\n",
hdr->cmdid, hdr->datalen,
footer->checksum, body_checksum);
}
}
else if(hdr->ver == ALTCOM_VER4)
{
if (hdr->v4_data_cksum == body_checksum)
{
valid_version = ALTCOM_VER4;
}
else
{
m_err("[V4] cmdid: 0x%04x cmdlen: %d, "
"body checksum: 0x%04x/0x%04x\n",
hdr->cmdid, hdr->datalen,
hdr->v4_data_cksum, body_checksum);
}
}
return valid_version;
}
static int check_valid_reply(FAR struct altcom_cmdhdr_s *hdr,
uint16_t body_checksum)
{
int valid_version = ALTCOM_VERX;
valid_version = check_valid_pkt(hdr, body_checksum);
if (valid_version == ALTCOM_VER1)
{
if ((hdr->cmdid == (ALTCOM_CMDID_POWER_ON_V1 | ALTCOM_CMDID_REPLY_BIT))
&& (hdr->datalen == ALTCOM_CMD_POWER_ON_REPLY_SIZE))
{
valid_version = ALTCOM_VER1;
}
else
{
valid_version = ALTCOM_VERX;
}
}
else if(valid_version == ALTCOM_VER4)
{
if ((hdr->cmdid == (ALTCOM_CMDID_POWER_ON_V4 | ALTCOM_CMDID_REPLY_BIT))
&& (hdr->datalen == ALTCOM_CMD_POWER_ON_REPLY_SIZE))
{
valid_version = ALTCOM_VER4;
}
else
{
valid_version = ALTCOM_VERX;
}
}
return valid_version;
}
static bool is_header_ok(FAR struct altcom_cmdhdr_s *hdr)
{
uint16_t checksum;
if (hdr->ver == ALTCOM_VER1)
{
checksum = calc_checksum_v1((uint8_t *)hdr,
sizeof(struct altcom_cmdhdr_s) - sizeof(hdr->v1_checksum));
if (ntohs(hdr->v1_checksum) == checksum)
{
if (ntohs(hdr->datalen) + sizeof(struct altcom_cmdhdr_s)
+ sizeof(struct altcom_cmdfooter_s) <= ALTCOM_RX_PKT_SIZE_MAX)
{
return true;
}
else
{
m_err("[V1] Data length exceeding the buffer length: %d\n",
ntohs(hdr->datalen));
}
}
else
{
m_err("[V1] cmdid: 0x%04x cmdlen: %d, "
"header checksum: 0x%04x/0x%04x\n",
ntohs(hdr->cmdid), ntohs(hdr->datalen),
ntohs(hdr->v1_checksum), checksum);
}
}
else if (hdr->ver == ALTCOM_VER4)
{
checksum = calc_checksum_v4((uint8_t *)hdr,
sizeof(struct altcom_cmdhdr_s) - sizeof(hdr->v4_hdr_cksum) -
sizeof(hdr->v4_data_cksum));
if (ntohs(hdr->v4_hdr_cksum) == checksum)
{
if (ntohs(hdr->datalen) + sizeof(struct altcom_cmdhdr_s) <=
ALTCOM_RX_PKT_SIZE_MAX)
{
return true;
}
else
{
m_err("[V4] Data length exceeding the buffer length: %d\n",
ntohs(hdr->datalen));
}
}
else
{
m_err("[V4] cmdid: 0x%04x cmdlen: %d, "
"header checksum: 0x%04x/0x%04x\n",
ntohs(hdr->cmdid), ntohs(hdr->datalen),
ntohs(hdr->v4_hdr_cksum), checksum);
}
}
return false;
}
/****************************************************************************
* Public Functions
****************************************************************************/
bool altcom_is_v1pkt_ok(struct altcom_cmdhdr_s *cmdhdr)
{
struct calculated_checksum checksum;
if (!is_header_ok(cmdhdr))
{
return false;
}
checksum = convert_ntoh(cmdhdr);
return (check_valid_reply(cmdhdr, checksum.body_checksum) == ALTCOM_VER1)
&& (cmdhdr->payload[0] == LTE_RESULT_OK);
}
bool altcom_is_v4pkt_ok(struct altcom_cmdhdr_s *cmdhdr)
{
struct calculated_checksum checksum;
if (!is_header_ok(cmdhdr))
{
return false;
}
checksum = convert_ntoh(cmdhdr);
return (check_valid_reply(cmdhdr, checksum.body_checksum) == ALTCOM_VER4)
&& (cmdhdr->payload[0] == LTE_RESULT_OK);
}
FAR void *altcom_make_poweron_cmd_v1(int *sz)
{
struct altcom_cmdhdr_s *hdr = (struct altcom_cmdhdr_s *)g_poweron_cmd;
struct altcom_cmdfooter_s *footer
= (struct altcom_cmdfooter_s *)&hdr->payload[0];
set_header_top(hdr, ALTCOM_VER1, ALTCOM_CMDID_POWER_ON_V1);
hdr->v1_options = htons(ALTCOM_CMDOPT_CHECKSUM_EN);
hdr->v1_checksum =
htons(calc_checksum_v1((uint8_t *)hdr,
sizeof(struct altcom_cmdhdr_s) - 2));
footer->reserve = 0;
footer->checksum =
htons(calc_checksum_v1(&hdr->payload[0],
sizeof(struct altcom_cmdfooter_s) - 2));
/* No payload of this altcom command.
* So sending size is just header and footer size
*/
*sz = sizeof(struct altcom_cmdhdr_s) + sizeof(struct altcom_cmdfooter_s);
return g_poweron_cmd;
}
FAR void *altcom_make_poweron_cmd_v4(int *sz)
{
struct altcom_cmdhdr_s *hdr = (struct altcom_cmdhdr_s *)g_poweron_cmd;
set_header_top(hdr, ALTCOM_VER4, ALTCOM_CMDID_POWER_ON_V4);
hdr->v4_hdr_cksum = htons(calc_checksum_v4((uint8_t *)hdr,
sizeof(struct altcom_cmdhdr_s)-4));
hdr->v4_data_cksum = htons(calc_checksum_v4(&hdr->payload[0], 0));
/* No payload of this altcom command. So sending size is just header size */
*sz = sizeof(struct altcom_cmdhdr_s);
return g_poweron_cmd;
}
int altcom_is_pkt_ok(FAR uint8_t *pkt, int sz)
{
struct calculated_checksum checksum;
int ver;
int ret = OK;
FAR struct altcom_cmdhdr_s *hdr = (FAR struct altcom_cmdhdr_s *)pkt;
int remlen;
if (!is_header_ok(hdr))
{
return -EPROTO;
}
remlen = get_pktlen(hdr->ver, ntohs(hdr->datalen)) - sz;
if (remlen > 0)
{
/* Cases in which fragmented packets are received. */
return remlen;
}
else if (remlen < 0)
{
/* The case where the received data length becomes
* larger than the payload length set in the header.
*/
return -EPROTO;
}
/* Whole packets are received. So check the validity of the packets. */
checksum = convert_ntoh((FAR struct altcom_cmdhdr_s *)pkt);
ver = check_valid_pkt((FAR struct altcom_cmdhdr_s *)pkt,
checksum.body_checksum);
if (ver == ALTCOM_VERX)
{
ret = -EPROTO;
}
return ret;
}
uint16_t altcom_make_header(FAR struct altcom_cmdhdr_s *hdr,
uint8_t ver, uint16_t cid, uint16_t sz)
{
uint16_t tid = g_transid;
hdr->magic = htonl(ALTCOM_HDR_MAGICNUMBER);
hdr->ver = ver;
hdr->seqid = g_seqid++;
hdr->cmdid = htons(cid);
hdr->transid = htons(g_transid++);
hdr->datalen = htons(sz);
if (ver == ALTCOM_VER1)
{
struct altcom_cmdfooter_s *footer
= (struct altcom_cmdfooter_s *)&hdr->payload[sz];
hdr->v1_options = htons(ALTCOM_CMDOPT_CHECKSUM_EN);
hdr->v1_checksum =
htons(calc_checksum_v1((uint8_t *)hdr,
sizeof(struct altcom_cmdhdr_s) - 2));
footer->reserve = 0;
footer->checksum =
htons(calc_checksum_v1(&hdr->payload[0],
sizeof(struct altcom_cmdfooter_s) - 2 + sz));
}
else if (ver == ALTCOM_VER4)
{
hdr->v4_hdr_cksum = htons(calc_checksum_v4((uint8_t *)hdr,
sizeof(struct altcom_cmdhdr_s)-4));
hdr->v4_data_cksum = htons(calc_checksum_v4(&hdr->payload[0], sz));
}
else
{
DEBUGASSERT(0);
}
return tid;
}

View file

@ -0,0 +1,414 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_pkt.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 __DRIVERS_MODEM_ALT1250_ALTCOM_PKT_H
#define __DRIVERS_MODEM_ALT1250_ALTCOM_PKT_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include <arpa/inet.h>
#include <nuttx/modem/alt1250.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define ALTCOM_HDR_MAGICNUMBER (0xFEEDBAC5)
#define ALTCOM_CMDOPT_CHECKSUM_EN (1 << 0)
#define ALTCOM_PAYLOAD_SIZE_MAX (4112)
#define ALTCOM_PAYLOAD_SIZE_MAX_V4 (3092)
#define ALTCOM_PKT_SIZE_MAX (ALTCOM_PAYLOAD_SIZE_MAX \
+ sizeof(struct altcom_cmdhdr_s) \
+ sizeof(struct altcom_cmdfooter_s))
#define ALTCOM_RX_PKT_SIZE_MAX (ALTCOM_PAYLOAD_SIZE_MAX_V4 \
+ sizeof(struct altcom_cmdhdr_s))
#define LTE_RESULT_OK (0) /**< Result code on success */
#define LTE_RESULT_ERROR (1) /**< Result code on failure */
#define LTE_RESULT_CANCEL (2) /**< Result code on cancel */
#define ALTCOM_CMD_POWER_ON_REPLY_SIZE (1)
/****************************************************************************
* Public Types
****************************************************************************/
begin_packed_struct struct altcom_cmdhdr_s
{
uint32_t magic;
uint8_t ver;
uint8_t seqid;
uint16_t cmdid;
uint16_t transid;
uint16_t datalen;
union
{
uint16_t v1_options;
uint16_t v4_hdr_cksum;
};
union
{
uint16_t v1_checksum;
uint16_t v4_data_cksum;
};
uint8_t payload[0];
} end_packed_struct;
begin_packed_struct struct altcom_cmdfooter_s
{
uint16_t reserve;
uint16_t checksum;
} end_packed_struct;
begin_packed_struct struct altcom_errind_s
{
uint8_t ver;
uint8_t seqid;
uint16_t cmdid;
uint16_t transid;
uint16_t dtlen;
union
{
uint16_t v1_options;
uint16_t v4_hdr_cksum;
};
union
{
uint16_t v1_checksum;
uint16_t v4_data_cksum;
};
} end_packed_struct;
/****************************************************************************
* Inline Functions
****************************************************************************/
static inline int is_errind(uint16_t cmdid)
{
return (cmdid == ALTCOM_CMDID_ERRIND);
}
static inline uint16_t parse_cid(FAR struct altcom_cmdhdr_s *hdr)
{
return hdr->cmdid;
}
static inline uint16_t parse_tid(FAR struct altcom_cmdhdr_s *hdr)
{
return hdr->transid;
}
static inline uint16_t parse_cid4errind(FAR struct altcom_cmdhdr_s *hdr)
{
FAR struct altcom_errind_s *pkt =
(FAR struct altcom_errind_s *)&hdr->payload[0];
return ntohl(pkt->cmdid);
}
static inline uint16_t parse_tid4errind(FAR struct altcom_cmdhdr_s *hdr)
{
FAR struct altcom_errind_s *pkt =
(FAR struct altcom_errind_s *)&hdr->payload[0];
return ntohl(pkt->transid);
}
static inline FAR uint8_t *get_payload(FAR struct altcom_cmdhdr_s *hdr)
{
return &hdr->payload[0];
}
static inline uint16_t get_payload_len(FAR struct altcom_cmdhdr_s *hdr)
{
return hdr->datalen;
}
static inline FAR uint8_t get_altver(FAR struct altcom_cmdhdr_s *hdr)
{
return hdr->ver;
}
static inline uint16_t get_pktlen(uint8_t ver, uint16_t payloadlen)
{
if (ver == ALTCOM_VER1)
{
payloadlen += sizeof(struct altcom_cmdhdr_s) +
sizeof(struct altcom_cmdfooter_s);
}
else if (ver == ALTCOM_VER4)
{
payloadlen += sizeof(struct altcom_cmdhdr_s);
}
else
{
DEBUGASSERT(0);
}
return payloadlen;
}
static inline uint16_t convert_cid2v1(uint16_t cid)
{
if ((cid >= APICMDID_SOCK_ACCEPT) && (cid <= APICMDID_SOCK_SETSOCKOPT))
{
return cid;
}
if ((cid >= APICMDID_SMS_INIT) && (cid <= APICMDID_SMS_DELETE))
{
return cid;
}
if ((cid >= APICMDID_GET_VERSION_V4) && (cid <= APICMDID_SET_PSM_V4))
{
return (cid + 1);
}
if ((cid >= APICMDID_RADIO_ON_V4) && (cid <= APICMDID_ACTIVATE_PDN_V4))
{
return (cid - 0x2ec);
}
if ((cid >= APICMDID_DEACTIVATE_PDN_V4) &&
(cid <= APICMDID_REPORT_NETINFO_V4))
{
return (cid - 0x2ed);
}
if (cid == (APICMDID_ERRINFO_V4 & ~ALTCOM_CMDID_REPLY_BIT))
{
return APICMDID_ERRINFO;
}
if (cid == APICMDID_GET_SIMINFO_V4)
{
return APICMDID_GET_SIMINFO;
}
if (cid == APICMDID_GET_QUALITY_V4)
{
return APICMDID_GET_QUALITY;
}
if (cid == APICMDID_ACTIVATE_PDN_CANCEL_V4)
{
return APICMDID_ACTIVATE_PDN_CANCEL;
}
if (cid == APICMDID_GET_CELLINFO_V4)
{
return APICMDID_GET_CELLINFO;
}
if (cid == APICMDID_GET_RAT_V4)
{
return APICMDID_GET_RAT;
}
if (cid == APICMDID_SET_RAT_V4)
{
return APICMDID_SET_RAT;
}
if (cid == APICMDID_SEND_ATCMD_V4)
{
return APICMDID_SEND_ATCMD;
}
if (cid == APICMDID_URC_EVENT_V4)
{
return APICMDID_URC_EVENT;
}
if ((cid >= APICMDID_FW_INJECTDELTAIMG_V4) &&
(cid <= APICMDID_FW_GETUPDATERESULT_V4))
{
return (cid + 0xdd0);
}
if (cid == APICMDID_TLS_CONFIG_VERIFY_CALLBACK_V4)
{
return APICMDID_TLS_CONFIG_VERIFY_CALLBACK;
}
if (cid == APICMDID_CLOGS_V4)
{
return APICMDID_CLOGS;
}
if (cid == APICMDID_LOGLIST_V4)
{
return APICMDID_LOGLIST;
}
#ifdef CONFIG_MODEM_ALT1250_LOG_ACCESS
if ((cid >= APICMDID_LOGOPEN_V4) && (cid <= APICMDID_LOGLSEEK_V4))
{
return cid + (APICMDID_LOGOPEN - APICMDID_LOGOPEN_V4);
}
#endif /* CONFIG_MODEM_ALT1250_LOG_ACCESS */
return APICMDID_UNKNOWN;
}
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: altcom_make_poweron_cmd_v1
*
* Description:
* Create an ALTCOM command for POWER_ON_REQ of protocol version 1.
*
* Input Parameters:
* sz - Variable to put the length of the command created.
*
* Returned Value:
* Returns the buffer pointer of the created command.
*
****************************************************************************/
FAR void *altcom_make_poweron_cmd_v1(FAR int *sz);
/****************************************************************************
* Name: altcom_make_poweron_cmd_v4
*
* Description:
* Create an ALTCOM command for POWER_ON_REQ of protocol version 4.
*
* Input Parameters:
* sz - Variable to put the length of the command created.
*
* Returned Value:
* Returns the buffer pointer of the created command.
*
****************************************************************************/
FAR void *altcom_make_poweron_cmd_v4(FAR int *sz);
/****************************************************************************
* Name: altcom_is_v1pkt_ok
*
* Description:
* Check if the POWER_ON_RES command of protocol version 1 is OK.
*
* Input Parameters:
* cmdhdr - Pointer to the received packet.
*
* Returned Value:
* Returns true if the POWER_ON_RES command of protocol version 1 is OK,
* false otherwise.
*
****************************************************************************/
bool altcom_is_v1pkt_ok(FAR struct altcom_cmdhdr_s *cmdhdr);
/****************************************************************************
* Name: altcom_is_v4pkt_ok
*
* Description:
* Check if the POWER_ON_RES command of protocol version 4 is OK.
*
* Input Parameters:
* cmdhdr - Pointer to the received packet.
*
* Returned Value:
* Returns true if the POWER_ON_RES command of protocol version 4 is OK,
* false otherwise.
*
****************************************************************************/
bool altcom_is_v4pkt_ok(FAR struct altcom_cmdhdr_s *cmdhdr);
/****************************************************************************
* Name: altcom_is_pkt_ok
*
* Description:
* Check the validity of the ALTCOM command received from ALT1250.
* In the case of a fragmented packet, returns the length of the remaining
* fragmented packets.
*
* Input Parameters:
* pkt - Pointer to the received packet.
* sz - Size of received packets.
*
* Returned Value:
* If the received packet is valid, 0 is returned. If the received packet
* is a fragmented packet, the length of the remaining fragmented packet is
* returned. If the received packet is not valid, a negative value is
* returned.
*
****************************************************************************/
int altcom_is_pkt_ok(FAR uint8_t *pkt, int sz);
/****************************************************************************
* Name: altcom_set_header_top
*
* Description:
* Set the version and command ID among the ALTCOM command headers.
*
* Input Parameters:
* hdr - Pointer to ALTCOM command header.
* ver - ALTCOM protocol version.
* cid - ALTCOM command ID.
*
* Returned Value:
* None
*
****************************************************************************/
void altcom_set_header_top(FAR struct altcom_cmdhdr_s *hdr,
uint8_t ver, uint16_t cid);
/****************************************************************************
* Name: altcom_make_header
*
* Description:
* Create ALTCOM command header.
*
* Input Parameters:
* hdr - Pointer to ALTCOM command header.
* ver - ALTCOM protocol version.
* cid - ALTCOM command ID.
* sz - Body size of the ALTCOM command.
*
* Returned Value:
* Returns the transaction ID of the ALTCOM command.
*
****************************************************************************/
uint16_t altcom_make_header(FAR struct altcom_cmdhdr_s *hdr,
uint8_t ver, uint16_t cid, uint16_t sz);
#endif /* __DRIVERS_MODEM_ALT1250_ALTCOM_PKT_H */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,240 @@
/****************************************************************************
* drivers/modem/alt1250/altmdm.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 __DRIVERS_MODEM_ALT1250_ALTMDM_H
#define __DRIVERS_MODEM_ALT1250_ALTMDM_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/modem/alt1250.h>
#include <nuttx/spi/spi.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define ALTMDM_RETURN_RESET_V1 (-1)
#define ALTMDM_RETURN_NOTREADY (-2)
#define ALTMDM_RETURN_CANCELED (-3)
#define ALTMDM_RETURN_RESET_V4 (-4)
#define ALTMDM_RETURN_RESET_PKT (-5)
#define ALTMDM_RETURN_EXIT (-6)
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: altmdm_init
*
* Description:
* Initialize the ALTMDM driver.
*
* Input Parameters:
* spidev - An SPI instance that communicates with the ALT1250.
* lower - An instance of the lower interface.
*
* Returned Value:
* Returns 0 on success.
* When an error occurs, a negative value is returned.
*
****************************************************************************/
int altmdm_init(FAR struct spi_dev_s *spidev,
FAR const struct alt1250_lower_s *lower);
/****************************************************************************
* Name: altmdm_fin
*
* Description:
* Finalize the ALTMDM driver.
*
* Input Parameters:
* None
*
* Returned Value:
* Returns 0 on success.
* When an error occurs, a negative value is returned.
*
****************************************************************************/
int altmdm_fin(void);
/****************************************************************************
* Name: altmdm_read
*
* Description:
* Read an SPI packet sent from the ALT1250.
*
* Input Parameters:
* buff - A buffer for reading SPI packets.
* sz - Buffer size.
*
* Returned Value:
* Returns the size of the read SPI packet. Otherwise, it returns a
* negative value. See the macro prefixed with ALTMDM_RETURN_ as defined
* in this file.
*
****************************************************************************/
int altmdm_read(FAR uint8_t *buff, int sz);
/****************************************************************************
* Name: altmdm_write
*
* Description:
* Write an SPI packet to the ALT1250.
*
* Input Parameters:
* buff - A buffer for sending SPI packets.
* sz - Buffer size.
*
* Returned Value:
* Returns the size of the write SPI packet. Otherwise, it returns a
* negative value. See the macro prefixed with ALTMDM_RETURN_ as defined
* in this file.
*
****************************************************************************/
int altmdm_write(FAR uint8_t *buff, int sz);
/****************************************************************************
* Name: altmdm_take_wlock
*
* Description:
* Take a wakelock. The ALT1250 will not be able to sleep until
* it is released with altmdm_take_wloc().
*
* Input Parameters:
* None
*
* Returned Value:
* Returns the count of wakelocks currently acquired.
*
****************************************************************************/
int altmdm_take_wlock(void);
/****************************************************************************
* Name: altmdm_give_wlock
*
* Description:
* Give a wakelock. If the wakelock count is 0, the ALT1250 can sleep.
*
* Input Parameters:
* None
*
* Returned Value:
* Returns the count of wakelocks currently acquired.
*
****************************************************************************/
int altmdm_give_wlock(void);
/****************************************************************************
* Name: altmdm_poweron
*
* Description:
* Turn on the power of the ALT1250.
*
* Input Parameters:
* None
*
* Returned Value:
* Returns 0 on success.
* When an error occurs, a negative value is returned.
*
****************************************************************************/
int altmdm_poweron(void);
/****************************************************************************
* Name: altmdm_poweroff
*
* Description:
* Turn off the power of the ALT1250.
*
* Input Parameters:
* None
*
* Returned Value:
* Returns 0 on success.
* When an error occurs, a negative value is returned.
*
****************************************************************************/
int altmdm_poweroff(void);
/****************************************************************************
* Name: altmdm_reset
*
* Description:
* Reset the ALT1250.
*
* Input Parameters:
* None
*
* Returned Value:
* Returns 0 on success.
* When an error occurs, a negative value is returned.
*
****************************************************************************/
int altmdm_reset(void);
/****************************************************************************
* Name: altmdm_get_reset_reason
*
* Description:
* Returns whether the reset was initiated by the user or ALT1250.
*
* Input Parameters:
* None
*
* Returned Value:
* Returns LTE_RESTART_USER_INITIATED if it was reset by the user
* or LTE_RESTART_MODEM_INITIATED by the ALT1250.
*
****************************************************************************/
uint32_t altmdm_get_reset_reason(void);
/****************************************************************************
* Name: altmdm_get_protoversion
*
* Description:
* Returns the protocol version of the ALTCOM command.
*
* Input Parameters:
* None
*
* Returned Value:
* Returns the protocol version of the ALTCOM command. ALTCOM_VERX means
* that the ALTCOM version check sequence has not been completed or is not
* supported.
*
****************************************************************************/
uint8_t altmdm_get_protoversion(void);
#endif /* __DRIVERS_MODEM_ALT1250_ALTMDM_H */

View file

@ -0,0 +1,209 @@
/****************************************************************************
* drivers/modem/alt1250/altmdm_event.c
*
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <time.h>
#include <errno.h>
#include <nuttx/irq.h>
#include <nuttx/semaphore.h>
#include "altmdm_event.h"
/****************************************************************************
* Private Functions
****************************************************************************/
static int set_expiretime(int expire_time, FAR struct timespec *set_time)
{
struct timespec curr_time;
/* Get current time. */
if (clock_gettime(CLOCK_REALTIME, &curr_time) != OK)
{
return ERROR;
}
set_time->tv_sec = expire_time / 1000;
set_time->tv_nsec =
(expire_time - (set_time->tv_sec * 1000)) * 1000 * 1000;
set_time->tv_sec += curr_time.tv_sec;
set_time->tv_nsec += curr_time.tv_nsec;
/* Check more than 1 sec. */
if (set_time->tv_nsec >= (1000 * 1000 * 1000))
{
set_time->tv_sec += 1;
set_time->tv_nsec -= (1000 * 1000 * 1000);
}
return OK;
}
/****************************************************************************
* Public Functions
****************************************************************************/
int altmdm_event_init(FAR struct altmdm_event_s *evt)
{
int ret;
evt->event = 0;
ret = nxsem_init(&evt->sem, 0, 0);
return ret;
}
int altmdm_event_destroy(FAR struct altmdm_event_s *evt)
{
int ret;
ret = nxsem_destroy(&evt->sem);
return ret;
}
uint32_t altmdm_event_wait(FAR struct altmdm_event_s *evt,
uint32_t event, bool with_clear, int timeout_ms)
{
int ret;
struct timespec abs_time;
irqstate_t flags;
uint32_t ptn;
/* Check argument. */
if (evt == NULL)
{
return 0;
}
if (timeout_ms > 0)
{
if (set_expiretime(timeout_ms, &abs_time) != OK)
{
return 0;
}
}
while (1)
{
flags = enter_critical_section();
ptn = (evt->event & event);
if (ptn != 0)
{
/* Clear read event. */
if (with_clear)
{
evt->event = (evt->event & ~ptn);
}
/* Clear the semaphore posted by altmdm_sys_setflag. */
while (1)
{
if (nxsem_trywait(&evt->sem) < 0)
{
break;
}
}
leave_critical_section(flags);
/* Go out while(1) as expected event is happened */
break;
}
leave_critical_section(flags);
/* Wait for any event is occured related on the semaphore.. */
if (timeout_ms > 0)
{
/* Wait with timeout. */
ret = nxsem_timedwait_uninterruptible(&evt->sem, &abs_time);
}
else
{
/* Wait it forever. */
ret = nxsem_wait_uninterruptible(&evt->sem);
}
/* Error check */
if (ret < 0)
{
ptn = 0;
break;
}
}
/* end of while(1) */
return ptn;
}
int altmdm_event_set(FAR struct altmdm_event_s *evt, uint32_t event)
{
int ret;
irqstate_t flags;
flags = enter_critical_section();
evt->event = (evt->event | event);
leave_critical_section(flags);
ret = nxsem_post(&evt->sem);
return ret;
}
int altmdm_event_clear(FAR struct altmdm_event_s *evt, uint32_t event)
{
irqstate_t flags;
flags = enter_critical_section();
evt->event = (evt->event & ~event);
leave_critical_section(flags);
return OK;
}
uint32_t altmdm_event_refer(FAR struct altmdm_event_s *evt)
{
uint32_t event;
irqstate_t flags;
flags = enter_critical_section();
event = evt->event;
leave_critical_section(flags);
return event;
}

View file

@ -0,0 +1,156 @@
/****************************************************************************
* drivers/modem/alt1250/altmdm_event.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 __DRIVERS_MODEM_ALT1250_ALTMDM_EVENT_H
#define __DRIVERS_MODEM_ALT1250_ALTMDM_EVENT_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <semaphore.h>
/****************************************************************************
* Public Types
****************************************************************************/
struct altmdm_event_s
{
sem_t sem;
uint32_t event;
};
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: altmdm_event_init
*
* Description:
* Initialize the event flag.
*
* Input Parameters:
* evt - An instance pointer to the event flag.
*
* Returned Value:
* Returns 0 on success.
* When an error occurs, a negative value is returned.
*
****************************************************************************/
int altmdm_event_init(FAR struct altmdm_event_s *evt);
/****************************************************************************
* Name: altmdm_event_destroy
*
* Description:
* Destroy the event flag.
*
* Input Parameters:
* evt - An instance pointer to the event flag.
*
* Returned Value:
* Returns 0 on success.
* When an error occurs, a negative value is returned.
*
****************************************************************************/
int altmdm_event_destroy(FAR struct altmdm_event_s *evt);
/****************************************************************************
* Name: altmdm_event_wait
*
* Description:
* Wait for the specified event.
*
* Input Parameters:
* evt - An instance pointer to the event flag.
* event - A bitmap that means an event to wait for.
* with_clear - A flag to clear the event flag when an event is received.
* timeout_ms - Time-out value to wait for an event. 0 means infinite wait.
*
* Returned Value:
* Returns the received event. When an error occurs,
* a negative value is returned.
*
****************************************************************************/
uint32_t altmdm_event_wait(FAR struct altmdm_event_s *evt,
uint32_t event, bool with_clear, int timeout_ms);
/****************************************************************************
* Name: altmdm_event_set
*
* Description:
* Send event.
*
* Input Parameters:
* evt - An instance pointer to the event flag.
* event - Bitmap of the event to send.
*
* Returned Value:
* Returns 0 on success.
* When an error occurs, a negative value is returned.
*
****************************************************************************/
int altmdm_event_set(FAR struct altmdm_event_s *evt, uint32_t event);
/****************************************************************************
* Name: altmdm_event_clear
*
* Description:
* Clear event.
*
* Input Parameters:
* evt - An instance pointer to the event flag.
* event - Bitmap of the event to clear.
*
* Returned Value:
* Returns 0 on success.
* When an error occurs, a negative value is returned.
*
****************************************************************************/
int altmdm_event_clear(FAR struct altmdm_event_s *evt, uint32_t event);
/****************************************************************************
* Name: altmdm_event_refer
*
* Description:
* Get which event is being received.
*
* Input Parameters:
* evt - An instance pointer to the event flag.
*
* Returned Value:
* Returns the received event. When an error occurs,
* a negative value is returned.
*
****************************************************************************/
uint32_t altmdm_event_refer(FAR struct altmdm_event_s *evt);
#endif /* __DRIVERS_MODEM_ALT1250_ALTMDM_EVENT_H */

View file

@ -0,0 +1,144 @@
/****************************************************************************
* drivers/modem/alt1250/altmdm_spi.c
*
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <nuttx/modem/alt1250.h>
#include "altmdm_spi.h"
/****************************************************************************
* Public Functions
****************************************************************************/
void altmdm_spipkt_init(FAR altmdm_spipkt_t *pkt)
{
pkt->header = 0;
pkt->buffer = NULL;
pkt->buff_size = 0;
}
void altmdm_set_spipkt_rxbuffer(FAR altmdm_spipkt_t *pkt, FAR void *buf,
uint16_t sz)
{
pkt->buffer = buf;
pkt->buff_size = sz;
}
void altmdm_set_spipkt_txbuffer(FAR altmdm_spipkt_t *pkt, FAR void *buf,
uint16_t sz)
{
uint16_t total_sz;
if (sz <= ALTSPI_MAX_PKTSIZE)
{
sz &= ALTSPI_PKT_SIZEMASK;
total_sz = (sz + (ALTSPI_PKT_WORDSIZE - 1)) &
~(ALTSPI_PKT_WORDSIZE - 1);
pkt->header = (total_sz << ALTSPI_PKT_TOTALSIZE_POS) + sz;
pkt->buffer = buf;
pkt->buff_size = sz;
}
}
void altmdm_overwrite_body_size(FAR altmdm_spipkt_t *pkt, uint16_t sz)
{
uint16_t total_sz;
if (sz <= ALTSPI_MAX_PKTSIZE)
{
sz &= ALTSPI_PKT_SIZEMASK;
total_sz = (sz + (ALTSPI_PKT_WORDSIZE - 1)) &
~(ALTSPI_PKT_WORDSIZE - 1);
pkt->header = (pkt->header & ALTSPI_STATUSMASK) |
((total_sz << ALTSPI_PKT_TOTALSIZE_POS) + sz);
}
}
void altmdm_set_sleeppkt(FAR altmdm_spipkt_t *pkt)
{
altmdm_set_spipkt_txbuffer(pkt, NULL, 0);
pkt->header |= ALTSPI_SLEEP_BIT;
}
bool altmdm_is_valid_spipkt_header(FAR altmdm_spipkt_t *pkt)
{
uint16_t actual_size;
uint16_t total_size;
actual_size = pkt_actual_size(pkt);
total_size = pkt_total_size(pkt);
return ((actual_size <= ALTSPI_MAX_PKTSIZE) &&
(actual_size <= pkt->buff_size) &&
(((actual_size + (ALTSPI_PKT_WORDSIZE - 1)) & ~(ALTSPI_PKT_WORDSIZE - 1))
== total_size));
}
bool altmdm_is_sleeppkt_ok(FAR altmdm_spipkt_t *pkt)
{
return (strncmp(pkt->buffer, "OKOK", 4) == 0);
}
void altmdm_do_hdr_transaction(FAR struct spi_dev_s *spidev,
FAR const struct alt1250_lower_s *lower, FAR altmdm_spipkt_t *tx_pkt,
FAR altmdm_spipkt_t *rx_pkt)
{
/* Alt1250 is network endian, so swap tx header value. */
tx_pkt->header = htonl(tx_pkt->header);
SPI_EXCHANGE(spidev, &tx_pkt->header, &rx_pkt->header, ALTSPI_PKT_HDRSIZE);
/* Get correct endian values after exchanged */
rx_pkt->header = ntohl(rx_pkt->header);
tx_pkt->header = ntohl(tx_pkt->header);
m_info("Header TRX done. rx: 0x%08lx, tx: 0x%08lx\n",
rx_pkt->header, tx_pkt->header);
}
void altmdm_do_body_transaction(FAR struct spi_dev_s *spidev,
FAR const struct alt1250_lower_s *lower, FAR altmdm_spipkt_t *tx_pkt,
FAR altmdm_spipkt_t *rx_pkt)
{
size_t exchange_size;
/* Larger size is exchange size */
exchange_size = pkt_total_size(tx_pkt) > pkt_total_size(rx_pkt)
? pkt_total_size(tx_pkt) : pkt_total_size(rx_pkt);
SPI_EXCHANGE(spidev, tx_pkt->buffer, rx_pkt->buffer, exchange_size);
m_info("Body TRX done. ex size: %d, rx size: %d/%d, tx size: %d/%d\n",
exchange_size, pkt_actual_size(rx_pkt), pkt_total_size(rx_pkt),
pkt_actual_size(tx_pkt), pkt_total_size(tx_pkt));
}

View file

@ -0,0 +1,280 @@
/****************************************************************************
* drivers/modem/alt1250/altmdm_spi.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 __DRIVERS_MODEM_ALT1250_ALTMDM_SPI_H
#define __DRIVERS_MODEM_ALT1250_ALTMDM_SPI_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define ALTSPI_PKT_STATUS_POS (28)
#define ALTSPI_SLEEP_BIT (1 << 28)
#define ALTSPI_RESET_BIT (1 << 30)
#define ALTSPI_BUFFFULL_BIT (1 << 31)
#define ALTSPI_STATUSMASK (0x0f << ALTSPI_PKT_STATUS_POS)
#define ALTSPI_PKT_TOTALSIZE_POS (14)
#define ALTSPI_PKT_SIZEMASK ((1 << 14) - 1)
#define ALTSPI_PKT_WORDSIZE (4)
#define ALTSPI_PKT_HDRSIZE ALTSPI_PKT_WORDSIZE
#define ALTSPI_MAX_PKTSIZE (2064)
/****************************************************************************
* Public Types
****************************************************************************/
typedef struct altmdm_spipkt_s
{
uint32_t header; /* Buffer for SPI protocol headers to be exchanged with
* the ALT1250. */
void *buffer; /* Buffer for SPI protocol body to be exchanged with
* the ALT1250. */
int buff_size; /* Buffer size of the SPI protocol body. Maximum size
* is ALTSPI_MAX_PKTSIZE. */
} altmdm_spipkt_t;
/****************************************************************************
* Inline Functions
****************************************************************************/
static inline FAR void *get_pkt_buffer(FAR altmdm_spipkt_t *pkt)
{
return pkt->buffer;
}
static inline int get_pkt_size(FAR altmdm_spipkt_t *pkt)
{
return pkt->buff_size;
}
static inline int get_spipayload_maxsize(void)
{
return ALTSPI_MAX_PKTSIZE;
}
static inline uint16_t pkt_total_size(FAR altmdm_spipkt_t *pkt)
{
return (uint16_t)
((pkt->header >> ALTSPI_PKT_TOTALSIZE_POS) & ALTSPI_PKT_SIZEMASK);
}
static inline uint16_t pkt_actual_size(FAR altmdm_spipkt_t *pkt)
{
return (uint16_t)(pkt->header & ALTSPI_PKT_SIZEMASK);
}
static inline int is_sleep_pkt(FAR altmdm_spipkt_t *pkt)
{
return (pkt->header & ALTSPI_SLEEP_BIT);
}
static inline int is_reset_pkt(FAR altmdm_spipkt_t *pkt)
{
return (pkt->header & ALTSPI_RESET_BIT);
}
static inline int has_sendrequest(FAR altmdm_spipkt_t *pkt)
{
return (pkt->buffer != NULL);
}
static inline int is_buffer_full(FAR altmdm_spipkt_t *pkt)
{
return (pkt->header & ALTSPI_BUFFFULL_BIT);
}
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: altmdm_spipkt_init
*
* Description:
* Initialize SPI packet structure.
*
* Input Parameters:
* pkt - Pointer to SPI packet structure.
*
* Returned Value:
* None
*
****************************************************************************/
void altmdm_spipkt_init(FAR altmdm_spipkt_t *pkt);
/****************************************************************************
* Name: altmdm_set_spipkt_rxbuffer
*
* Description:
* Sets parameters of the SPI packet structure for reception.
*
* Input Parameters:
* pkt - Pointer to SPI packet structure for reception.
* buf - Buffer for SPI protocol body reception.
* sz - Buffer size for SPI protocol body reception.
*
* Returned Value:
* None
*
****************************************************************************/
void altmdm_set_spipkt_rxbuffer(FAR altmdm_spipkt_t *pkt, FAR void *buf,
uint16_t sz);
/****************************************************************************
* Name: altmdm_set_spipkt_txbuffer
*
* Description:
* Set the parameters of the SPI packet structure for sending.
*
* Input Parameters:
* pkt - Pointer to SPI packet structure for sending.
* buf - Buffer for SPI protocol body sending.
* sz - Buffer size for SPI protocol body sending.
*
* Returned Value:
* None
*
****************************************************************************/
void altmdm_set_spipkt_txbuffer(FAR altmdm_spipkt_t *pkt, FAR void *buf,
uint16_t sz);
/****************************************************************************
* Name: altmdm_overwrite_body_size
*
* Description:
* Overwrites the body size of the SPI packet structure.
*
* Input Parameters:
* pkt - Pointer to SPI packet structure.
* sz - Buffer size for SPI protocol body sending.
*
* Returned Value:
* None
*
****************************************************************************/
void altmdm_overwrite_body_size(FAR altmdm_spipkt_t *pkt, uint16_t sz);
/****************************************************************************
* Name: altmdm_set_sleeppkt
*
* Description:
* Set sleep packet parameters to SPI packet structure.
*
* Input Parameters:
* pkt - Pointer to SPI packet structure.
*
* Returned Value:
* None
*
****************************************************************************/
void altmdm_set_sleeppkt(FAR altmdm_spipkt_t *pkt);
/****************************************************************************
* Name: altmdm_is_valid_spipkt_header
*
* Description:
* Checks if the header received from ALT1250 is valid.
*
* Input Parameters:
* pkt - Pointer to SPI packet structure for reception.
*
* Returned Value:
* Returns true if the header is valid, false otherwise.
*
****************************************************************************/
bool altmdm_is_valid_spipkt_header(FAR altmdm_spipkt_t *pkt);
/****************************************************************************
* Name: altmdm_is_sleeppkt_ok
*
* Description:
* Checks if the sleep packet received from ALT1250 is OK.
*
* Input Parameters:
* pkt - Pointer to SPI packet structure for reception.
*
* Returned Value:
* Returns true if the contents of the sleep packet are OK,
* false otherwise.
*
****************************************************************************/
bool altmdm_is_sleeppkt_ok(FAR altmdm_spipkt_t *pkt);
/****************************************************************************
* Name: altmdm_do_hdr_transaction
*
* Description:
* Initiates a transaction for the SPI protocol header.
*
* Input Parameters:
* spidev - An SPI instance that communicates with the ALT1250.
* lower - An instance of the lower interface.
* tx_pkt - Pointer to SPI packet structure for sending.
* rx_pkt - Pointer to SPI packet structure for reception.
*
* Returned Value:
* None
*
****************************************************************************/
void altmdm_do_hdr_transaction(FAR struct spi_dev_s *spidev,
FAR const struct alt1250_lower_s *lower, FAR altmdm_spipkt_t *tx_pkt,
FAR altmdm_spipkt_t *rx_pkt);
/****************************************************************************
* Name: altmdm_do_body_transaction
*
* Description:
* Initiates a transaction for the SPI protocol body.
*
* Input Parameters:
* spidev - An SPI instance that communicates with the ALT1250.
* lower - An instance of the lower interface.
* tx_pkt - Pointer to SPI packet structure for sending.
* rx_pkt - Pointer to SPI packet structure for reception.
*
* Returned Value:
* None
*
****************************************************************************/
void altmdm_do_body_transaction(FAR struct spi_dev_s *spidev,
FAR const struct alt1250_lower_s *lower, FAR altmdm_spipkt_t *tx_pkt,
FAR altmdm_spipkt_t *rx_pkt);
#endif /* __DRIVERS_MODEM_ALT1250_ALTMDM_SPI_H */

View file

@ -0,0 +1,153 @@
/****************************************************************************
* drivers/modem/alt1250/altmdm_timer.c
*
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/signal.h>
#include <signal.h>
#include "altmdm_timer.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define MY_TIMER_SIGNAL SIGUSR1
/****************************************************************************
* Private Functions
****************************************************************************/
static int set_signal(int signal_no, FAR _sa_sigaction_t handler)
{
int ret;
sigset_t mask;
struct sigaction sa;
sigemptyset(&mask);
nxsig_addset(&mask, signal_no);
ret = nxsig_procmask(SIG_UNBLOCK, &mask, NULL);
if (ret != OK)
{
return ERROR;
}
sa.sa_sigaction = handler;
sa.sa_flags = SA_SIGINFO;
sigfillset(&sa.sa_mask);
nxsig_delset(&sa.sa_mask, signal_no);
ret = nxsig_action(signal_no, &sa, NULL, false);
if (ret != OK)
{
return ERROR;
}
return OK;
}
/****************************************************************************
* Public Functions
****************************************************************************/
timer_t altmdm_timer_start(int first_ms, int interval_ms,
FAR _sa_sigaction_t handler, FAR void *ptr_param)
{
int ret;
struct sigevent sev;
struct itimerspec timer;
timer_t timerid;
if (set_signal(MY_TIMER_SIGNAL, handler) != OK)
{
return NULL;
}
sev.sigev_notify = SIGEV_SIGNAL;
sev.sigev_signo = MY_TIMER_SIGNAL;
sev.sigev_value.sival_int = 0;
sev.sigev_value.sival_ptr = ptr_param;
ret = timer_create(CLOCK_REALTIME, &sev, &timerid);
if (ret != OK)
{
return NULL;
}
timer.it_value.tv_sec = first_ms / 1000;
timer.it_value.tv_nsec = (first_ms % 1000) * 1000 * 1000;
timer.it_interval.tv_sec = interval_ms / 1000;
timer.it_interval.tv_nsec = (interval_ms % 1000) * 1000 * 1000;
ret = timer_settime(timerid, 0, &timer, NULL);
if (ret != OK)
{
return NULL;
}
return timerid;
}
int altmdm_timer_restart(timer_t timerid, int first_ms, int interval_ms)
{
int ret;
struct itimerspec timer;
timer.it_value.tv_sec = first_ms / 1000;
timer.it_value.tv_nsec = (first_ms % 1000) * 1000 * 1000;
timer.it_interval.tv_sec = interval_ms / 1000;
timer.it_interval.tv_nsec = (interval_ms % 1000) * 1000 * 1000;
ret = timer_settime(timerid, 0, &timer, NULL);
if (ret != OK)
{
return ret;
}
return ret;
}
int altmdm_timer_is_running(timer_t timerid)
{
struct itimerspec timer;
timer_gettime(timerid, &timer);
return (timer.it_value.tv_sec != 0 || timer.it_value.tv_nsec != 0);
}
void altmdm_timer_stop(timer_t timerid)
{
sigset_t mask;
timer_delete(timerid);
sigfillset(&mask);
nxsig_procmask(SIG_SETMASK, &mask, NULL);
}

View file

@ -0,0 +1,111 @@
/****************************************************************************
* drivers/modem/alt1250/altmdm_timer.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 __DEVICES_MODEM_ALT1250_ALTMDM_TIMER_H
#define __DEVICES_MODEM_ALT1250_ALTMDM_TIMER_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <signal.h>
#include <time.h>
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: altmdm_timer_start
*
* Description:
* Starts the timer with the specified timeout period. When the timeout
* occurs, the function specified in the handler is executed.
*
* Input Parameters:
* first_ms - The time until next expiration.
* interval_ms - The reload value of the timer.
* handler - Function pointer to be called when the timer expires.
* ptr_param - The value set in info->si_value.sival_ptr.
* info is the second argument of the handler.
*
* Returned Value:
* If the altmdm_timer_start() succeeds, timer instance will be returned.
* If an error occurs, the NULL will be returned.
*
****************************************************************************/
timer_t altmdm_timer_start(int first_ms, int interval_ms,
FAR _sa_sigaction_t handler, FAR void *ptr_param);
/****************************************************************************
* Name: altmdm_timer_restart
*
* Description:
* Restarts the timer with the specified timeout period.
*
* Input Parameters:
* timerid - timer instatce created by altmdm_timer_start().
* first_ms - The time until next expiration.
* interval_ms - The reload value of the timer.
*
* Returned Value:
* If the altmdm_timer_restart() succeeds, the value 0 (OK) will be
* returned. If an error occurs, the value -1 (ERROR) will be returned.
*
****************************************************************************/
int altmdm_timer_restart(timer_t timerid, int first_ms, int interval_ms);
/****************************************************************************
* Name: altmdm_timer_is_running
*
* Description:
* Check whether the timer is running or not.
*
* Input Parameters:
* timerid - timer instatce created by altmdm_timer_start().
*
* Returned Value:
* Return 1 if the timer is running, 0 otherwise.
*
****************************************************************************/
int altmdm_timer_is_running(timer_t timerid);
/****************************************************************************
* Name: altmdm_timer_stop
*
* Description:
* Stops the timer.
*
* Input Parameters:
* timerid - timer instatce created by altmdm_timer_start().
*
* Returned Value:
* None
*
****************************************************************************/
void altmdm_timer_stop(timer_t timerid);
#endif /* __DEVICES_MODEM_ALT1250_ALTMDM_TIMER_H */

View file

@ -1,51 +0,0 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
menuconfig MODEM_ALTMDM
bool "Altair modem support"
default n
select SPI
---help---
Enable driver for the Altair modem.
if MODEM_ALTMDM
config MODEM_ALTMDM_XFER_TASK_PRIORITY
int "transfer task priority"
default 170
range 1 255
config MODEM_ALTMDM_DEBUG
bool "Enable debug mode for Altair modem driver"
default n
depends on MODEM_ALTMDM
---help---
Allow the Altair modem driver print debug information.
config MODEM_ALTMDM_KEEP_WAKE_STATE
bool "Configuration to keep wake state of modem"
default n
depends on MODEM_ALTMDM
---help---
none
config MODEM_ALTMDM_MAX_PACKET_SIZE
int "Max size to be transfer in bytes"
default 2064
depends on MODEM_ALTMDM
---help---
none
config MODEM_ALTMDM_SLEEP_TIMER_VAL
int "Modem sleep timer"
default 20
depends on MODEM_ALTMDM
---help---
Modem sleep timer in milliseconds.
Modem may sleep if there is no data to be transferred
during specified time. Values smaller than 20 milliseconds
can not be specified.
endif

View file

@ -1,427 +0,0 @@
/****************************************************************************
* drivers/modem/altair/altmdm.c
*
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <string.h>
#include <nuttx/kmalloc.h>
#include <nuttx/fs/fs.h>
#include <nuttx/spi/spi.h>
#include <nuttx/modem/altmdm.h>
#include "altmdm_dev.h"
#include "altmdm_spi.h"
#include "altmdm_pm.h"
#include "altmdm_sys.h"
#if defined(CONFIG_MODEM_ALTMDM)
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/* Character driver methods. */
static ssize_t altmdm_read(FAR struct file *filep, FAR char *buffer,
size_t len);
static ssize_t altmdm_write(FAR struct file *filep, FAR const char *buffer,
size_t len);
static int altmdm_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
/****************************************************************************
* Private Data
****************************************************************************/
/* This the vtable that supports the character driver interface. */
static const struct file_operations g_altmdmfops =
{
NULL, /* open */
NULL, /* close */
altmdm_read, /* read */
altmdm_write, /* write */
NULL, /* seek */
altmdm_ioctl, /* ioctl */
NULL /* poll */
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
, NULL /* unlink */
#endif
};
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: is_poweron
*
* Description:
* Check ALTMDM power on.
*
****************************************************************************/
static int is_poweron(FAR struct altmdm_dev_s *priv)
{
int poweron;
altmdm_sys_lock(&priv->lock);
poweron = priv->poweron;
altmdm_sys_unlock(&priv->lock);
return poweron;
}
/****************************************************************************
* Name: altmdm_initialize
*
* Description:
* Initialize ALTMDM driver.
*
****************************************************************************/
static int altmdm_initialize(FAR struct altmdm_dev_s *priv)
{
int ret;
ret = altmdm_sys_initlock(&priv->lock);
if (ret == ERROR)
{
m_err("altmdm_sys_initlock() failed:%d\n", ret);
}
priv->poweron = 0;
/* Initialize ALTMDM SPI driver. */
ret = altmdm_spi_init(priv);
return ret;
}
/****************************************************************************
* Name: altmdm_uninitialize
*
* Description:
* Uninitialize ALTMDM driver.
*
****************************************************************************/
static int altmdm_uninitialize(FAR struct altmdm_dev_s *priv)
{
int ret;
/* Uninitialize ALTMDM SPI driver */
altmdm_spi_uninit(priv);
ret = altmdm_sys_deletelock(&priv->lock);
if (ret == ERROR)
{
m_err("altmdm_sys_deletelock() failed:%d\n", ret);
}
return ret;
}
/****************************************************************************
* Name: altmdm_read
*
* Description:
* Standard character driver read method.
*
****************************************************************************/
static ssize_t altmdm_read(FAR struct file *filep,
FAR char *buffer,
size_t len)
{
FAR struct inode *inode = filep->f_inode;
FAR struct altmdm_dev_s *priv = inode->i_private;
ssize_t rsize = -EPERM;
rsize = altmdm_spi_read(priv, buffer, len);
return rsize;
}
/****************************************************************************
* Name: altmdm_write
*
* Description:
* Standard character driver write method.
*
****************************************************************************/
static ssize_t altmdm_write(FAR struct file *filep, FAR const char *buffer,
size_t len)
{
FAR struct inode *inode = filep->f_inode;
FAR struct altmdm_dev_s *priv = inode->i_private;
ssize_t wsize = -EPERM;
if (is_poweron(priv))
{
wsize = altmdm_spi_write(priv, buffer, len);
}
return wsize;
}
/****************************************************************************
* Name: altmdm_ioctl
*
* Description:
* Standard character driver ioctl method.
*
****************************************************************************/
static int altmdm_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
{
FAR struct inode *inode = filep->f_inode;
FAR struct altmdm_dev_s *priv = inode->i_private;
int ret = -EPERM;
switch (cmd)
{
case MODEM_IOC_POWERON: /* Power on ALTMDM. */
{
altmdm_sys_lock(&priv->lock);
if (!priv->poweron)
{
altmdm_pm_poweron(priv);
priv->poweron = 1;
ret = altmdm_spi_enable(priv);
}
else
{
ret = -EBUSY;
}
altmdm_sys_unlock(&priv->lock);
}
break;
case MODEM_IOC_POWEROFF: /* Power off ALTMDM. */
{
altmdm_sys_lock(&priv->lock);
if (priv->poweron)
{
ret = altmdm_spi_disable(priv);
altmdm_pm_poweroff(priv);
priv->poweron = 0;
}
else
{
ret = -EBUSY;
}
altmdm_sys_unlock(&priv->lock);
}
break;
case MODEM_IOC_READABORT: /* Abort the read process. */
{
ret = altmdm_spi_readabort(priv);
}
break;
case MODEM_IOC_SLEEP: /* Make ALTMDM sleep. */
{
if (is_poweron(priv))
{
ret = altmdm_spi_sleepmodem(priv);
}
}
break;
case MODEM_IOC_PM_REGISTERCB: /* Register callback function. */
{
ret = altmdm_pm_registercb(MODEM_PM_CB_TYPE_NORMAL,
(altmdm_pm_cbfunc_t) arg);
}
break;
case MODEM_IOC_PM_DEREGISTERCB: /* Deregister callback function. */
{
ret = altmdm_pm_deregistercb(MODEM_PM_CB_TYPE_NORMAL);
}
break;
case MODEM_IOC_PM_ERR_REGISTERCB: /* Register error callback function. */
{
ret = altmdm_pm_registercb(MODEM_PM_CB_TYPE_ERROR,
(altmdm_pm_cbfunc_t) arg);
}
break;
case MODEM_IOC_PM_ERR_DEREGISTERCB: /* Deregister error callback
function.
*/
{
ret = altmdm_pm_deregistercb(MODEM_PM_CB_TYPE_ERROR);
}
break;
case MODEM_IOC_PM_GETSTATE: /* Get ALTMDM power management state. */
{
*(uint32_t *) arg = altmdm_pm_getstate();
ret = 0;
}
break;
case MODEM_IOC_PM_INITWAKELOCK: /* Initialize wakelock resource. */
{
ret = altmdm_pm_initwakelock((struct altmdm_pm_wakelock_s *)arg);
}
break;
case MODEM_IOC_PM_ACQUIREWAKELOCK: /* Acquire wakelock. */
{
ret = altmdm_pm_acquirewakelock((struct altmdm_pm_wakelock_s *)arg);
}
break;
case MODEM_IOC_PM_RELEASEWAKELOCK: /* Release wakelock. */
{
ret = altmdm_pm_releasewakelock((struct altmdm_pm_wakelock_s *)arg);
}
break;
case MODEM_IOC_PM_GETNUMOFWAKELOCK: /* Get number of wakelocks. */
{
ret = altmdm_pm_getnumofwakelock((struct altmdm_pm_wakelock_s *)arg);
}
break;
case MODEM_IOC_PM_GETWAKELOCKSTATE: /* Get wakelock state. */
{
ret = altmdm_pm_getwakelockstate();
}
break;
default:
m_err("Unrecognized cmd: 0x%08x\n", cmd);
ret = -ENOTTY;
break;
}
return ret;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: altmdm_register
*
* Description:
* Register the ALTMDM character device as 'devpath'.
*
* Input Parameters:
* devpath - The full path to the driver to register. E.g., "/dev/altmdm".
* dev - An instance of the SPI interface to use to communicate with
* ALTMDM.
*
* Returned Value:
* Not NULL on success; NULL on failure.
*
****************************************************************************/
FAR void *altmdm_register(FAR const char *devpath, FAR struct spi_dev_s *dev,
FAR const struct altmdm_lower_s *lower)
{
FAR struct altmdm_dev_s *priv;
int ret;
int size = sizeof(struct altmdm_dev_s);
priv = (FAR struct altmdm_dev_s *)kmm_malloc(size);
if (!priv)
{
m_err("Failed to allocate instance.\n");
return NULL;
}
priv->spi = dev;
priv->path = strdup(devpath);
priv->lower = lower;
ret = altmdm_initialize(priv);
if (ret < 0)
{
m_err("Failed to initialize ALTMDM driver.\n");
kmm_free(priv);
return NULL;
}
ret = register_driver(devpath, &g_altmdmfops, 0666, priv);
if (ret < 0)
{
m_err("Failed to register driver: %d\n", ret);
kmm_free(priv);
return NULL;
}
return (FAR void *)priv;
}
/****************************************************************************
* Name: altmdm_unregister
*
* Description:
* Unregister the ALTMDM character device.
*
* Input Parameters:
* handle - The pointer that getting from altmdm_register.
*
* Returned Value:
* None.
*
****************************************************************************/
void altmdm_unregister(FAR void *handle)
{
FAR struct altmdm_dev_s *priv;
if (handle)
{
priv = (FAR struct altmdm_dev_s *)handle;
altmdm_uninitialize(priv);
unregister_driver(priv->path);
kmm_free(priv->path);
kmm_free(priv);
}
}
#endif

View file

@ -1,176 +0,0 @@
/****************************************************************************
* drivers/modem/altair/altmdm_dev.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 __DRIVERS_MODEM_ALTAIR_ALTMDM_DEV_H
#define __DRIVERS_MODEM_ALTAIR_ALTMDM_DEV_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/modem/altmdm.h>
#include "altmdm_spi.h"
#include "altmdm_sys.h"
#if defined(CONFIG_MODEM_ALTMDM)
/****************************************************************************
* Public Types
****************************************************************************/
struct altmdm_dev_s
{
FAR char *path; /* Registration path */
FAR struct spi_dev_s *spi;
struct altmdm_spi_dev_s spidev;
struct altmdm_sys_lock_s lock;
int poweron;
FAR const struct altmdm_lower_s *lower;
};
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: altmdm_spi_init
*
* Description:
* Initialize ALTMDM driver.
*
****************************************************************************/
int altmdm_spi_init(FAR struct altmdm_dev_s *priv);
/****************************************************************************
* Name: altmdm_spi_uninit
*
* Description:
* Uninitialize ALTMDM driver.
*
****************************************************************************/
int altmdm_spi_uninit(FAR struct altmdm_dev_s *priv);
/****************************************************************************
* Name: altmdm_spi_enable
*
* Description:
* Enable ALTMDM SPI driver.
*
****************************************************************************/
int altmdm_spi_enable(FAR struct altmdm_dev_s *priv);
/****************************************************************************
* Name: altmdm_spi_disable
*
* Description:
* Disable ALTMDM SPI driver.
*
****************************************************************************/
int altmdm_spi_disable(FAR struct altmdm_dev_s *priv);
/****************************************************************************
* Name: altmdm_spi_read
*
* Description:
* ALTMDM SPI driver read method.
*
****************************************************************************/
ssize_t altmdm_spi_read(FAR struct altmdm_dev_s *priv,
FAR const char *buffer, size_t readlen);
/****************************************************************************
* Name: altmdm_spi_write
*
* Description:
* ALTMDM SPI driver write method.
*
****************************************************************************/
ssize_t altmdm_spi_write(FAR struct altmdm_dev_s *priv,
FAR const char *buffer, size_t witelen);
/****************************************************************************
* Name: altmdm_spi_readabort
*
* Description:
* Abort the read process.
*
****************************************************************************/
int altmdm_spi_readabort(FAR struct altmdm_dev_s *priv);
/****************************************************************************
* Name: altmdm_spi_sleepmodem
*
* Description:
* Make ALTMDM sleep.
*
****************************************************************************/
int altmdm_spi_sleepmodem(FAR struct altmdm_dev_s *priv);
/****************************************************************************
* Name: altmdm_spi_setreceiverready
*
* Description:
* Set receiver ready notification.
*
****************************************************************************/
int altmdm_spi_setreceiverready(FAR struct altmdm_dev_s *priv);
/****************************************************************************
* Name: altmdm_spi_isreceiverready
*
* Description:
* Check already notified or not by altmdm_spi_setreceiverready.
*
****************************************************************************/
int altmdm_spi_isreceiverready(FAR struct altmdm_dev_s *priv);
/****************************************************************************
* Name: altmdm_spi_clearreceiverready
*
* Description:
* Clear receiver ready notification.
*
****************************************************************************/
int altmdm_spi_clearreceiverready(FAR struct altmdm_dev_s *priv);
/****************************************************************************
* Name: altmdm_spi_gpioreadyisr
*
* Description:
* Interrupt handler for SLAVE_REQUEST GPIO line.
*
****************************************************************************/
int altmdm_spi_gpioreadyisr(int irq, FAR void *context, FAR void *arg);
#endif
#endif /* __DRIVERS_MODEM_ALTAIR_ALTMDM_DEV_H */

View file

@ -1,775 +0,0 @@
/****************************************************************************
* drivers/modem/altair/altmdm_pm.c
*
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <nuttx/kmalloc.h>
#include <nuttx/signal.h>
#include <nuttx/modem/altmdm.h>
#include "altmdm_sys.h"
#include "altmdm_pm.h"
#include "altmdm_pm_state.h"
#if defined(CONFIG_MODEM_ALTMDM)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Timeout is counted in units of millisecond. */
# define D2H_UP_EVENT_TIMEOUT (5*1000)
# define GPIO_LOW (false)
# define GPIO_HIGH (true)
/****************************************************************************
* Private Data
****************************************************************************/
static struct altmdm_dev_s *g_privdata = NULL;
static bool g_is_initdone = false;
static altmdm_pm_cbfunc_t g_pm_callback = NULL;
static altmdm_pm_cbfunc_t g_pm_errcallback = NULL;
static sq_queue_t g_wakelock;
static uint32_t g_boot_stat = MODEM_PM_ERR_RESET_BOOTSTAT_NONE;
/****************************************************************************
* Name: set_mreq_gpio
*
* Description:
* Control Master-request GPIO line.
*
****************************************************************************/
static int set_mreq_gpio(FAR struct altmdm_dev_s *priv, bool value)
{
DEBUGASSERT(priv && priv->lower);
priv->lower->master_request(value);
return 0;
}
/****************************************************************************
* Name: set_h2d_gpio
*
* Description:
* Control Host to Device GPIO line.
*
****************************************************************************/
static int set_h2d_gpio(FAR struct altmdm_dev_s *priv, bool value)
{
DEBUGASSERT(priv && priv->lower);
priv->lower->wakeup(value);
return 0;
}
/****************************************************************************
* Name: set_mreq_down
*
* Description:
* Deassert Master-request GPIO line.
*
****************************************************************************/
static int set_mreq_down(FAR struct altmdm_dev_s *priv)
{
return set_mreq_gpio(priv, GPIO_LOW);
}
/****************************************************************************
* Name: set_mreq_up
*
* Description:
* Assert Master-request GPIO line.
*
****************************************************************************/
static int set_mreq_up(FAR struct altmdm_dev_s *priv)
{
return set_mreq_gpio(priv, GPIO_HIGH);
}
/****************************************************************************
* Name: set_h2d_down
*
* Description:
* Deassert Host to Device GPIO line.
*
****************************************************************************/
static int set_h2d_down(FAR struct altmdm_dev_s *priv)
{
return set_h2d_gpio(priv, GPIO_LOW);
}
/****************************************************************************
* Name: set_h2d_up
*
* Description:
* Assert Host to Device GPIO line.
*
****************************************************************************/
static int set_h2d_up(FAR struct altmdm_dev_s *priv)
{
return set_h2d_gpio(priv, GPIO_HIGH);
}
/****************************************************************************
* Name: exe_callback
*
* Description:
* Execute callback of modem power manager.
*
****************************************************************************/
static int exe_callback(uint32_t type, uint32_t cb_event)
{
altmdm_pm_cbfunc_t lcallback = NULL;
if (type == MODEM_PM_CB_TYPE_ERROR)
{
lcallback = g_pm_errcallback;
}
else
{
lcallback = g_pm_callback;
}
if (lcallback == NULL)
{
return -EPERM;
}
lcallback(cb_event);
return 0;
}
/****************************************************************************
* Name: sleep_modem_itself
*
* Description:
* The modem slept on itself, it transitions to the sleep state.
*
****************************************************************************/
static int sleep_modem_itself(FAR struct altmdm_dev_s *priv)
{
set_h2d_down(priv);
/* Transitions to the sleep state. */
altmdm_pm_setinternalstate(MODEM_PM_INTERNAL_STATE_SLEEP);
/* Perform processing at the time of state transition. */
exe_callback(MODEM_PM_CB_TYPE_NORMAL, MODEM_PM_CB_SLEEP);
return 0;
}
/****************************************************************************
* Name: modem_sleep_procedure
*
* Description:
* Make the modem transition to sleep.
*
****************************************************************************/
static int modem_sleep_procedure(FAR struct altmdm_dev_s *priv)
{
int ret;
ret = set_h2d_down(priv);
if (ret == 0)
{
/* Transitions to the sleep state. */
altmdm_pm_setinternalstate(MODEM_PM_INTERNAL_STATE_SLEEP);
/* Perform processing at the time of state transition. */
exe_callback(MODEM_PM_CB_TYPE_NORMAL, MODEM_PM_CB_SLEEP);
}
return ret;
}
/****************************************************************************
* Name: modem_wakeup_procedure
*
* Description:
* Make the modem transition to wakeup.
*
****************************************************************************/
static int modem_wakeup_procedure(FAR struct altmdm_dev_s *priv,
CODE int (*wait_fn)(FAR struct altmdm_dev_s *priv, uint32_t timeout_ms))
{
int ret = 0;
if (MODEM_PM_INTERNAL_STATE_WAKE == altmdm_pm_getinternalstate())
{
return MODEM_PM_WAKEUP_ALREADY;
}
altmdm_pm_setinternalstate(MODEM_PM_INTERNAL_STATE_GOING_TO_WAKE);
ret = set_h2d_up(priv);
if (ret == 0)
{
if (wait_fn)
{
set_mreq_up(priv);
ret = wait_fn(priv, D2H_UP_EVENT_TIMEOUT);
if (ret != 0)
{
m_err("ERR:%04d device is not up.\n", __LINE__);
/* Do rollback. */
set_mreq_down(priv);
set_h2d_down(priv);
altmdm_pm_setinternalstate(MODEM_PM_INTERNAL_STATE_SLEEP);
ret = MODEM_PM_WAKEUP_FAIL;
}
else
{
/* Transitions to the wake state. */
altmdm_pm_setinternalstate(MODEM_PM_INTERNAL_STATE_WAKE);
/* Perform processing at the time of state transition. */
exe_callback(MODEM_PM_CB_TYPE_NORMAL, MODEM_PM_CB_WAKE);
ret = MODEM_PM_WAKEUP_DONE;
}
}
else
{
/* Transitions to the wake state. */
altmdm_pm_setinternalstate(MODEM_PM_INTERNAL_STATE_WAKE);
/* Perform processing at the time of state transition. */
exe_callback(MODEM_PM_CB_TYPE_NORMAL, MODEM_PM_CB_WAKE);
ret = MODEM_PM_WAKEUP_DONE;
}
}
return ret;
}
/****************************************************************************
* Name: sleep_is_possible
*
* Description:
* Check if the modem can sleep.
*
****************************************************************************/
static int sleep_is_possible(FAR struct altmdm_dev_s *priv)
{
# ifdef CONFIG_MODEM_ALTMDM_KEEP_WAKE_STATE
return -EPERM;
# else
int num_of_lock;
uint32_t pm_state;
pm_state = altmdm_pm_getinternalstate();
if (pm_state != MODEM_PM_INTERNAL_STATE_WAKE)
{
return -EBUSY;
}
num_of_lock = altmdm_pm_getwakelockstate();
if (num_of_lock)
{
return -EBUSY;
}
if (g_boot_stat != MODEM_PM_ERR_RESET_BOOTSTAT_DONE)
{
return -EBUSY;
}
return 0;
# endif
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: altmdm_pm_init
*
* Description:
* Initialize the ALTMDM power manager driver.
*
****************************************************************************/
int altmdm_pm_init(FAR struct altmdm_dev_s *priv)
{
if (g_is_initdone)
{
return -EPERM;
}
g_is_initdone = true;
g_privdata = priv;
altmdm_pm_setinternalstate(MODEM_PM_INTERNAL_STATE_SLEEP);
sq_init(&g_wakelock);
return 0;
}
/****************************************************************************
* Name: altmdm_pm_uninit
*
* Description:
* Uninitialize the ALTMDM power manager driver.
*
****************************************************************************/
int altmdm_pm_uninit(FAR struct altmdm_dev_s *priv)
{
if (!g_is_initdone)
{
return -EPERM;
}
g_is_initdone = false;
altmdm_pm_setinternalstate(MODEM_PM_INTERNAL_STATE_SLEEP);
sq_init(&g_wakelock);
return 0;
}
/****************************************************************************
* Name: altmdm_pm_wakeup
*
* Description:
* Make modem wake up.
*
****************************************************************************/
int altmdm_pm_wakeup(FAR struct altmdm_dev_s *priv,
CODE int (*wait_fn)(FAR struct altmdm_dev_s *priv, uint32_t timeout_ms))
{
int ret = MODEM_PM_WAKEUP_FAIL;
if (!g_is_initdone)
{
return -EPERM;
}
ret = modem_wakeup_procedure(priv, wait_fn);
return ret;
}
/****************************************************************************
* Name: altmdm_pm_notify_reset
*
* Description:
* Notify reset has done.
*
****************************************************************************/
int altmdm_pm_notify_reset(FAR struct altmdm_dev_s *priv)
{
if (!g_is_initdone)
{
return -EPERM;
}
if (MODEM_PM_ERR_RESET_BOOTSTAT_NONE != g_boot_stat)
{
exe_callback(MODEM_PM_CB_TYPE_ERROR, g_boot_stat);
}
else
{
m_err("ERR:%04d Unexpected boot stat:%d.\n",
__LINE__, g_boot_stat);
}
return 0;
}
/****************************************************************************
* Name: altmdm_pm_registercb
*
* Description:
* Register callback for ALTMDM power manager driver.
*
****************************************************************************/
int altmdm_pm_registercb(uint32_t type, altmdm_pm_cbfunc_t cb)
{
if (!g_is_initdone)
{
return -EPERM;
}
if (type == MODEM_PM_CB_TYPE_ERROR)
{
if (g_pm_errcallback == NULL)
{
g_pm_errcallback = cb;
}
}
else
{
if (g_pm_callback == NULL)
{
g_pm_callback = cb;
}
}
return 0;
}
/****************************************************************************
* Name: altmdm_pm_deregistercb
*
* Description:
* Deregister callback for ALTMDM power manager driver.
*
****************************************************************************/
int altmdm_pm_deregistercb(uint32_t type)
{
altmdm_pm_cbfunc_t *lcallback = NULL;
if (!g_is_initdone)
{
return -EPERM;
}
if (type == MODEM_PM_CB_TYPE_ERROR)
{
lcallback = &g_pm_errcallback;
}
else
{
lcallback = &g_pm_callback;
}
if (*lcallback == NULL)
{
return -EPERM;
}
*lcallback = NULL;
return 0;
}
/****************************************************************************
* Name: altmdm_pm_sleepmodem
*
* Description:
* Make modem sleep.
*
****************************************************************************/
int altmdm_pm_sleepmodem(FAR struct altmdm_dev_s *priv)
{
int ret;
if (!g_is_initdone)
{
return -EPERM;
}
altmdm_pm_setinternalstate(MODEM_PM_INTERNAL_STATE_GOING_TO_SLEEP);
ret = modem_sleep_procedure(priv);
return ret;
}
/****************************************************************************
* Name: altmdm_pm_cansleep
*
* Description:
* Check if modem can sleep.
*
****************************************************************************/
int altmdm_pm_cansleep(FAR struct altmdm_dev_s *priv)
{
int ret;
if (!g_is_initdone)
{
return -EPERM;
}
ret = sleep_is_possible(priv);
if (ret == 0)
{
m_info("possible to sleep.\n");
ret = 1;
}
else
{
m_info("impossible to sleep.\n");
ret = 0;
}
return ret;
}
/****************************************************************************
* Name: altmdm_pm_initwakelock
*
* Description:
* Initialize the modem wakelock resource.
*
****************************************************************************/
int altmdm_pm_initwakelock(FAR struct altmdm_pm_wakelock_s *lock)
{
if (!g_is_initdone)
{
return -EPERM;
}
if (!lock)
{
return -EINVAL;
}
memset(lock, 0, sizeof(struct altmdm_pm_wakelock_s));
return 0;
}
/****************************************************************************
* Name: altmdm_pm_acquirewakelock
*
* Description:
* Acquire the modem wakelock.
*
****************************************************************************/
int altmdm_pm_acquirewakelock(FAR struct altmdm_pm_wakelock_s *lock)
{
irqstate_t flags;
if (!g_is_initdone)
{
return -EPERM;
}
if (!lock)
{
return -EINVAL;
}
flags = enter_critical_section();
if (lock->count == 0)
{
sq_addlast((FAR sq_entry_t *) & lock->queue, &g_wakelock);
}
lock->count++;
leave_critical_section(flags);
return 0;
}
/****************************************************************************
* Name: altmdm_pm_releasewakelock
*
* Description:
* Release the modem wakelock.
*
****************************************************************************/
int altmdm_pm_releasewakelock(FAR struct altmdm_pm_wakelock_s *lock)
{
irqstate_t flags;
if (!g_is_initdone)
{
return -EPERM;
}
if (!lock && (lock->count < 1))
{
return -EINVAL;
}
flags = enter_critical_section();
lock->count--;
if (lock->count == 0)
{
sq_rem((FAR sq_entry_t *) & lock->queue, &g_wakelock);
}
leave_critical_section(flags);
return 0;
}
/****************************************************************************
* Name: altmdm_pm_getnumofwakelock
*
* Description:
* Get the lock count of the specified wakelock.
*
****************************************************************************/
int altmdm_pm_getnumofwakelock(FAR struct altmdm_pm_wakelock_s *lock)
{
if (!g_is_initdone)
{
return -EPERM;
}
if (!lock)
{
return -EINVAL;
}
return lock->count;
}
/****************************************************************************
* Name: altmdm_pm_getwakelockstate
*
* Description:
* Get the wakelock status. If the return value is 0, it means that it is
* not locked. Otherwise it means that someone is locking.
*
****************************************************************************/
int altmdm_pm_getwakelockstate(void)
{
int num;
irqstate_t flags;
if (!g_is_initdone)
{
return -EPERM;
}
flags = enter_critical_section();
num = sq_count(&g_wakelock);
leave_critical_section(flags);
return num;
}
/****************************************************************************
* Name: altmdm_pm_poweron
*
* Description:
* Modem power on.
*
****************************************************************************/
int altmdm_pm_poweron(FAR struct altmdm_dev_s *priv)
{
if (!g_is_initdone)
{
return -EPERM;
}
priv->lower->poweron();
return 0;
}
/****************************************************************************
* Name: altmdm_pm_poweroff
*
* Description:
* Modem power off.
*
****************************************************************************/
int altmdm_pm_poweroff(FAR struct altmdm_dev_s *priv)
{
if (!g_is_initdone)
{
return -EPERM;
}
priv->lower->poweroff();
sleep_modem_itself(priv);
return 0;
}
/****************************************************************************
* Name: altmdm_pm_set_bootstatus
*
* Description:
* Set boot status.
*
****************************************************************************/
int altmdm_pm_set_bootstatus(FAR struct altmdm_dev_s *priv, uint32_t status)
{
if (!g_is_initdone)
{
return -EPERM;
}
g_boot_stat = status;
return 0;
}
#endif

View file

@ -1,212 +0,0 @@
/****************************************************************************
* drivers/modem/altair/altmdm_pm.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 __DRIVERS_MODEM_ALTAIR_ALTMDM_PM_H
#define __DRIVERS_MODEM_ALTAIR_ALTMDM_PM_H
/****************************************************************************
* Included Files
****************************************************************************/
#include "altmdm_dev.h"
#include "altmdm_sys.h"
#include "altmdm_pm_state.h"
#if defined(CONFIG_MODEM_ALTMDM)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define MODEM_PM_WAKEUP_DONE (0)
#define MODEM_PM_WAKEUP_ALREADY (1)
#define MODEM_PM_WAKEUP_FAIL (2)
#define MODEM_PM_CB_SLEEP (0)
#define MODEM_PM_CB_WAKE (1)
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: altmdm_pm_init
*
* Description:
* Initialize the ALTMDM power manager driver.
*
****************************************************************************/
int altmdm_pm_init(FAR struct altmdm_dev_s *priv);
/****************************************************************************
* Name: altmdm_pm_uninit
*
* Description:
* Uninitialize the ALTMDM power manager driver.
*
****************************************************************************/
int altmdm_pm_uninit(FAR struct altmdm_dev_s *priv);
/****************************************************************************
* Name: altmdm_pm_wakeup
*
* Description:
* Make modem wake up.
*
****************************************************************************/
int altmdm_pm_wakeup(FAR struct altmdm_dev_s *priv,
CODE int (*wait_fn)(FAR struct altmdm_dev_s *priv, uint32_t timeout_ms));
/****************************************************************************
* Name: altmdm_pm_notify_reset
*
* Description:
* Notify reset has done.
*
****************************************************************************/
int altmdm_pm_notify_reset(FAR struct altmdm_dev_s *priv);
/****************************************************************************
* Name: altmdm_pm_registercb
*
* Description:
* Register callback for ALTMDM power manager driver.
*
****************************************************************************/
int altmdm_pm_registercb(uint32_t type, altmdm_pm_cbfunc_t cb);
/****************************************************************************
* Name: altmdm_pm_deregistercb
*
* Description:
* Deregister callback for ALTMDM power manager driver.
*
****************************************************************************/
int altmdm_pm_deregistercb(uint32_t type);
/****************************************************************************
* Name: altmdm_pm_sleepmodem
*
* Description:
* Make modem sleep.
*
****************************************************************************/
int altmdm_pm_sleepmodem(FAR struct altmdm_dev_s *priv);
/****************************************************************************
* Name: altmdm_pm_cansleep
*
* Description:
* Check if modem can sleep.
*
****************************************************************************/
int altmdm_pm_cansleep(FAR struct altmdm_dev_s *priv);
/****************************************************************************
* Name: altmdm_pm_initwakelock
*
* Description:
* Initialize the modem wakelock resource.
*
****************************************************************************/
int altmdm_pm_initwakelock(FAR struct altmdm_pm_wakelock_s *lock);
/****************************************************************************
* Name: altmdm_pm_acquirewakelock
*
* Description:
* Acquire the modem wakelock.
*
****************************************************************************/
int altmdm_pm_acquirewakelock(FAR struct altmdm_pm_wakelock_s *lock);
/****************************************************************************
* Name: altmdm_pm_releasewakelock
*
* Description:
* Release the modem wakelock.
*
****************************************************************************/
int altmdm_pm_releasewakelock(FAR struct altmdm_pm_wakelock_s *lock);
/****************************************************************************
* Name: altmdm_pm_getnumofwakelock
*
* Description:
* Get the lock count of the specified wakelock.
*
****************************************************************************/
int altmdm_pm_getnumofwakelock(FAR struct altmdm_pm_wakelock_s *lock);
/****************************************************************************
* Name: altmdm_pm_getwakelockstate
*
* Description:
* Get the wakelock status. If the return value is 0, it means that it is
* not locked. Otherwise it means that someone is locking.
*
****************************************************************************/
int altmdm_pm_getwakelockstate(void);
/****************************************************************************
* Name: altmdm_pm_poweron
*
* Description:
* Modem power on.
*
****************************************************************************/
int altmdm_pm_poweron(FAR struct altmdm_dev_s *priv);
/****************************************************************************
* Name: altmdm_pm_poweroff
*
* Description:
* Modem power off.
*
****************************************************************************/
int altmdm_pm_poweroff(FAR struct altmdm_dev_s *priv);
/****************************************************************************
* Name: altmdm_pm_set_bootstatus
*
* Description:
* Set boot status.
*
****************************************************************************/
int altmdm_pm_set_bootstatus(FAR struct altmdm_dev_s *priv, uint32_t status);
#endif
#endif /* __DRIVERS_MODEM_ALTAIR_ALTMDM_PM_H */

View file

@ -1,139 +0,0 @@
/****************************************************************************
* drivers/modem/altair/altmdm_pm_state.c
*
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/irq.h>
#include <nuttx/modem/altmdm.h>
#include "altmdm_pm_state.h"
#if defined(CONFIG_MODEM_ALTMDM)
/****************************************************************************
* Private Data
****************************************************************************/
static uint32_t g_stateofmodem;
#ifdef CONFIG_MODEM_PM_PUTSTATE
static char *g_putstring[MODEM_PM_INTERNAL_STATE_MAX] =
{
"SLEEP",
"GOING_TO_WAKE",
"WAKE",
"GOING_TO_SLEEP"
};
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: altmdm_pm_getstate
*
* Description:
* Get current modem state.
*
****************************************************************************/
uint32_t altmdm_pm_getstate(void)
{
uint32_t get_state;
uint32_t internal_state;
internal_state = altmdm_pm_getinternalstate();
switch (internal_state)
{
case MODEM_PM_INTERNAL_STATE_SLEEP:
case MODEM_PM_INTERNAL_STATE_GOING_TO_WAKE:
get_state = MODEM_PM_STATE_SLEEP;
break;
case MODEM_PM_INTERNAL_STATE_WAKE:
case MODEM_PM_INTERNAL_STATE_GOING_TO_SLEEP:
get_state = MODEM_PM_STATE_WAKE;
break;
default:
get_state = MODEM_PM_STATE_WAKE;
break;
}
return get_state;
}
/****************************************************************************
* Name: altmdm_pm_getinternalstate
*
* Description:
* Get internal modem state.
*
****************************************************************************/
uint32_t altmdm_pm_getinternalstate(void)
{
uint32_t get_state;
irqstate_t flags;
flags = enter_critical_section();
get_state = g_stateofmodem;
leave_critical_section(flags);
return get_state;
}
/****************************************************************************
* Name: altmdm_pm_setinternalstate
*
* Description:
* Set internal modem state.
*
****************************************************************************/
void altmdm_pm_setinternalstate(uint32_t state)
{
irqstate_t flags;
#ifdef CONFIG_MODEM_PM_PUTSTATE
uint32_t prev_state;
#endif
if (state < MODEM_PM_INTERNAL_STATE_MAX)
{
flags = enter_critical_section();
#ifdef CONFIG_MODEM_PM_PUTSTATE
prev_state = g_stateofmodem;
#endif
g_stateofmodem = state;
leave_critical_section(flags);
#ifdef CONFIG_MODEM_PM_PUTSTATE
m_err("MODEM State [%d:%s]-->[%d:%s]\n",
prev_state, g_putstring[prev_state], state, g_putstring[state]);
#endif
}
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,172 +0,0 @@
/****************************************************************************
* drivers/modem/altair/altmdm_spi.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 __DRIVERS_MODEM_ALTAIR_ALTMDM_SPI_H
#define __DRIVERS_MODEM_ALTAIR_ALTMDM_SPI_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "altmdm_dev.h"
#include "altmdm_sys.h"
#if defined(CONFIG_MODEM_ALTMDM)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
/* This structure describes the transfer header. */
struct altmdm_spi_xferhdr_s
{
uint8_t header[4]; /* Transfer header. */
};
/* This structure describes the buffer for data receive. */
struct altmdm_spi_rxbuff_s
{
FAR char *buff_addr; /* Receive buffer address. */
uint32_t buff_size; /* Size of this buffer. */
uint32_t rx_size; /* Received data size. */
FAR struct altmdm_spi_rxbuff_s *next; /* Link for next buffer. */
};
/* This structure describes the fifo for received buffer. */
struct altmdm_spi_rxbufffifo_s
{
FAR struct altmdm_spi_rxbuff_s *head; /* Point to the head of fifo */
FAR struct altmdm_spi_rxbuff_s *tail; /* Point to the tail of fifo */
struct altmdm_sys_csem_s csem; /* It is used for notification when
* data is put in fifo.
*/
};
/* This structure describes the parameters for receive buffer information. */
struct altmdm_spi_rxbuffinfo_s
{
FAR struct altmdm_spi_rxbuff_s *free_buff; /* Free receive buffer address. */
struct altmdm_spi_rxbufffifo_s fifo; /* Receive buffer fifo. */
};
/* This structure describes the parameters for send data. */
struct altmdm_spi_tx_s
{
struct altmdm_sys_lock_s lock; /* Lock on accessing the following
* parameters.
*/
struct altmdm_sys_flag_s done_flag; /* Notify that tx request has been
* completed.
*/
struct altmdm_spi_xferhdr_s header; /* Tx header. */
FAR char *buff_addr; /* Buffer address for data transmission
* specified by the user.
*/
int32_t actual_size; /* Actual data size. */
int32_t total_size; /* Data size of 4byte alignment. */
int32_t result; /* Result of transfer. */
int32_t is_bufful; /* Indicates the slave is buffer full status. */
};
/* This structure describes the parameters for receive data. */
struct altmdm_spi_rx_s
{
struct altmdm_sys_lock_s lock; /* Lock on accessing the following
* parameters.
*/
struct altmdm_spi_xferhdr_s header; /* Rx header. */
int8_t status_info; /* Header status information */
int32_t actual_size; /* Actual data size */
int32_t total_size; /* Data size of 4byte alignment. */
FAR struct altmdm_spi_rxbuff_s *rxbuff; /* Current receive buffer. */
bool rxabort; /* Indicates whether the rx process
* is aborted.
*/
};
/* This structure describes the parameters for sleep modem. */
struct altmdm_spi_sleepmodem_s
{
struct altmdm_sys_lock_s lock; /* Lock on accessing the following
* parameters.
*/
struct altmdm_sys_flag_s done_flag; /* Notify that sleep request has been
* completed.
*/
int32_t result; /* Result of sleep request. */
bool requested; /* Indicates that sleep request has been requested. */
timer_t sv_timerid; /* Supervisor timer. */
};
/* This structure describes the resource of the ALTMDM spi driver */
struct altmdm_spi_dev_s
{
/* Common fields */
bool is_not_run; /* Indicates xfer task is not run. */
int32_t task_id; /* xfer task ID. */
bool is_xferready; /* Indicates whether the modem is ready to xfer. */
struct altmdm_sys_flag_s xferready_flag; /* Used for waiting ready to
* xfer.
*/
struct altmdm_sys_flag_s xfer_flag; /* Used for event handling of xfer
* task.
*/
struct altmdm_sys_flag_s dma_done_flag; /* Notify that DMA transfer has
* been completed.
*/
/* Parameter for receive buffer */
struct altmdm_spi_rxbuffinfo_s rxbuffinfo;
/* Parameter for send data */
struct altmdm_spi_tx_s tx_param;
/* Parameter for receive data */
struct altmdm_spi_rx_s rx_param;
/* Parameters for sleep modem */
struct altmdm_spi_sleepmodem_s sleep_param;
};
#endif
#endif /* __DRIVERS_MODEM_ALTAIR_ALTMDM_SPI_H */

View file

@ -1,724 +0,0 @@
/****************************************************************************
* drivers/modem/altair/altmdm_sys.c
*
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <errno.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <signal.h>
#include <nuttx/signal.h>
#include "altmdm_dev.h"
#include "altmdm_sys.h"
#if defined(CONFIG_MODEM_ALTMDM)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define MY_TIMER_SIGNAL SIGUSR1
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: altmdm_sys_initlock
*
* Description:
* Initialize lock resource.
*
****************************************************************************/
int altmdm_sys_initlock(FAR struct altmdm_sys_lock_s *handle)
{
int ret;
/* Check argument. */
if (handle == NULL)
{
return ERROR;
}
ret = nxmutex_init(&handle->lock);
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
if (ret < 0)
{
m_err("nxsem_init() failed:%d\n", ret);
}
#endif
return ret;
}
/****************************************************************************
* Name: altmdm_sys_deletelock
*
* Description:
* Delete lock resource
*
****************************************************************************/
int altmdm_sys_deletelock(FAR struct altmdm_sys_lock_s *handle)
{
int ret;
/* Check argument. */
if (handle == NULL)
{
return ERROR;
}
ret = nxmutex_destroy(&handle->lock);
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
if (ret < 0)
{
m_err("nxsem_destroy() failed:%d\n", ret);
}
#endif
return ret;
}
/****************************************************************************
* Name: altmdm_sys_lock
*
* Description:
* Acquire lock.
*
****************************************************************************/
int altmdm_sys_lock(FAR struct altmdm_sys_lock_s *handle)
{
int ret;
/* Check argument. */
if (handle == NULL)
{
return ERROR;
}
ret = nxmutex_lock(&handle->lock);
if (ret < 0)
{
m_err("nxsem_wait_uninterruptible() failed:%d\n", ret);
}
return ret;
}
/****************************************************************************
* Name: altmdm_sys_unlock
*
* Description:
* Release lock.
*
****************************************************************************/
int altmdm_sys_unlock(FAR struct altmdm_sys_lock_s *handle)
{
int ret;
/* Check argument. */
if (handle == NULL)
{
return ERROR;
}
ret = nxmutex_unlock(&handle->lock);
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
if (ret < 0)
{
m_err("nxsem_post() failed:%d\n", ret);
}
#endif
return ret;
}
/****************************************************************************
* Name: altmdm_sys_initcsem
*
* Description:
* Initialize counting semaphore.
*
****************************************************************************/
int altmdm_sys_initcsem(FAR struct altmdm_sys_csem_s *handle)
{
int ret;
/* Check argument. */
if (handle == NULL)
{
return ERROR;
}
ret = nxsem_init(&handle->sem, 0, 0);
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
if (ret < 0)
{
m_err("nxsem_init() failed:%d\n", ret);
}
#endif
return ret;
}
/****************************************************************************
* Name: altmdm_sys_deletecsem
*
* Description:
* Delete counting semaphore.
*
****************************************************************************/
int altmdm_sys_deletecsem(FAR struct altmdm_sys_csem_s *handle)
{
int ret;
/* Check argument. */
if (handle == NULL)
{
return ERROR;
}
ret = nxsem_destroy(&handle->sem);
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
if (ret < 0)
{
m_err("nxsem_destroy() failed:%d\n", ret);
}
#endif
return ret;
}
/****************************************************************************
* Name: altmdm_sys_waitcsem
*
* Description:
* Wait counting semaphore.
*
****************************************************************************/
int altmdm_sys_waitcsem(FAR struct altmdm_sys_csem_s *handle)
{
int ret;
/* Check argument. */
if (handle == NULL)
{
return ERROR;
}
ret = nxsem_wait_uninterruptible(&handle->sem);
if (ret < 0)
{
m_err("nxsem_wait_uninterruptible() failed:%d\n", ret);
}
return ret;
}
/****************************************************************************
* Name: altmdm_sys_postcsem
*
* Description:
* Post counting semaphore.
*
****************************************************************************/
int altmdm_sys_postcsem(FAR struct altmdm_sys_csem_s *handle)
{
int ret;
/* Check argument. */
if (handle == NULL)
{
return ERROR;
}
ret = nxsem_post(&handle->sem);
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
if (ret < 0)
{
m_err("nxsem_post() failed:%d\n", ret);
}
#endif
return ret;
}
/****************************************************************************
* Name: altmdm_sys_getcsemvalue
*
* Description:
* Get value of counting semaphore.
*
****************************************************************************/
int altmdm_sys_getcsemvalue(FAR struct altmdm_sys_csem_s *handle,
FAR int *value)
{
int ret;
/* Check argument. */
if ((handle == NULL) || (value == NULL))
{
return ERROR;
}
ret = nxsem_get_value(&handle->sem, value);
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
if (ret < 0)
{
m_err("nxsem_get_value() failed:%d\n", ret);
}
#endif
return ret;
}
/****************************************************************************
* Name: altmdm_sys_initflag
*
* Description:
* Initialize event flag resource.
*
****************************************************************************/
int altmdm_sys_initflag(FAR struct altmdm_sys_flag_s *handle)
{
int ret;
/* Check argument. */
if (handle == NULL)
{
return ERROR;
}
handle->flag = 0;
ret = nxsem_init(&handle->sem, 0, 0);
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
if (ret < 0)
{
m_err("nxsem_init() failed:%d\n", ret);
}
#endif
return ret;
}
/****************************************************************************
* Name: altmdm_sys_deleteflag
*
* Description:
* Delete event flag resource.
*
****************************************************************************/
int altmdm_sys_deleteflag(FAR struct altmdm_sys_flag_s *handle)
{
int ret;
/* Check argument. */
if (handle == NULL)
{
return ERROR;
}
ret = nxsem_destroy(&handle->sem);
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
if (ret < 0)
{
m_err("nxsem_destroy() failed:%d\n", ret);
}
#endif
return ret;
}
/****************************************************************************
* Name: altmdm_sys_waitflag
*
* Description:
* Wait event flag.
*
****************************************************************************/
int altmdm_sys_waitflag(FAR struct altmdm_sys_flag_s *handle,
uint32_t wait_pattern, uint32_t wait_mode,
FAR uint32_t * pattern, uint32_t timeout_ms)
{
int ret = OK;
irqstate_t flags;
uint32_t ptn;
/* Check argument. */
if ((handle == NULL) || (pattern == NULL))
{
m_err("invalid parameter\n");
return ERROR;
}
switch (wait_mode)
{
case ALTMDM_SYS_FLAG_WMODEOR:
case ALTMDM_SYS_FLAG_WMODEAND:
break;
default:
m_err("invalid wait mode:%d\n", wait_mode);
return ERROR;
}
*pattern = 0;
while (1)
{
if (wait_mode == ALTMDM_SYS_FLAG_WMODEOR)
{
flags = enter_critical_section();
ptn = (handle->flag & wait_pattern);
if (ptn != 0)
{
/* Wait pattern matched. */
*pattern = ptn;
handle->flag = (handle->flag & ~ptn);
/* Clear the semaphore posted by altmdm_sys_setflag. */
while (1)
{
if (nxsem_trywait(&handle->sem) < 0)
{
break;
}
}
leave_critical_section(flags);
ret = OK;
break;
}
leave_critical_section(flags);
}
else
{
flags = enter_critical_section();
ptn = (handle->flag & wait_pattern);
if (ptn == wait_pattern)
{
/* Wait pattern matched. */
*pattern = ptn;
handle->flag = (handle->flag & ~ptn);
/* Clear the semaphore posted by altmdm_sys_setflag. */
while (1)
{
if (nxsem_trywait(&handle->sem) < 0)
{
break;
}
}
leave_critical_section(flags);
ret = OK;
break;
}
leave_critical_section(flags);
}
if (timeout_ms != ALTMDM_SYS_FLAG_TMOFEVR)
{
/* Wait for the semaphore to be posted until timeout occurs. */
ret = nxsem_tickwait_uninterruptible(&handle->sem,
MSEC2TICK(timeout_ms));
if (ret < 0)
{
m_err("nxsem_tickwait_uninterruptible() failed:%d\n", ret);
break;
}
}
else
{
/* Wait for the semaphore to be posted forever. */
ret = nxsem_wait_uninterruptible(&handle->sem);
if (ret < 0)
{
m_err("nxsem_wait_uninterruptible() failed:%d\n", ret);
break;
}
}
}
return ret;
}
/****************************************************************************
* Name: altmdm_sys_setflag
*
* Description:
* Set event flag.
*
****************************************************************************/
int altmdm_sys_setflag(FAR struct altmdm_sys_flag_s *handle,
uint32_t pattern)
{
int ret;
irqstate_t flags;
/* Check argument. */
if (handle == NULL)
{
return ERROR;
}
flags = enter_critical_section();
handle->flag = (handle->flag | pattern);
leave_critical_section(flags);
ret = nxsem_post(&handle->sem);
return ret;
}
/****************************************************************************
* Name: altmdm_sys_clearflag
*
* Description:
* Clear event flag.
*
****************************************************************************/
int altmdm_sys_clearflag(FAR struct altmdm_sys_flag_s *handle,
uint32_t pattern)
{
irqstate_t flags;
/* Check argument. */
if (handle == NULL)
{
return ERROR;
}
flags = enter_critical_section();
handle->flag = (handle->flag & ~pattern);
leave_critical_section(flags);
return OK;
}
/****************************************************************************
* Name: altmdm_sys_referflag
*
* Description:
* Refer event flag.
*
****************************************************************************/
int altmdm_sys_referflag(FAR struct altmdm_sys_flag_s *handle,
FAR struct altmdm_sys_flagstate_s *status)
{
irqstate_t flags;
/* Check argument. */
if ((handle == NULL) || (status == NULL))
{
return ERROR;
}
flags = enter_critical_section();
status->flag_pattern = handle->flag;
leave_critical_section(flags);
return OK;
}
/****************************************************************************
* Name: altmdm_sys_starttimer
*
* Description:
* Start timer.
*
****************************************************************************/
timer_t altmdm_sys_starttimer(int first_ms, int interval_ms,
FAR void *handler, int int_param,
FAR void *ptr_param)
{
int ret;
sigset_t mask;
struct sigaction sa;
struct sigevent sev;
struct itimerspec timer;
timer_t timerid;
/* Check argument. */
if (handler == NULL)
{
return NULL;
}
sigemptyset(&mask);
nxsig_addset(&mask, MY_TIMER_SIGNAL);
ret = nxsig_procmask(SIG_UNBLOCK, &mask, NULL);
if (ret != OK)
{
m_err("nxsig_procmask() failed:%d\n", ret);
return NULL;
}
sa.sa_sigaction = handler;
sa.sa_flags = SA_SIGINFO;
sigfillset(&sa.sa_mask);
nxsig_delset(&sa.sa_mask, MY_TIMER_SIGNAL);
ret = nxsig_action(MY_TIMER_SIGNAL, &sa, NULL, false);
if (ret != OK)
{
m_err("nxsig_action() failed:%d\n", ret);
return NULL;
}
sev.sigev_notify = SIGEV_SIGNAL;
sev.sigev_signo = MY_TIMER_SIGNAL;
sev.sigev_value.sival_int = int_param;
sev.sigev_value.sival_ptr = ptr_param;
ret = timer_create(CLOCK_REALTIME, &sev, &timerid);
if (ret != OK)
{
m_err("timer_create() failed:%d\n", ret);
return NULL;
}
timer.it_value.tv_sec = first_ms / 1000;
timer.it_value.tv_nsec = (first_ms % 1000) * 1000 * 1000;
timer.it_interval.tv_sec = interval_ms / 1000;
timer.it_interval.tv_nsec = (interval_ms % 1000) * 1000 * 1000;
ret = timer_settime(timerid, 0, &timer, NULL);
if (ret != OK)
{
m_err("timer_settime() failed:%d\n", ret);
return NULL;
}
return timerid;
}
/****************************************************************************
* Name: altmdm_sys_restarttimer
*
* Description:
* Restart timer.
*
****************************************************************************/
int altmdm_sys_restarttimer(timer_t timerid, int first_ms, int interval_ms)
{
int ret;
struct itimerspec timer;
timer.it_value.tv_sec = first_ms / 1000;
timer.it_value.tv_nsec = (first_ms % 1000) * 1000 * 1000;
timer.it_interval.tv_sec = interval_ms / 1000;
timer.it_interval.tv_nsec = (interval_ms % 1000) * 1000 * 1000;
ret = timer_settime(timerid, 0, &timer, NULL);
if (ret != OK)
{
m_err("timer_settime() failed:%d\n", ret);
return ret;
}
return ret;
}
/****************************************************************************
* Name: altmdm_sys_stoptimer
*
* Description:
* Stop timer.
*
****************************************************************************/
void altmdm_sys_stoptimer(timer_t timerid)
{
sigset_t mask;
timer_delete(timerid);
sigfillset(&mask);
nxsig_procmask(SIG_SETMASK, &mask, NULL);
}
#endif

View file

@ -1,260 +0,0 @@
/****************************************************************************
* drivers/modem/altair/altmdm_sys.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 __DRIVERS_MODEM_ALTAIR_ALTMDM_SYS_H
#define __DRIVERS_MODEM_ALTAIR_ALTMDM_SYS_H
#if defined(CONFIG_MODEM_ALTMDM)
/****************************************************************************
* Included Files
****************************************************************************/
#include <time.h>
#include <nuttx/mutex.h>
#include <nuttx/semaphore.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define ALTMDM_SYS_FLAG_WMODEOR 0
#define ALTMDM_SYS_FLAG_WMODEAND 1
#define ALTMDM_SYS_FLAG_TMOFEVR 0
/****************************************************************************
* Public Types
****************************************************************************/
struct altmdm_sys_lock_s
{
mutex_t lock;
};
struct altmdm_sys_csem_s
{
sem_t sem;
};
struct altmdm_sys_flag_s
{
sem_t sem;
uint32_t flag;
};
struct altmdm_sys_flagstate_s
{
uint32_t flag_pattern;
};
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: altmdm_sys_initlock
*
* Description:
* Initialize lock resource.
*
****************************************************************************/
int altmdm_sys_initlock(FAR struct altmdm_sys_lock_s *handle);
/****************************************************************************
* Name: altmdm_sys_deletelock
*
* Description:
* Delete lock resource
*
****************************************************************************/
int altmdm_sys_deletelock(FAR struct altmdm_sys_lock_s *handle);
/****************************************************************************
* Name: altmdm_sys_lock
*
* Description:
* Acquire lock.
*
****************************************************************************/
int altmdm_sys_lock(FAR struct altmdm_sys_lock_s *handle);
/****************************************************************************
* Name: altmdm_sys_unlock
*
* Description:
* Release lock.
*
****************************************************************************/
int altmdm_sys_unlock(FAR struct altmdm_sys_lock_s *handle);
/****************************************************************************
* Name: altmdm_sys_initcsem
*
* Description:
* Initialize counting semaphore.
*
****************************************************************************/
int altmdm_sys_initcsem(FAR struct altmdm_sys_csem_s *handle);
/****************************************************************************
* Name: altmdm_sys_deletecsem
*
* Description:
* Delete counting semaphore.
*
****************************************************************************/
int altmdm_sys_deletecsem(FAR struct altmdm_sys_csem_s *handle);
/****************************************************************************
* Name: altmdm_sys_waitcsem
*
* Description:
* Wait counting semaphore.
*
****************************************************************************/
int altmdm_sys_waitcsem(FAR struct altmdm_sys_csem_s *handle);
/****************************************************************************
* Name: altmdm_sys_postcsem
*
* Description:
* Post counting semaphore.
*
****************************************************************************/
int altmdm_sys_postcsem(FAR struct altmdm_sys_csem_s *handle);
/****************************************************************************
* Name: altmdm_sys_getcsemvalue
*
* Description:
* Get value of counting semaphore.
*
****************************************************************************/
int altmdm_sys_getcsemvalue(FAR struct altmdm_sys_csem_s *handle,
FAR int *value);
/****************************************************************************
* Name: altmdm_sys_initflag
*
* Description:
* Initialize event flag resource.
*
****************************************************************************/
int altmdm_sys_initflag(FAR struct altmdm_sys_flag_s *handle);
/****************************************************************************
* Name: altmdm_sys_deleteflag
*
* Description:
* Delete event flag resource.
*
****************************************************************************/
int altmdm_sys_deleteflag(FAR struct altmdm_sys_flag_s *handle);
/****************************************************************************
* Name: altmdm_sys_waitflag
*
* Description:
* Wait event flag.
*
****************************************************************************/
int altmdm_sys_waitflag(FAR struct altmdm_sys_flag_s *handle,
uint32_t wait_pattern, uint32_t wait_mode,
FAR uint32_t * pattern, uint32_t timeout_ms);
/****************************************************************************
* Name: altmdm_sys_setflag
*
* Description:
* Set event flag.
*
****************************************************************************/
int altmdm_sys_setflag(FAR struct altmdm_sys_flag_s *handle,
uint32_t pattern);
/****************************************************************************
* Name: altmdm_sys_clearflag
*
* Description:
* Clear event flag.
*
****************************************************************************/
int altmdm_sys_clearflag(FAR struct altmdm_sys_flag_s *handle,
uint32_t pattern);
/****************************************************************************
* Name: altmdm_sys_referflag
*
* Description:
* Refer event flag.
*
****************************************************************************/
int altmdm_sys_referflag(FAR struct altmdm_sys_flag_s *handle,
FAR struct altmdm_sys_flagstate_s *status);
/****************************************************************************
* Name: altmdm_sys_starttimer
*
* Description:
* Start timer.
*
****************************************************************************/
timer_t altmdm_sys_starttimer(int first_ms, int interval_ms,
FAR void *handler, int int_param,
FAR void *ptr_param);
/****************************************************************************
* Name: altmdm_sys_restarttimer
*
* Description:
* Restart timer.
*
****************************************************************************/
int altmdm_sys_restarttimer(timer_t timerid, int first_ms, int interval_ms);
/****************************************************************************
* Name: altmdm_sys_stoptimer
*
* Description:
* Stop timer.
*
****************************************************************************/
void altmdm_sys_stoptimer(timer_t timerid);
#endif
#endif /* __DRIVERS_MODEM_ALTAIR_ALTMDM_SYS_H */

View file

@ -91,6 +91,7 @@
#define _MMCSDIOBASE (0x3300) /* MMCSD device ioctl commands */
#define _BLUETOOTHBASE (0x3400) /* Bluetooth ioctl commands */
#define _PKTRADIOBASE (0x3500) /* Packet radio ioctl commands */
#define _LTEBASE (0x3600) /* LTE device ioctl commands */
#define _WLIOCBASE (0x8b00) /* Wireless modules ioctl network commands */
/* boardctl() commands share the same number space */
@ -593,6 +594,11 @@
#define _PKRADIOIOCVALID(c) (_IOC_TYPE(c)==_PKTRADIOBASE)
#define _PKRADIOIOC(nr) _IOC(_PKTRADIOBASE,nr)
/* LTE device ioctl definitions *********************************************/
#define _LTEIOCVALID(c) (_IOC_TYPE(c)==_LTEBASE)
#define _LTEIOC(nr) _IOC(_LTEBASE,nr)
/* Wireless driver network ioctl definitions ********************************/
/* (see nuttx/include/wireless/wireless.h */

View file

@ -0,0 +1,394 @@
/****************************************************************************
* include/nuttx/modem/alt1250.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 __INCLUDE_NUTTX_MODEM_ALT1250_H
#define __INCLUDE_NUTTX_MODEM_ALT1250_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/spi/spi.h>
#include <nuttx/queue.h>
#include <semaphore.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <pthread.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Debug ********************************************************************/
/* Non-standard debug that may be enabled just for testing the modem driver */
#ifdef CONFIG_MODEM_ALT1250_DEBUG
# define m_err _err
# define m_warn _warn
# define m_info _info
#else
# define m_err(...)
# define m_warn(...)
# define m_info(...)
#endif
#define ALT1250_IOC_POWER _MODEMIOC(1)
#define ALT1250_IOC_SEND _MODEMIOC(2)
#define ALT1250_IOC_SETEVTBUFF _MODEMIOC(3)
#define ALT1250_IOC_EXCHGCONTAINER _MODEMIOC(4)
#define ALT1250_EVTBIT_RESET (1ULL << 63)
#define ALT1250_EVTBIT_REPLY (1ULL << 62)
/* Number of sockets */
#define ALTCOM_NSOCKET 10
/* Macros for fcntl */
#define ALTCOM_GETFL 3
#define ALTCOM_SETFL 4
#define ALTCOM_O_NONBLOCK 0x01
#define ALTCOM_FD_SETSIZE ALTCOM_NSOCKET
#define ALTCOM_FDSETSAFESET(s, code) \
do { \
if (((s) < ALTCOM_FD_SETSIZE) && ((int)(s) >= 0)) \
{ \
code; \
} \
} while(0)
#define ALTCOM_FDSETSAFEGET(s, code) \
(((s) < ALTCOM_FD_SETSIZE) && ((int)(s) >= 0) ? (code) : 0)
#define ALTCOM_FD_SET(s, set) ALTCOM_FDSETSAFESET(s, (set)->fd_bits[(s)/8] |= (1 << ((s) & 7)))
#define ALTCOM_FD_CLR(s, set) ALTCOM_FDSETSAFESET(s, (set)->fd_bits[(s)/8] &= ~(1 << ((s) & 7)))
#define ALTCOM_FD_ISSET(s, set) ALTCOM_FDSETSAFEGET(s, (set)->fd_bits[(s)/8] & (1 << ((s) & 7)))
#define ALTCOM_FD_ZERO(set) memset((void*)(set), 0, sizeof(*(set)))
#define ALTCOM_DNS_SERVERS (4)
#define ALTCOM_REPEVT_FLAG_SIMSTAT (1 << 0)
#define ALTCOM_REPEVT_FLAG_LTIME (1 << 1)
#define ALTCOM_VERX (0)
#define ALTCOM_VER1 (1)
#define ALTCOM_VER4 (4)
#define APICMDID_UNKNOWN (0x0000)
#define APICMDID_POWER_ON (0x0001)
#define ALTCOM_CMDID_POWER_ON_V1 (0x0001)
#define ALTCOM_CMDID_POWER_ON_V4 (0x0311)
#define APICMDID_GET_VERSION (0x000C)
#define APICMDID_GET_PHONENO (0x000D)
#define APICMDID_GET_IMSI (0x000E)
#define APICMDID_GET_IMEI (0x000F)
#define APICMDID_GET_PINSET (0x0010)
#define APICMDID_SET_PIN_LOCK (0x0011)
#define APICMDID_SET_PIN_CODE (0x0012)
#define APICMDID_ENTER_PIN (0x0013)
#define APICMDID_GET_LTIME (0x0014)
#define APICMDID_GET_OPERATOR (0x0015)
#define APICMDID_SET_REP_EVT (0x0019)
#define APICMDID_SET_REP_QUALITY (0x001A)
#define APICMDID_SET_REP_CELLINFO (0x001B)
#define APICMDID_REPORT_EVT (0x001D)
#define APICMDID_REPORT_QUALITY (0x001E)
#define APICMDID_REPORT_CELLINFO (0x001F)
#define APICMDID_GET_EDRX (0x0020)
#define APICMDID_SET_EDRX (0x0021)
#define APICMDID_GET_PSM (0x0022)
#define APICMDID_SET_PSM (0x0023)
#define APICMDID_GET_CE (0x0024)
#define APICMDID_SET_CE (0x0025)
#define APICMDID_RADIO_ON (0x0026)
#define APICMDID_RADIO_OFF (0x0027)
#define APICMDID_ACTIVATE_PDN (0x0028)
#define APICMDID_DEACTIVATE_PDN (0x0029)
#define APICMDID_DATA_ALLOW (0x002A)
#define APICMDID_GET_NETINFO (0x002B)
#define APICMDID_GET_IMS_CAP (0x002C)
#define APICMDID_SETREP_NETINFO (0x002D)
#define APICMDID_REPORT_NETINFO (0x002E)
#define APICMDID_REPORT_RESTART (0x002F)
#define APICMDID_ERRINFO (0x0030)
#define APICMDID_SET_REP_EVT_LTIME (0x0031)
#define APICMDID_SET_REP_EVT_SIMSTATE (0x0032)
#define APICMDID_POWER_OFF (0x0033)
#define APICMDID_GET_SIMINFO (0x0034)
#define APICMDID_GET_DYNAMICEDRX (0x0035)
#define APICMDID_GET_DYNAMICPSM (0x0036)
#define APICMDID_GET_QUALITY (0x0037)
#define APICMDID_ACTIVATE_PDN_CANCEL (0x0038)
#define APICMDID_FW_INJECTDELTAIMG (0x1040)
#define APICMDID_FW_GETDELTAIMGLEN (0x1041)
#define APICMDID_FW_EXECDELTAUPDATE (0x1042)
#define APICMDID_FW_GETUPDATERESULT (0x1043)
#define APICMDID_CLOGS (0x1023)
#define APICMDID_LOGLIST (0x1024)
#define APICMDID_LOGOPEN (0x1030)
#define APICMDID_LOGCLOSE (0x1031)
#define APICMDID_LOGREAD (0x1033)
#define APICMDID_LOGREMOVE (0x1034)
#define APICMDID_LOGLSEEK (0x1035)
/* dummy ID because not support V1 */
#define APICMDID_GET_CELLINFO (0x0039)
#define APICMDID_GET_RAT (0x00A0)
#define APICMDID_SET_RAT (0x00A1)
#define APICMDID_SEND_ATCMD (0x00B0)
#define APICMDID_URC_EVENT (0x00B2)
#define APICMDID_GET_VERSION_V4 (0x000B)
#define APICMDID_GET_PHONENO_V4 (0x000C)
#define APICMDID_GET_IMSI_V4 (0x000D)
#define APICMDID_GET_IMEI_V4 (0x000E)
#define APICMDID_GET_PINSET_V4 (0x000F)
#define APICMDID_SET_PIN_LOCK_V4 (0x0010)
#define APICMDID_SET_PIN_CODE_V4 (0x0011)
#define APICMDID_ENTER_PIN_V4 (0x0012)
#define APICMDID_GET_LTIME_V4 (0x0013)
#define APICMDID_GET_OPERATOR_V4 (0x0014)
#define APICMDID_GET_SLPMODESET_V4 (0x0015)
#define APICMDID_SET_SLPMODESET_V4 (0x0016)
#define APICMDID_SET_REP_NETSTAT_V4 (0x0017)
#define APICMDID_SET_REP_EVT_V4 (0x0018)
#define APICMDID_SET_REP_QUALITY_V4 (0x0019)
#define APICMDID_SET_REP_CELLINFO_V4 (0x001A)
#define APICMDID_REPORT_NETSTAT_V4 (0x001B)
#define APICMDID_REPORT_EVT_V4 (0x001C)
#define APICMDID_REPORT_QUALITY_V4 (0x001D)
#define APICMDID_REPORT_CELLINFO_V4 (0x001E)
#define APICMDID_GET_EDRX_V4 (0x001F)
#define APICMDID_SET_EDRX_V4 (0x0020)
#define APICMDID_GET_PSM_V4 (0x0021)
#define APICMDID_SET_PSM_V4 (0x0022)
#define APICMDID_GET_CELLINFO_V4 (0x0024)
#define APICMDID_GET_QUALITY_V4 (0x0025)
#define APICMDID_GET_SIMINFO_V4 (0x0310)
#define APICMDID_POWER_ON_V4 (0x0311)
#define APICMDID_RADIO_ON_V4 (0x0312)
#define APICMDID_RADIO_OFF_V4 (0x0313)
#define APICMDID_ACTIVATE_PDN_V4 (0x0314)
#define APICMDID_ACTIVATE_PDN_CANCEL_V4 (0x0315)
#define APICMDID_DEACTIVATE_PDN_V4 (0x0316)
#define APICMDID_DATA_ALLOW_V4 (0x0317)
#define APICMDID_GET_NETINFO_V4 (0x0318)
#define APICMDID_GET_IMS_CAP_V4 (0x0319)
#define APICMDID_SETREP_NETINFO_V4 (0x031A)
#define APICMDID_REPORT_NETINFO_V4 (0x031B)
#define APICMDID_ERRINFO_V4 (0xFFFD)
#define APICMDID_GET_RAT_V4 (0x00A0)
#define APICMDID_SET_RAT_V4 (0x00A1)
#define APICMDID_SEND_ATCMD_V4 (0x0030)
#define APICMDID_URC_EVENT_V4 (0x0032)
#define APICMDID_FW_INJECTDELTAIMG_V4 (0x0270)
#define APICMDID_FW_GETDELTAIMGLEN_V4 (0x0271)
#define APICMDID_FW_EXECDELTAUPDATE_V4 (0x0272)
#define APICMDID_FW_GETUPDATERESULT_V4 (0x0273)
#define APICMDID_CLOGS_V4 (0x0300)
#define APICMDID_LOGLIST_V4 (0x0301)
#define APICMDID_LOGOPEN_V4 (0x0280)
#define APICMDID_LOGCLOSE_V4 (0x0281)
#define APICMDID_LOGREAD_V4 (0x0283)
#define APICMDID_LOGREMOVE_V4 (0x0284)
#define APICMDID_LOGLSEEK_V4 (0x0285)
#define APICMDID_SOCK_ACCEPT (0x0080)
#define APICMDID_SOCK_BIND (0x0081)
#define APICMDID_SOCK_CLOSE (0x0082)
#define APICMDID_SOCK_CONNECT (0x0083)
#define APICMDID_SOCK_FCNTL (0x0084)
#define APICMDID_SOCK_GETADDRINFO (0x0085)
#define APICMDID_SOCK_GETHOSTBYNAME (0x0086)
#define APICMDID_SOCK_GETHOSTBYNAMER (0x0087)
#define APICMDID_SOCK_GETSOCKNAME (0x0088)
#define APICMDID_SOCK_GETSOCKOPT (0x0089)
#define APICMDID_SOCK_LISTEN (0x008A)
#define APICMDID_SOCK_RECV (0x008B)
#define APICMDID_SOCK_RECVFROM (0x008C)
#define APICMDID_SOCK_SELECT (0x008D)
#define APICMDID_SOCK_SEND (0x008E)
#define APICMDID_SOCK_SENDTO (0x008F)
#define APICMDID_SOCK_SHUTDOWN (0x0090)
#define APICMDID_SOCK_SOCKET (0x0091)
#define APICMDID_SOCK_SETSOCKOPT (0x0092)
#define APICMDID_TLS_CONFIG_VERIFY_CALLBACK (0x0129)
#define APICMDID_TLS_CONFIG_VERIFY_CALLBACK_V4 (0x0161)
#define APICMDID_SMS_INIT (0x0330)
#define APICMDID_SMS_FIN (0x0331)
#define APICMDID_SMS_SEND (0x0332)
#define APICMDID_SMS_REPORT_RECV (0x0333)
#define APICMDID_SMS_DELETE (0x0334)
#define ALTCOM_CMDID_ERRIND (0xFFFF)
#define ALTCOM_CMDID_REPLY_BIT (0x8000)
/****************************************************************************
* Public Types
****************************************************************************/
struct alt_power_s
{
uint32_t cmdid;
};
typedef struct alt_container_s
{
sq_entry_t node;
int sock;
unsigned long priv;
uint32_t cmdid;
uint16_t altcid;
uint16_t alttid;
int result;
FAR void **inparam;
size_t inparamlen;
FAR void **outparam;
size_t outparamlen;
} alt_container_t;
typedef enum alt_evtbuf_state_e
{
ALTEVTBUF_ST_WRITABLE = 0,
ALTEVTBUF_ST_NOTWRITABLE = 1,
} alt_evtbuf_state_t;
typedef struct alt_evtbuf_inst_s
{
uint32_t cmdid;
uint16_t altcid;
FAR void **outparam;
size_t outparamlen;
sem_t stat_lock;
alt_evtbuf_state_t stat;
} alt_evtbuf_inst_t;
struct alt_evtbuffer_s
{
unsigned int ninst;
alt_evtbuf_inst_t *inst;
};
struct alt_readdata_s
{
uint64_t evtbitmap;
FAR struct alt_container_s *head;
};
struct alt1250_lower_s
{
FAR struct spi_dev_s * (*poweron)(void);
void (*poweroff)(void);
void (*reset)(void);
void (*irqattach)(xcpt_t handler);
void (*irqenable)(bool enable);
bool (*get_sready)(void);
void (*set_mready)(bool on);
void (*set_wakeup)(bool on);
};
struct altcom_fd_set_s
{
unsigned char fd_bits[(ALTCOM_FD_SETSIZE + 7) / 8];
};
typedef struct altcom_fd_set_s altcom_fd_set;
struct alt_queue_s
{
sq_queue_t queue;
sem_t lock;
};
struct alt1250_dev_s
{
FAR struct spi_dev_s *spi;
FAR const struct alt1250_lower_s *lower;
sem_t refslock;
uint8_t crefs;
struct alt_queue_s waitlist;
struct alt_queue_s replylist;
uint64_t evtbitmap;
sem_t evtmaplock;
sem_t pfdlock;
FAR struct pollfd *pfd;
pthread_t recvthread;
FAR struct alt_evtbuffer_s *evtbuff;
uint32_t discardcnt;
sem_t senddisablelock;
bool senddisable;
FAR alt_container_t *select_container;
struct alt_evtbuf_inst_s select_inst;
};
typedef int32_t (*compose_handler_t)(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf, const size_t pktsz,
FAR uint16_t *altcid);
typedef int32_t (*parse_handler_t)(FAR struct alt1250_dev_s *dev,
FAR uint8_t *pktbuf, size_t pktsz, uint8_t altver, FAR void **arg,
size_t arglen, FAR uint64_t *bitmap);
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Name: alt1250_register
*
* Description:
* Register the ALT1250 character device as 'devpath'.
*
* Input Parameters:
* devpath - The full path to the driver to register. E.g., "/dev/alt1250".
* dev - An instance of the SPI interface to use to communicate with
* ALT1250.
* lower - An instance of the lower interface.
*
* Returned Value:
* Not NULL on success; NULL on failure.
*
****************************************************************************/
FAR void *alt1250_register(FAR const char *devpath,
FAR struct spi_dev_s *dev, FAR const struct alt1250_lower_s *lower);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __INCLUDE_NUTTX_MODEM_ALT1250_H */

View file

@ -1,151 +0,0 @@
/****************************************************************************
* include/nuttx/modem/altmdm.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 __INCLUDE_NUTTX_MODEM_ALTMDM_H
#define __INCLUDE_NUTTX_MODEM_ALTMDM_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/spi/spi.h>
#include <nuttx/queue.h>
#include <nuttx/irq.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Debug ********************************************************************/
/* Non-standard debug that may be enabled just for testing the modem driver */
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
# define m_err _err
# define m_info _info
#else
# define m_err(x...)
# define m_info(x...)
#endif
#define MODEM_IOC_POWERON _MODEMIOC(1)
#define MODEM_IOC_POWEROFF _MODEMIOC(2)
#define MODEM_IOC_READABORT _MODEMIOC(3)
#define MODEM_IOC_SLEEP _MODEMIOC(4)
#define MODEM_IOC_PM_REGISTERCB _MODEMIOC(5)
#define MODEM_IOC_PM_DEREGISTERCB _MODEMIOC(6)
#define MODEM_IOC_PM_GETSTATE _MODEMIOC(7)
#define MODEM_IOC_PM_INITWAKELOCK _MODEMIOC(8)
#define MODEM_IOC_PM_ACQUIREWAKELOCK _MODEMIOC(9)
#define MODEM_IOC_PM_RELEASEWAKELOCK _MODEMIOC(10)
#define MODEM_IOC_PM_GETNUMOFWAKELOCK _MODEMIOC(11)
#define MODEM_IOC_PM_GETWAKELOCKSTATE _MODEMIOC(12)
#define MODEM_IOC_PM_ERR_REGISTERCB _MODEMIOC(13)
#define MODEM_IOC_PM_ERR_DEREGISTERCB _MODEMIOC(14)
#define MODEM_PM_CB_TYPE_NORMAL 0
#define MODEM_PM_CB_TYPE_ERROR 1
#define MODEM_PM_STATE_SLEEP 0
#define MODEM_PM_STATE_WAKE 1
#define MODEM_PM_ERR_RESET_BOOTSTAT_NONE 0x00
#define MODEM_PM_ERR_RESET_BOOTSTAT_BOOTING 0x01
#define MODEM_PM_ERR_RESET_BOOTSTAT_UPDATING 0x02
#define MODEM_PM_ERR_RESET_BOOTSTAT_DONE 0x10
/****************************************************************************
* Public Types
****************************************************************************/
struct altmdm_pm_wakelock_s
{
sq_entry_t queue;
int count;
};
struct altmdm_lower_s
{
void (*poweron)(void);
void (*poweroff)(void);
void (*sready_irqattach)(bool attach, xcpt_t handler);
void (*sready_irqenable)(bool enable);
bool (*sready)(void);
void (*master_request)(bool request);
void (*wakeup)(bool wakeup);
uint32_t (*spi_maxfreq)(void);
};
typedef void (*altmdm_pm_cbfunc_t) (uint32_t state);
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Name: altmdm_register
*
* Description:
* Register the ALTMDM character device as 'devpath'.
*
* Input Parameters:
* devpath - The full path to the driver to register. E.g., "/dev/altmdm".
* dev - An instance of the SPI interface to use to communicate with
* ALTMDM.
* lower - An instance of the lower interface.
*
* Returned Value:
* Not NULL on success; NULL on failure.
*
****************************************************************************/
FAR void *altmdm_register(FAR const char *devpath, FAR struct spi_dev_s *dev,
FAR const struct altmdm_lower_s *lower);
/****************************************************************************
* Name: altmdm_unregister
*
* Description:
* Unregister the ALTMDM character device.
*
* Input Parameters:
* handle - The pointer that getting from altmdm_register.
*
* Returned Value:
* None.
*
****************************************************************************/
void altmdm_unregister(FAR void *handle);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __INCLUDE_NUTTX_MODEM_ALTMDM_H */

163
include/nuttx/net/sms.h Normal file
View file

@ -0,0 +1,163 @@
/****************************************************************************
* include/nuttx/net/sms.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 __INCLUDE_NUTTX_NET_SMS_H
#define __INCLUDE_NUTTX_NET_SMS_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define SMS_MAX_ADDRLEN 16 /* 16 characters in USC2 format: 32byte */
#define SMS_MAX_DATALEN 670 /* 670 characters in USC2 format: 1340byte */
#define SMS_MSG_TYPE_DELIVER 0
#define SMS_MSG_TYPE_STATUS_REPORT 1
#define SMS_STATUS_SUCCESS 0
#define SMS_STATUS_FAILED 1
#define SMS_STATUS_PENDING 2
#define SMS_CHSET_UCS2 0
#define SMS_CHSET_GSM7 1
#define SMS_CHSET_BINARY 2
#define SMS_CONCATENATE_MAX 10
/* Nature of Address Indicator */
#define SMS_NAI_UNKNOWN 0x0 /* Unknown */
#define SMS_NAI_INTERNATIONAL 0x1 /* International number */
#define SMS_NAI_NATIONAL 0x2 /* National number */
#define SMS_NAI_NETWORK_SPEC 0x3 /* Network specific number */
#define SMS_NAI_SUBSCRIBER 0x4 /* Subscriber number */
#define SMS_NAI_ALPANUMERIC 0x5 /* Alphanumeric */
#define SMS_NAI_ABBREVIATED 0x6 /* Abbreviated number */
#define SMS_NAI_RESERVED 0x7 /* Reserved for extension */
/* Numbering Plan Indicator */
#define SMS_NPI_UNKNOWN 0x0 /* Unknown */
#define SMS_NPI_ISDN 0x1 /* ISDN/telephone numbering plan */
#define SMS_NPI_DATA 0x3 /* Data numbering plan */
#define SMS_NPI_TELEX 0x4 /* Telex numbering plan */
#define SMS_NPI_SERVICE_CENTRE_SPEC 0x5 /* Service Centre Specific plan 1) */
#define SMS_NPI_SERVICE_CENTRE_SPEC2 0x6 /* Service Centre Specific plan 1) */
#define SMS_NPI_NATIONAL 0x8 /* National numbering plan */
#define SMS_NPI_PRIVATE 0x9 /* Private numbering plan */
#define SMS_NPI_ERMES 0xa /* ERMES numbering plan */
#define SMS_NPI_RESERVED 0xf /* Reserved for extension */
#define SMS_NAI_SHIFT(a) ((a) << 4)
#define SMS_SET_TOA(a, p) (SMS_NAI_SHIFT(a) | (p))
/****************************************************************************
* Public Types
****************************************************************************/
struct sms_timestamp_s
{
unsigned char year; /* Years (0-99) */
unsigned char mon; /* Month (1-12) */
unsigned char mday; /* Day of the month (1-31) */
unsigned char hour; /* Hours (0-23) */
unsigned char min; /* Minutes (0-59) */
unsigned char sec; /* Seconds (0-59) */
signed char tz; /* Time zone (-24-24) */
};
/* This is the data structure used when sending SMS */
struct sms_send_msg_header_s
{
unsigned char destaddrlen;
unsigned char reserve;
unsigned short datalen;
unsigned short destaddr[SMS_MAX_ADDRLEN];
};
struct sms_send_msg_s
{
struct sms_send_msg_header_s header;
unsigned short data[0]; /* payload data in USC2 format */
};
/* This is the data structure used when receiving SMS */
struct sms_recv_msg_header_s
{
unsigned char msgtype;
struct sms_timestamp_s send_time;
unsigned char srcaddrlen;
unsigned char reserve;
unsigned short datalen;
unsigned short srcaddr[SMS_MAX_ADDRLEN];
};
struct sms_deliver_msg_s
{
struct sms_recv_msg_header_s header;
unsigned short data[0]; /* payload data in USC2 format */
};
struct sms_deliver_msg_max_s
{
struct sms_recv_msg_header_s header;
unsigned short data[SMS_MAX_DATALEN]; /* payload data in USC2 format */
};
struct sms_status_report_s
{
unsigned char refid;
unsigned char status;
unsigned char reserve;
struct sms_timestamp_s discharge_time;
};
struct sms_status_report_msg_s
{
struct sms_recv_msg_header_s header;
struct sms_status_report_s status_report;
};
struct sms_refids_s
{
unsigned char nrefid;
unsigned char refid[SMS_CONCATENATE_MAX];
};
struct sms_sc_addr_s
{
unsigned char toa;
unsigned char addrlen;
unsigned short addr[SMS_MAX_ADDRLEN];
};
#endif /* __INCLUDE_NUTTX_NET_SMS_H */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,371 @@
/****************************************************************************
* include/nuttx/wireless/lte/lte_ioctl.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 __INCLUDE_NUTTX_WIRELESS_LTE_LTE_IOCTL_H
#define __INCLUDE_NUTTX_WIRELESS_LTE_LTE_IOCTL_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdint.h>
#include <stdbool.h>
#include <nuttx/wireless/wireless.h>
#include <nuttx/net/sms.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* LTE network device IOCTL commands. */
/* SIOCLTECMD
* Description: Perform LTE command
*/
#define SIOCLTECMD _LTEIOC(0)
/* SIOCSMSENSTREP
* Description: Enable or disable the function to confirm whether or not
* the SMS has been delivered to the destination device.
*/
#define SIOCSMSENSTREP _LTEIOC(1)
/* SIOCSMSGREFID
* Description: Obtain the ID associated with the submitted SMS.
* If the submitted SMS is a concatenated SMS, multiple IDs
* will be obtained;
* otherwise, a single ID will be obtained.
*/
#define SIOCSMSGREFID _LTEIOC(2)
/* SIOCSMSSSCA
* Description: Set the service center address of the destination.
*/
#define SIOCSMSSSCA _LTEIOC(3)
/* for cmdid */
#define _CMDOPT_LSB (28)
#define _CMDOPT_MASK (0xf << (_CMDOPT_LSB))
#define _CMDGRP_LSB (24)
#define _CMDGRP_MASK (0xf << (_CMDGRP_LSB))
#define _CMDGRP_SHIFT(nr) ((nr) << (_CMDGRP_LSB))
#define _CMDGRP_NORMAL(nr) (_CMDGRP_SHIFT(0) | (nr))
#define _CMDGRP_EVENT(nr) (_CMDGRP_SHIFT(1) | (nr))
#define _CMDGRP_NOMDM(nr) (_CMDGRP_SHIFT(2) | (nr))
#define _CMDGRP_POWER(nr) (_CMDGRP_SHIFT(3) | (nr))
#define _CMDGRP_FWUPDATE(nr) (_CMDGRP_SHIFT(4) | (nr))
#define _CMDGRP_EXTEND(nr) (_CMDGRP_SHIFT(5) | (nr))
#define _CMDGRP_LWM2M(nr) (_CMDGRP_SHIFT(6) | (nr))
#define LTE_CMDOPT_ASYNC_BIT (0x1 << (_CMDOPT_LSB))
#define LTE_IS_ASYNC_CMD(cid) ((cid) & LTE_CMDOPT_ASYNC_BIT)
#define LTE_PURE_CMDID(cid) ((cid) & ~LTE_CMDOPT_ASYNC_BIT)
#define LTE_ISCMDGRP_NORMAL(cmd) ((cmd & _CMDGRP_MASK) == _CMDGRP_NORMAL(0))
#define LTE_ISCMDGRP_EVENT(cmd) ((cmd & _CMDGRP_MASK) == _CMDGRP_EVENT(0))
#define LTE_ISCMDGRP_NOMDM(cmd) ((cmd & _CMDGRP_MASK) == _CMDGRP_NOMDM(0))
#define LTE_ISCMDGRP_POWER(cmd) ((cmd & _CMDGRP_MASK) == _CMDGRP_POWER(0))
#define LTE_ISCMDGRP_FWUPDATE(cmd) ((cmd & _CMDGRP_MASK) == _CMDGRP_FWUPDATE(0))
#define LTE_ISCMDGRP_EXTEND(cmd) ((cmd & _CMDGRP_MASK) == _CMDGRP_EXTEND(0))
#define LTE_ISCMDGRP_LWM2M(cmd) ((cmd & _CMDGRP_MASK) == _CMDGRP_LWM2M(0))
#define LTE_CMDID_POWERON _CMDGRP_POWER(0x00)
#define LTE_CMDID_POWEROFF _CMDGRP_POWER(0x01)
#define LTE_CMDID_FIN _CMDGRP_POWER(0x02)
#define LTE_CMDID_SETEVTCTX _CMDGRP_NOMDM(0x03)
#define LTE_CMDID_SETRESTART _CMDGRP_NOMDM(0x04)
#define LTE_CMDID_GETERRINFO _CMDGRP_NOMDM(0x05)
#define LTE_CMDID_GETVER _CMDGRP_NORMAL(0x06)
#define LTE_CMDID_RADIOON _CMDGRP_NORMAL(0x07)
#define LTE_CMDID_RADIOOFF _CMDGRP_NORMAL(0x08)
#define LTE_CMDID_ACTPDN _CMDGRP_NORMAL(0x09)
#define LTE_CMDID_ACTPDNCAN _CMDGRP_NORMAL(0x0a)
#define LTE_CMDID_DEACTPDN _CMDGRP_NORMAL(0x0b)
#define LTE_CMDID_GETNETINFO _CMDGRP_NORMAL(0x0c)
#define LTE_CMDID_IMSCAP _CMDGRP_NORMAL(0x0d)
#define LTE_CMDID_GETPHONE _CMDGRP_NORMAL(0x0e)
#define LTE_CMDID_GETIMSI _CMDGRP_NORMAL(0x0f)
#define LTE_CMDID_GETIMEI _CMDGRP_NORMAL(0x10)
#define LTE_CMDID_GETPINSET _CMDGRP_NORMAL(0x11)
#define LTE_CMDID_PINENABLE _CMDGRP_NORMAL(0x12)
#define LTE_CMDID_CHANGEPIN _CMDGRP_NORMAL(0x13)
#define LTE_CMDID_ENTERPIN _CMDGRP_NORMAL(0x14)
#define LTE_CMDID_GETLTIME _CMDGRP_NORMAL(0x15)
#define LTE_CMDID_GETOPER _CMDGRP_NORMAL(0x16)
#define LTE_CMDID_GETEDRX _CMDGRP_NORMAL(0x17)
#define LTE_CMDID_SETEDRX _CMDGRP_NORMAL(0x18)
#define LTE_CMDID_GETPSM _CMDGRP_NORMAL(0x19)
#define LTE_CMDID_SETPSM _CMDGRP_NORMAL(0x1a)
#define LTE_CMDID_GETCE _CMDGRP_NORMAL(0x1b)
#define LTE_CMDID_SETCE _CMDGRP_NORMAL(0x1c)
#define LTE_CMDID_GETSIMINFO _CMDGRP_NORMAL(0x1d)
#define LTE_CMDID_GETCEDRX _CMDGRP_NORMAL(0x1e)
#define LTE_CMDID_GETCPSM _CMDGRP_NORMAL(0x1f)
#define LTE_CMDID_GETQUAL _CMDGRP_NORMAL(0x20)
#define LTE_CMDID_GETCELL _CMDGRP_NORMAL(0x21)
#define LTE_CMDID_GETRAT _CMDGRP_NORMAL(0x22)
#define LTE_CMDID_SETRAT _CMDGRP_NORMAL(0x23)
#define LTE_CMDID_GETRATINFO _CMDGRP_NORMAL(0x24)
#define LTE_CMDID_REPNETINFO _CMDGRP_EVENT(0x25)
#define LTE_CMDID_REPSIMSTAT _CMDGRP_EVENT(0x26)
#define LTE_CMDID_REPLTIME _CMDGRP_EVENT(0x27)
#define LTE_CMDID_REPQUAL _CMDGRP_EVENT(0x28)
#define LTE_CMDID_REPCELL _CMDGRP_EVENT(0x29)
#define LTE_CMDID_SAVEAPN _CMDGRP_NOMDM(0x2a)
#define LTE_CMDID_GETAPN _CMDGRP_NOMDM(0x2b)
#define LTE_CMDID_TAKEWLOCK _CMDGRP_POWER(0x2c)
#define LTE_CMDID_GIVEWLOCK _CMDGRP_POWER(0x2d)
#define LTE_CMDID_SENDATCMD _CMDGRP_NORMAL(0x2e)
#define LTE_CMDID_INJECTIMAGE _CMDGRP_FWUPDATE(0x2f)
#define LTE_CMDID_GETIMAGELEN _CMDGRP_FWUPDATE(0x30)
#define LTE_CMDID_EXEUPDATE _CMDGRP_FWUPDATE(0x31)
#define LTE_CMDID_GETUPDATERES _CMDGRP_NORMAL(0x32)
#define LTE_CMDID_FACTORY_RESET _CMDGRP_EXTEND(0x33)
#define LTE_CMDID_SAVE_LOG _CMDGRP_NORMAL(0x34)
#define LTE_CMDID_GET_LOGLIST _CMDGRP_NORMAL(0x35)
#define LTE_CMDID_LOGOPEN _CMDGRP_NORMAL(0x36)
#define LTE_CMDID_LOGCLOSE _CMDGRP_NORMAL(0x37)
#define LTE_CMDID_LOGREAD _CMDGRP_NORMAL(0x38)
#define LTE_CMDID_LOGLSEEK _CMDGRP_NORMAL(0x39)
#define LTE_CMDID_LOGREMOVE _CMDGRP_NORMAL(0x3a)
#define LTE_CMDID_ACCEPT _CMDGRP_NORMAL(0x50)
#define LTE_CMDID_BIND _CMDGRP_NORMAL(0x51)
#define LTE_CMDID_CLOSE _CMDGRP_NORMAL(0x52)
#define LTE_CMDID_CONNECT _CMDGRP_NORMAL(0x53)
#define LTE_CMDID_FCNTL _CMDGRP_NORMAL(0x54)
#define LTE_CMDID_GETADDRINFO _CMDGRP_NORMAL(0x55)
#define LTE_CMDID_GETHOSTBYNAME _CMDGRP_NORMAL(0x56)
#define LTE_CMDID_GETHOSTBYNAMER _CMDGRP_NORMAL(0x57)
#define LTE_CMDID_GETSOCKNAME _CMDGRP_NORMAL(0x58)
#define LTE_CMDID_GETSOCKOPT _CMDGRP_NORMAL(0x59)
#define LTE_CMDID_LISTEN _CMDGRP_NORMAL(0x5a)
#define LTE_CMDID_RECV _CMDGRP_NORMAL(0x5b)
#define LTE_CMDID_RECVFROM _CMDGRP_NORMAL(0x5c)
#define LTE_CMDID_SELECT _CMDGRP_NORMAL(0x5d)
#define LTE_CMDID_SEND _CMDGRP_NORMAL(0x5e)
#define LTE_CMDID_SENDTO _CMDGRP_NORMAL(0x5f)
#define LTE_CMDID_SHUTDOWN _CMDGRP_NORMAL(0x60)
#define LTE_CMDID_SOCKET _CMDGRP_NORMAL(0x61)
#define LTE_CMDID_SETSOCKOPT _CMDGRP_NORMAL(0x62)
#define LTE_CMDID_SMS_INIT _CMDGRP_NORMAL(0x65)
#define LTE_CMDID_SMS_FIN _CMDGRP_NORMAL(0x66)
#define LTE_CMDID_SMS_SEND _CMDGRP_NORMAL(0x67)
#define LTE_CMDID_SMS_DELETE _CMDGRP_NORMAL(0x68)
#define LTE_CMDID_SMS_REPORT_RECV _CMDGRP_EVENT(0x69)
#define LTE_CMDID_TLS_SSL_INIT _CMDGRP_NORMAL(0x80)
#define LTE_CMDID_TLS_SSL_FREE _CMDGRP_NORMAL(0x81)
#define LTE_CMDID_TLS_SSL_SETUP _CMDGRP_NORMAL(0x82)
#define LTE_CMDID_TLS_SSL_HOSTNAME _CMDGRP_NORMAL(0x83)
#define LTE_CMDID_TLS_SSL_BIO _CMDGRP_NORMAL(0x84)
#define LTE_CMDID_TLS_SSL_HANDSHAKE _CMDGRP_NORMAL(0x85)
#define LTE_CMDID_TLS_SSL_WRITE _CMDGRP_NORMAL(0x86)
#define LTE_CMDID_TLS_SSL_READ _CMDGRP_NORMAL(0x87)
#define LTE_CMDID_TLS_SSL_CLOSE_NOTIFY _CMDGRP_NORMAL(0x88)
#define LTE_CMDID_TLS_SSL_VERSION _CMDGRP_NORMAL(0x89)
#define LTE_CMDID_TLS_SSL_CIPHERSUITE _CMDGRP_NORMAL(0x8a)
#define LTE_CMDID_TLS_SSL_CIPHERSUITE_ID _CMDGRP_NORMAL(0x8b)
#define LTE_CMDID_TLS_SSL_RECORD_EXPANSION _CMDGRP_NORMAL(0x8c)
#define LTE_CMDID_TLS_SSL_VERIFY_RESULT _CMDGRP_NORMAL(0x8d)
#define LTE_CMDID_TLS_SSL_TIMER_CB _CMDGRP_NORMAL(0x8e)
#define LTE_CMDID_TLS_SSL_PEER_CERT _CMDGRP_NORMAL(0x8f)
#define LTE_CMDID_TLS_SSL_BYTES_AVAIL _CMDGRP_NORMAL(0x90)
#define LTE_CMDID_TLS_CONFIG_INIT _CMDGRP_NORMAL(0x91)
#define LTE_CMDID_TLS_CONFIG_FREE _CMDGRP_NORMAL(0x92)
#define LTE_CMDID_TLS_CONFIG_DEFAULTS _CMDGRP_NORMAL(0x93)
#define LTE_CMDID_TLS_CONFIG_AUTHMODE _CMDGRP_NORMAL(0x94)
#define LTE_CMDID_TLS_CONFIG_RNG _CMDGRP_NORMAL(0x95)
#define LTE_CMDID_TLS_CONFIG_CA_CHAIN _CMDGRP_NORMAL(0x96)
#define LTE_CMDID_TLS_CONFIG_OWN_CERT _CMDGRP_NORMAL(0x97)
#define LTE_CMDID_TLS_CONFIG_READ_TIMEOUT _CMDGRP_NORMAL(0x98)
#define LTE_CMDID_TLS_CONFIG_VERIFY _CMDGRP_EVENT(0x99)
#define LTE_CMDID_TLS_CONFIG_VERIFY_CALLBACK _CMDGRP_NORMAL(0x9a)
#define LTE_CMDID_TLS_CONFIG_ALPN_PROTOCOLS _CMDGRP_NORMAL(0x9b)
#define LTE_CMDID_TLS_CONFIG_CIPHERSUITES _CMDGRP_NORMAL(0x9c)
#define LTE_CMDID_TLS_SESSION_INIT _CMDGRP_NORMAL(0x9d)
#define LTE_CMDID_TLS_SESSION_FREE _CMDGRP_NORMAL(0x9e)
#define LTE_CMDID_TLS_SESSION_GET _CMDGRP_NORMAL(0x9f)
#define LTE_CMDID_TLS_SESSION_SET _CMDGRP_NORMAL(0xa0)
#define LTE_CMDID_TLS_SESSION_RESET _CMDGRP_NORMAL(0xa1)
#define LTE_CMDID_TLS_X509_CRT_INIT _CMDGRP_NORMAL(0xa2)
#define LTE_CMDID_TLS_X509_CRT_FREE _CMDGRP_NORMAL(0xa3)
#define LTE_CMDID_TLS_X509_CRT_PARSE_FILE _CMDGRP_NORMAL(0xa4)
#define LTE_CMDID_TLS_X509_CRT_PARSE_DER _CMDGRP_NORMAL(0xa5)
#define LTE_CMDID_TLS_X509_CRT_PARSE _CMDGRP_NORMAL(0xa6)
#define LTE_CMDID_TLS_X509_CRT_INFO _CMDGRP_NORMAL(0xa7)
#define LTE_CMDID_TLS_X509_CRT_VERIFY_INFO _CMDGRP_NORMAL(0xa8)
#define LTE_CMDID_TLS_PK_INIT _CMDGRP_NORMAL(0xa9)
#define LTE_CMDID_TLS_PK_FREE _CMDGRP_NORMAL(0xaa)
#define LTE_CMDID_TLS_PK_PARSE_KEYFILE _CMDGRP_NORMAL(0xab)
#define LTE_CMDID_TLS_PK_PARSE_KEY _CMDGRP_NORMAL(0xac)
#define LTE_CMDID_TLS_PK_CHECK_PAIR _CMDGRP_NORMAL(0xad)
#define LTE_CMDID_TLS_PK_SETUP _CMDGRP_NORMAL(0xae)
#define LTE_CMDID_TLS_PK_INFO_FROM_TYPE _CMDGRP_NORMAL(0xaf)
#define LTE_CMDID_TLS_PK_WRITE_KEY_PEM _CMDGRP_NORMAL(0xb0)
#define LTE_CMDID_TLS_PK_WRITE_KEY_DER _CMDGRP_NORMAL(0xb1)
#define LTE_CMDID_TLS_PK_RSA _CMDGRP_NORMAL(0xb2)
#define LTE_CMDID_TLS_CTR_DRBG_INIT _CMDGRP_NORMAL(0xb3)
#define LTE_CMDID_TLS_CTR_DRBG_FREE _CMDGRP_NORMAL(0xb4)
#define LTE_CMDID_TLS_CTR_DRBG_SEED _CMDGRP_NORMAL(0xb5)
#define LTE_CMDID_TLS_ENTROPY_INIT _CMDGRP_NORMAL(0xb6)
#define LTE_CMDID_TLS_ENTROPY_FREE _CMDGRP_NORMAL(0xb7)
#define LTE_CMDID_TLS_CIPHER_INIT _CMDGRP_NORMAL(0xb8)
#define LTE_CMDID_TLS_CIPHER_FREE _CMDGRP_NORMAL(0xb9)
#define LTE_CMDID_TLS_CIPHER_INFO_FROM_STRING _CMDGRP_NORMAL(0xba)
#define LTE_CMDID_TLS_CIPHER_SETUP _CMDGRP_NORMAL(0xbb)
#define LTE_CMDID_TLS_CIPHER_SETKEY _CMDGRP_NORMAL(0xbc)
#define LTE_CMDID_TLS_CIPHER_SET_IV _CMDGRP_NORMAL(0xbd)
#define LTE_CMDID_TLS_CIPHER_UPDATE _CMDGRP_NORMAL(0xbe)
#define LTE_CMDID_TLS_MD_INFO_FROM_TYPE _CMDGRP_NORMAL(0xbf)
#define LTE_CMDID_TLS_MD_GET_SIZE _CMDGRP_NORMAL(0xc0)
#define LTE_CMDID_TLS_MD _CMDGRP_NORMAL(0xc1)
#define LTE_CMDID_TLS_MD_DIGEST _CMDGRP_NORMAL(0xc2)
#define LTE_CMDID_TLS_BASE64_ENCODE _CMDGRP_NORMAL(0xc3)
#define LTE_CMDID_TLS_SHA1 _CMDGRP_NORMAL(0xc4)
#define LTE_CMDID_TLS_SSL_EXPORT_SRTP_KEYS _CMDGRP_NORMAL(0xc5)
#define LTE_CMDID_TLS_SSL_USE_SRTP _CMDGRP_NORMAL(0xc6)
#define LTE_CMDID_TLS_SSL_SRTP_PROFILE _CMDGRP_NORMAL(0xc7)
#define LTE_CMDID_TLS_SSL_TURN _CMDGRP_NORMAL(0xc8)
#define LTE_CMDID_TLS_MPI_INIT _CMDGRP_NORMAL(0xc9)
#define LTE_CMDID_TLS_MPI_FREE _CMDGRP_NORMAL(0xca)
#define LTE_CMDID_TLS_MPI_READ_STRING _CMDGRP_NORMAL(0xcb)
#define LTE_CMDID_TLS_MPI_WRITE_STRING _CMDGRP_NORMAL(0xcc)
#define LTE_CMDID_TLS_X509_CSR_INIT _CMDGRP_NORMAL(0xcd)
#define LTE_CMDID_TLS_X509_CSR_FREE _CMDGRP_NORMAL(0xce)
#define LTE_CMDID_TLS_X509_CSR_PARSE_FILE _CMDGRP_NORMAL(0xcf)
#define LTE_CMDID_TLS_X509_CSR_PARSE_DER _CMDGRP_NORMAL(0xd0)
#define LTE_CMDID_TLS_X509_CSR_PARSE _CMDGRP_NORMAL(0xd1)
#define LTE_CMDID_TLS_X509_DN_GETS_CRT _CMDGRP_NORMAL(0xd2)
#define LTE_CMDID_TLS_X509_DN_GETS_CSR _CMDGRP_NORMAL(0xd3)
#define LTE_CMDID_TLS_X509WRITE_CRT_INIT _CMDGRP_NORMAL(0xd4)
#define LTE_CMDID_TLS_X509WRITE_CRT_FREE _CMDGRP_NORMAL(0xd5)
#define LTE_CMDID_TLS_X509WRITE_CRT_DER _CMDGRP_NORMAL(0xd6)
#define LTE_CMDID_TLS_X509WRITE_CRT_PEM _CMDGRP_NORMAL(0xd7)
#define LTE_CMDID_TLS_X509WRITE_CRT_SUBJECT_KEY _CMDGRP_NORMAL(0xd8)
#define LTE_CMDID_TLS_X509WRITE_CRT_ISSUER_KEY _CMDGRP_NORMAL(0xd9)
#define LTE_CMDID_TLS_X509WRITE_CRT_SUBJECT_NAME _CMDGRP_NORMAL(0xda)
#define LTE_CMDID_TLS_X509WRITE_CRT_ISSUER_NAME _CMDGRP_NORMAL(0xdb)
#define LTE_CMDID_TLS_X509WRITE_CRT_VERSION _CMDGRP_NORMAL(0xdc)
#define LTE_CMDID_TLS_X509WRITE_CRT_MD_ALG _CMDGRP_NORMAL(0xdd)
#define LTE_CMDID_TLS_X509WRITE_CRT_SERIAL _CMDGRP_NORMAL(0xde)
#define LTE_CMDID_TLS_X509WRITE_CRT_VALIDITY _CMDGRP_NORMAL(0xdf)
#define LTE_CMDID_TLS_X509WRITE_CRT_CONSTRAINTS _CMDGRP_NORMAL(0xe0)
#define LTE_CMDID_TLS_X509WRITE_CRT_SUBJECT_ID _CMDGRP_NORMAL(0xe1)
#define LTE_CMDID_TLS_X509WRITE_CRT_AUTHORITY_ID _CMDGRP_NORMAL(0xe2)
#define LTE_CMDID_TLS_X509WRITE_CRT_KEY_USAGE _CMDGRP_NORMAL(0xe3)
#define LTE_CMDID_TLS_X509WRITE_CRT_NS_CERT_TYPE _CMDGRP_NORMAL(0xe4)
#define LTE_CMDID_TLS_RSA_INIT _CMDGRP_NORMAL(0xe5)
#define LTE_CMDID_TLS_RSA_FREE _CMDGRP_NORMAL(0xe6)
#define LTE_CMDID_TLS_RSA_GEN_KEY _CMDGRP_NORMAL(0xe7)
/* for LwM2M stub */
#define LTE_CMDID_LWM2M_URC_DUMMY _CMDGRP_EVENT(0x0101)
#define LTE_CMDID_LWM2M_READ_EVT _CMDGRP_EVENT(0x0102)
#define LTE_CMDID_LWM2M_WRITE_EVT _CMDGRP_EVENT(0x0103)
#define LTE_CMDID_LWM2M_EXEC_EVT _CMDGRP_EVENT(0x0104)
#define LTE_CMDID_LWM2M_OVSTART_EVT _CMDGRP_EVENT(0x0105)
#define LTE_CMDID_LWM2M_OVSTOP_EVT _CMDGRP_EVENT(0x0106)
#define LTE_CMDID_LWM2M_SERVEROP_EVT _CMDGRP_EVENT(0x0107)
#define LTE_CMDID_LWM2M_FWUP_EVT _CMDGRP_EVENT(0x0108)
#define LTE_CMDID_LWM2M_GETEP _CMDGRP_LWM2M(0x0109)
#define LTE_CMDID_LWM2M_SETEP _CMDGRP_LWM2M(0x010A)
#define LTE_CMDID_LWM2M_GETSRVNUM _CMDGRP_LWM2M(0x010B)
#define LTE_CMDID_LWM2M_GETSRVINFO _CMDGRP_LWM2M(0x010C)
#define LTE_CMDID_LWM2M_SETSRVINFO _CMDGRP_LWM2M(0x010D)
#define LTE_CMDID_LWM2M_GETACTIVEOBJNUM _CMDGRP_LWM2M(0x010E)
#define LTE_CMDID_LWM2M_GETACTIVEOBJ _CMDGRP_LWM2M(0x010F)
#define LTE_CMDID_LWM2M_SETACTIVEOBJ _CMDGRP_LWM2M(0x0110)
#define LTE_CMDID_LWM2M_APPLY_SETTING _CMDGRP_LWM2M(0x0111)
#define LTE_CMDID_LWM2M_GETOBJRESNUM _CMDGRP_LWM2M(0x0112)
#define LTE_CMDID_LWM2M_GETOBJRESOURCE _CMDGRP_LWM2M(0x0113)
#define LTE_CMDID_LWM2M_SETOBJRESOURCE _CMDGRP_LWM2M(0x0114)
#define LTE_CMDID_LWM2M_CONNECT _CMDGRP_LWM2M(0x0115)
#define LTE_CMDID_LWM2M_READRESP _CMDGRP_LWM2M(0x0116)
#define LTE_CMDID_LWM2M_WRITERESP _CMDGRP_LWM2M(0x0117)
#define LTE_CMDID_LWM2M_OBSERVERESP _CMDGRP_LWM2M(0x0118)
#define LTE_CMDID_LWM2M_EXECRESP _CMDGRP_LWM2M(0x0119)
#define LTE_CMDID_LWM2M_OBSERVEUPDATE _CMDGRP_LWM2M(0x011A)
#define IS_LWM2M_EVENT(cid) (\
((cid) == LTE_CMDID_LWM2M_READ_EVT) || \
((cid) == LTE_CMDID_LWM2M_WRITE_EVT) || \
((cid) == LTE_CMDID_LWM2M_EXEC_EVT) || \
((cid) == LTE_CMDID_LWM2M_OVSTART_EVT) || \
((cid) == LTE_CMDID_LWM2M_OVSTOP_EVT) || \
((cid) == LTE_CMDID_LWM2M_SERVEROP_EVT) || \
((cid) == LTE_CMDID_LWM2M_FWUP_EVT) )
/****************************************************************************
* Public Types
****************************************************************************/
typedef void (*lte_evthndl_t)(uint64_t evtbitmap);
/* for SIOCLTECMD IOCTL command */
struct lte_ioctl_data_s
{
uint32_t cmdid; /* Command ID */
FAR void **inparam; /* Pointer to input parameter */
size_t inparamlen; /* Length of input parameter */
FAR void **outparam; /* Pointer to output parameter */
size_t outparamlen; /* Length of output parameter */
FAR void *cb; /* Pointer to callback function */
};
struct lte_evtctx_in_s
{
FAR const char *mqname;
};
struct lte_evtctx_out_s
{
lte_evthndl_t handle;
};
/* for IOCTL related SMS */
struct lte_smsreq_s
{
union
{
/* Using for SIOCSMSENSTREP command */
bool enable;
/* Using for SIOCSMSGREFID command */
struct sms_refids_s refid;
/* Using for SIOCSMSSSCA command */
struct sms_sc_addr_s scaddr;
} smsru;
};
#endif /* __INCLUDE_NUTTX_WIRELESS_LTE_LTE_IOCTL_H */