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
@@ -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
+1 -1
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
+1 -1
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
+33
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
@@ -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
+59
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 */
File diff suppressed because it is too large Load Diff
+123
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 */
+212
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 */
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+72
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 */
+412
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;
}
@@ -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 */
+433
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;
}
+414
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
+240
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 */
+209
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;
}
+156
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 */
+144
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));
}
+280
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 */
+153
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);
}
+111
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 */
-51
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
-427
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
-176
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 */
File diff suppressed because it is too large Load Diff
-212
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 */
-139
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
-172
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 */
File diff suppressed because it is too large Load Diff
-260
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 */
+6
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 */
+394
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 */
-151
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
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
+371
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 */