1
0
Fork 0
forked from nuttx/nuttx-update

drivers/modem/alt1250: Update alt1250 driver

Updated alt1250 driver with regarding to the following changes.
- Add LTE hibernation feature
- Split source code per module
- Some refactoring
- Some bug fixes
This commit is contained in:
SPRESENSE 2023-06-08 10:17:27 +09:00 committed by Alin Jerpelea
parent b89215a11f
commit 54112ac070
44 changed files with 8436 additions and 6385 deletions

View file

@ -38,6 +38,7 @@
#include <arch/board/board.h>
#include <arch/board/cxd56_alt1250.h>
#include <arch/chip/pm.h>
#include "cxd56_spi.h"
#include "cxd56_dmac.h"
@ -79,6 +80,8 @@
static struct spi_dev_s *alt1250_poweron(void);
static void alt1250_poweroff(void);
static bool alt1250_powerstatus(void);
static int alt1250_hibernation_mode(bool enable);
static void alt1250_reset(void);
static void alt1250_irqattach(xcpt_t handler);
static void alt1250_irqenable(bool enable);
@ -95,6 +98,8 @@ static const struct alt1250_lower_s g_alt1250_lower =
{
.poweron = alt1250_poweron,
.poweroff = alt1250_poweroff,
.powerstatus = alt1250_powerstatus,
.hiber_mode = alt1250_hibernation_mode,
.reset = alt1250_reset,
.irqattach = alt1250_irqattach,
.irqenable = alt1250_irqenable,
@ -292,6 +297,43 @@ static void alt1250_poweroff(void)
board_alt1250_poweroff();
}
/****************************************************************************
* Name: alt1250_powerstatus
*
* Description:
* Get the power status for the Altair modem device on the board.
*
****************************************************************************/
static bool alt1250_powerstatus(void)
{
return board_alt1250_powerstatus();
}
/****************************************************************************
* Name: alt1250_hibernation_mode
*
* Description:
* Set power manager for entering hibernation mode.
*
****************************************************************************/
static int alt1250_hibernation_mode(bool enable)
{
uint32_t bootmask = 0;
if (enable)
{
/* Set GPIO interrupt for wake-up */
bootmask = up_pm_get_bootmask();
bootmask |= PM_BOOT_COLD_GPIO;
up_pm_set_bootmask(bootmask);
}
return board_alt1250_powerkeep(enable);
}
/****************************************************************************
* Name: alt1250_reset
*

View file

@ -56,7 +56,7 @@ extern "C"
*
****************************************************************************/
int board_alt1250_initialize(const char *devpath);
int board_alt1250_initialize(FAR const char *devpath);
/****************************************************************************
* Name: board_alt1250_uninitialize
@ -88,6 +88,26 @@ void board_alt1250_poweron(void);
void board_alt1250_poweroff(void);
/****************************************************************************
* Name: board_alt1250_powerstatus
*
* Description:
* Get the power status for the Altair modem device on the board.
*
****************************************************************************/
bool board_alt1250_powerstatus(void);
/****************************************************************************
* Name: board_alt1250_powerkeep
*
* Description:
* Set Modem power keep mode when turning off the board.
*
****************************************************************************/
int board_alt1250_powerkeep(bool enable);
/****************************************************************************
* Name: board_alt1250_reset
*

View file

@ -65,14 +65,6 @@ static sem_t g_wd_wait;
void board_alt1250_poweron(void)
{
/* Power on altair modem device */
cxd56_gpio_config(ALT1250_LTE_POWER_BUTTON, false);
cxd56_gpio_write(ALT1250_LTE_POWER_BUTTON, false);
cxd56_gpio_config(ALT1250_SHUTDOWN, false);
cxd56_gpio_write(ALT1250_SHUTDOWN, true);
board_power_control(POWER_LTE, true);
}
@ -86,12 +78,40 @@ void board_alt1250_poweron(void)
void board_alt1250_poweroff(void)
{
/* Power off Altair modem device */
board_power_control(POWER_LTE, false);
}
cxd56_gpio_write(ALT1250_SHUTDOWN, false);
cxd56_gpio_write(ALT1250_LTE_POWER_BUTTON, false);
/****************************************************************************
* Name: board_alt1250_powerstatus
*
* Description:
* Get the power status for the Altair modem device on the board.
*
****************************************************************************/
bool board_alt1250_powerstatus(void)
{
return board_power_monitor(POWER_LTE);
}
/****************************************************************************
* Name: board_alt1250_powerkeep
*
* Description:
* Set Modem power keep mode when turning off the board.
*
****************************************************************************/
int board_alt1250_powerkeep(bool enable)
{
if (enable)
{
return board_unset_reset_gpo(POWER_LTE);
}
else
{
return board_set_reset_gpo(POWER_LTE);
}
}
/****************************************************************************
@ -124,7 +144,7 @@ void board_alt1250_reset(void)
/* Reset Altair modem device */
cxd56_gpio_write(ALT1250_SHUTDOWN, false);
board_alt1250_poweroff();
/* ALT1250_SHUTDOWN should be low in the range 101usec to 100msec */
@ -135,7 +155,7 @@ void board_alt1250_reset(void)
nxsem_wait_uninterruptible(&g_wd_wait);
cxd56_gpio_write(ALT1250_SHUTDOWN, true);
board_alt1250_poweron();
nxsem_destroy(&g_wd_wait);
}

View file

@ -14,6 +14,34 @@ menuconfig MODEM_ALT1250
if MODEM_ALT1250
menuconfig MODEM_ALT1250_RESTRICTIONS
bool "ALT1250 modem restrictions [Attention. See help]"
default n
---help---
Enable restrict the modem function is at your own risk.
If you don't have enough knowledge of this firmware,
you may get unexpected situation.
if MODEM_ALT1250_RESTRICTIONS
config MODEM_ALT1250_DISABLE_PV1
bool "Disable PV1"
default n
---help---
Enable restrict the modem function is at your own risk.
If you don't have enough knowledge of this firmware,
you may get unexpected situation.
config MODEM_ALT1250_DISABLE_PV4
bool "Disable PV4"
default n
---help---
Enable restrict the modem function is at your own risk.
If you don't have enough knowledge of this firmware,
you may get unexpected situation.
endif
config MODEM_ALT1250_ADDITIONAL_FUNC
bool
default n

View file

@ -24,7 +24,19 @@ ifeq ($(CONFIG_MODEM_ALT1250),y)
CSRCS += alt1250.c
CSRCS += altcom_pkt.c
CSRCS += altcom_hdlr.c
CSRCS += altcom_hdlr_pdn.c
CSRCS += altcom_hdlr_radio.c
CSRCS += altcom_hdlr_net.c
CSRCS += altcom_hdlr_psave.c
CSRCS += altcom_hdlr_sim.c
CSRCS += altcom_hdlr_pin.c
CSRCS += altcom_hdlr_socket.c
CSRCS += altcom_hdlr_sms.c
CSRCS += altcom_hdlr_firmware.c
CSRCS += altcom_hdlr_log.c
CSRCS += altcom_hdlr_other.c
CSRCS += altcom_lwm2m_hdlr.c
CSRCS += altcom_errno.c
CSRCS += altmdm.c
CSRCS += altmdm_event.c
CSRCS += altmdm_spi.c

View file

@ -25,11 +25,15 @@
#include <nuttx/config.h>
#include <nuttx/kmalloc.h>
#include <nuttx/kthread.h>
#include <nuttx/fs/fs.h>
#include <poll.h>
#include <errno.h>
#include <arch/board/board.h>
#include <nuttx/wireless/lte/lte.h>
#include <nuttx/wireless/lte/lte_ioctl.h>
#include <nuttx/modem/alt1250.h>
#include <nuttx/power/pm.h>
#include <assert.h>
#include "altcom_pkt.h"
@ -45,6 +49,16 @@
#define rel_evtbufinst(inst, dev) unlock_evtbufinst(inst, dev)
/****************************************************************************
* Private Types
****************************************************************************/
struct alt1250_res_s
{
sem_t sem;
int code;
};
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
@ -60,8 +74,15 @@ static int alt1250_poll(FAR struct file *filep, FAR struct pollfd *fds,
bool setup);
parse_handler_t alt1250_additional_parsehdlr(uint16_t, uint8_t);
compose_handler_t alt1250_additional_composehdlr(uint32_t, FAR uint8_t *,
size_t);
compose_handler_t alt1250_additional_composehdlr(uint32_t,
FAR uint8_t *, size_t);
#ifdef CONFIG_PM
static int alt1250_pm_prepare(struct pm_callback_s *cb, int domain,
enum pm_state_e pmstate);
static void alt1250_pm_notify(struct pm_callback_s *cb, int domain,
enum pm_state_e pmstate);
#endif
/****************************************************************************
* Private Data
@ -84,6 +105,18 @@ static const struct file_operations g_alt1250fops =
static uint8_t g_recvbuff[ALTCOM_RX_PKT_SIZE_MAX];
static uint8_t g_sendbuff[ALTCOM_PKT_SIZE_MAX];
static struct alt1250_dev_s *g_alt1250_dev;
#ifdef CONFIG_PM
static struct pm_callback_s g_alt1250pmcb =
{
.notify = alt1250_pm_notify,
.prepare = alt1250_pm_prepare,
};
static struct alt1250_res_s g_alt1250_res_s;
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
@ -244,7 +277,8 @@ static ssize_t read_data(FAR struct alt1250_dev_s *dev,
****************************************************************************/
static void write_evtbitmap(FAR struct alt1250_dev_s *dev,
uint64_t bitmap)
uint64_t bitmap,
FAR struct alt_container_s *container)
{
nxmutex_lock(&dev->evtmaplock);
@ -255,28 +289,12 @@ static void write_evtbitmap(FAR struct alt1250_dev_s *dev,
dev->evtbitmap = ALT1250_EVTBIT_RESET;
}
m_info("write bitmap: 0x%llx\n", bitmap);
nxmutex_unlock(&dev->evtmaplock);
}
/****************************************************************************
* Name: write_evtbitmapwithlist
****************************************************************************/
static void write_evtbitmapwithlist(FAR struct alt1250_dev_s *dev,
uint64_t bitmap, FAR struct alt_container_s *container)
{
nxmutex_lock(&dev->evtmaplock);
dev->evtbitmap |= bitmap;
if (dev->evtbitmap & ALT1250_EVTBIT_RESET)
if (container)
{
dev->evtbitmap = ALT1250_EVTBIT_RESET;
add_list(&dev->replylist, container);
}
add_list(&dev->replylist, container);
m_info("write bitmap: 0x%llx\n", bitmap);
nxmutex_unlock(&dev->evtmaplock);
}
@ -496,8 +514,11 @@ static void write_restart_param(FAR void *outp[], FAR void *buff)
* Name: pollnotify
****************************************************************************/
static void pollnotify(FAR struct alt1250_dev_s *dev)
static void pollnotify(FAR struct alt1250_dev_s *dev, uint64_t bitmap,
FAR struct alt_container_s *container)
{
write_evtbitmap(dev, bitmap, container);
nxmutex_lock(&dev->pfdlock);
if (dev->pfd != NULL)
@ -551,6 +572,40 @@ parse_handler_t get_parsehdlr(uint16_t altcid, uint8_t altver)
return ret;
}
#ifdef CONFIG_PM
/****************************************************************************
* Name: alt1250_send_daemon_request
****************************************************************************/
static int alt1250_send_daemon_request(uint64_t bitmap)
{
/* Send event for daemon */
pollnotify(g_alt1250_dev, bitmap, NULL);
/* Waiting for daemon response */
nxsem_wait_uninterruptible(&g_alt1250_res_s.sem);
return g_alt1250_res_s.code;
}
/****************************************************************************
* Name: alt1250_receive_daemon_response
****************************************************************************/
static void alt1250_receive_daemon_response(FAR struct alt_power_s *req)
{
/* Store daemon response code */
g_alt1250_res_s.code = req->resp;
/* Post request semaphore */
nxsem_post(&g_alt1250_res_s.sem);
}
#endif
/****************************************************************************
* Name: alt1250_power_control
****************************************************************************/
@ -578,6 +633,25 @@ static int alt1250_power_control(FAR struct alt1250_dev_s *dev,
ret = altmdm_give_wlock();
break;
case LTE_CMDID_COUNTWLOCK:
ret = altmdm_count_wlock();
break;
#ifdef CONFIG_PM
case LTE_CMDID_STOPAPI:
case LTE_CMDID_SUSPEND:
alt1250_receive_daemon_response(req);
break;
#endif
case LTE_CMDID_RETRYDISABLE:
ret = altmdm_set_pm_event(EVENT_RETRYREQ, false);
break;
case LTE_CMDID_GET_POWER_STAT:
ret = altmdm_get_powersupply(dev->lower);
break;
default:
ret = -EINVAL;
break;
@ -731,23 +805,144 @@ static int exchange_selectcontainer(FAR struct alt1250_dev_s *dev,
return OK;
}
/****************************************************************************
* Name: parse_altcompkt
****************************************************************************/
static int parse_altcompkt(FAR struct alt1250_dev_s *dev, FAR uint8_t *pkt,
int pktlen, FAR uint64_t *bitmap,
FAR struct alt_container_s **container)
{
int ret;
FAR struct altcom_cmdhdr_s *h = (FAR struct altcom_cmdhdr_s *)pkt;
uint16_t cid = parse_cid(h);
uint16_t tid = parse_tid(h);
parse_handler_t parser;
FAR alt_evtbuf_inst_t *inst;
FAR void **outparam;
size_t outparamlen;
m_info("receive cid:0x%04x tid:0x%04x\n", cid, tid);
parser = get_parsehdlr(cid, get_altver(h));
if (is_errind(cid))
{
/* Get ALTCOM command ID and transaction ID
* from payload
*/
cid = parse_cid4errind(h);
tid = parse_tid4errind(h);
m_err("ALT1250 does not support this command. cid:0x%04x tid:0x%04x\n",
cid, tid);
cid |= ALTCOM_CMDID_REPLY_BIT;
}
*container = remove_list(&dev->waitlist, cid, tid);
m_info("container %sfound. cid:0x%04x tid:0x%04x\n",
*container == NULL ? "not " : "", cid, tid);
if (parser == NULL)
{
m_err("parser is not found\n");
/* If there is a container, use the container to notify
* daemon of the event. Otherwise, discard the event.
*/
if (*container)
{
(*container)->result = -ENOSYS;
}
return *container == NULL ? ERROR: OK;
}
/* Obtain outparam and bitmap required for parser execution arguments. */
if (*container)
{
outparam = (*container)->outparam;
outparamlen = (*container)->outparamlen;
*bitmap = get_bitmap(dev, cid, get_altver(h));
}
else
{
/* The outparam is updated in the parser. Lock until the parser
* returns to prevent outparam from being updated by other tasks.
*/
inst = get_evtbuffinst_withlock(dev, cid, get_altver(h), bitmap);
if (inst)
{
outparam = inst->outparam;
outparamlen = inst->outparamlen;
}
else
{
/* Error return means that the event will be discarded. */
return ERROR;
}
}
ret = parser(dev, get_payload(h), get_payload_len(h), get_altver(h),
outparam, outparamlen, bitmap);
if (*container)
{
(*container)->result = ret;
if (LTE_IS_ASYNC_CMD((*container)->cmdid))
{
/* Asynchronous types need to call the callback corresponding
* to the received event, so the REPLY bit is added to the
* received event.
*/
*bitmap |= ALT1250_EVTBIT_REPLY;
}
else
{
/* Synchronous types do not call a callback,
* so only the REPLY bit is needed.
*/
*bitmap = ALT1250_EVTBIT_REPLY;
}
}
else
{
/* Unlock outparam because it has been updated. */
unlock_evtbufinst(inst, dev);
if (ret < 0)
{
/* Error return means that the event will be discarded */
return ERROR;
}
}
/* OK return means that the event will be notified to the daemon. */
return OK;
}
/****************************************************************************
* Name: altcom_recvthread
****************************************************************************/
static void altcom_recvthread(FAR void *arg)
static int altcom_recvthread(int argc, FAR char *argv[])
{
int ret;
FAR struct alt1250_dev_s *dev = (FAR struct alt1250_dev_s *)arg;
FAR struct alt1250_dev_s *dev = g_alt1250_dev;
bool is_running = true;
FAR struct alt_container_s *head;
FAR struct alt_container_s *container;
uint16_t cid;
uint16_t tid;
uint8_t altver;
parse_handler_t handler;
uint64_t bitmap = 0ULL;
int recvedlen = 0;
uint32_t reason;
m_info("recv thread start\n");
@ -767,7 +962,21 @@ static void altcom_recvthread(FAR void *arg)
recvedlen += ret;
ret = altcom_is_pkt_ok(g_recvbuff, recvedlen);
if (ret > 0)
if (ret == 0)
{
ret = parse_altcompkt(dev, g_recvbuff, recvedlen, &bitmap,
&container);
if (ret == OK)
{
pollnotify(dev, bitmap, container);
}
else
{
dev->discardcnt++;
m_err("discard event %lu\n", dev->discardcnt);
}
}
else if (ret > 0)
{
/* Cases in which fragmented packets are received.
* Therefore, the receive process is performed again.
@ -777,8 +986,7 @@ static void altcom_recvthread(FAR void *arg)
ret);
continue;
}
if (ret < 0)
else
{
/* Forced reset of modem due to packet format error detected */
@ -786,213 +994,125 @@ static void altcom_recvthread(FAR void *arg)
altmdm_reset();
}
else
}
else if (ret == ALTMDM_RETURN_RESET_PKT)
{
m_info("recieve ALTMDM_RETURN_RESET_PKT\n");
set_senddisable(dev, true);
}
else if (ret == ALTMDM_RETURN_RESET_V1 ||
ret == ALTMDM_RETURN_RESET_V4)
{
reason = altmdm_get_reset_reason();
m_info("recieve ALTMDM_RETURN_RESET_V%s reason: %d\n",
(ret == ALTMDM_RETURN_RESET_V1) ? "1" : "4",
reason);
#if defined(CONFIG_MODEM_ALT1250_DISABLE_PV1) && \
defined(CONFIG_MODEM_ALT1250_DISABLE_PV4)
# error Unsupported configuration. Do not disable both PV1 and PV4.
#endif
#ifdef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (ret == ALTMDM_RETURN_RESET_V1)
{
bool is_discard = false;
m_err("Unsupported ALTCOM Version: V1\n");
reason = LTE_RESTART_VERSION_ERROR;
}
#endif
/* parse ALTCOM command ID and transaction ID from header */
#ifdef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (ret == ALTMDM_RETURN_RESET_V4)
{
m_err("Unsupported ALTCOM Version: V4\n");
reason = LTE_RESTART_VERSION_ERROR;
}
#endif
cid = parse_cid((FAR struct altcom_cmdhdr_s *)g_recvbuff);
tid = parse_tid((FAR struct altcom_cmdhdr_s *)g_recvbuff);
altver = get_altver(
(FAR struct altcom_cmdhdr_s *)g_recvbuff);
ret = write_evtbuff_byidx(dev, 0, write_restart_param,
(FAR void *)&reason);
m_info("receive cid:0x%04x tid:0x%04x\n", cid, tid);
/* If there is a waiting list,
* replace it with the replay list.
*/
/* Is error indication packet?
* This packet is a response to a command that is not supported
* by the ALT1250. The header of the request packet is included
* in the contents of the this packet.
head = remove_list_all(&dev->waitlist);
pollnotify(dev, ALT1250_EVTBIT_RESET, head);
}
else if (ret == ALTMDM_RETURN_SUSPENDED)
{
m_info("recieve ALTMDM_RETURN_SUSPENDED\n");
nxsem_post(&dev->rxthread_sem);
while (1)
{
/* After receiving a suspend event, the ALT1250 driver
* does not accept any requests and must stay alive.
*/
if (is_errind(cid))
{
/* Get ALTCOM command ID and transaction ID
* from error indication packet
*/
cid = parse_cid4errind(
(FAR struct altcom_cmdhdr_s *)g_recvbuff);
tid = parse_tid4errind(
(FAR struct altcom_cmdhdr_s *)g_recvbuff);
m_info("receive errind cid:0x%04x tid:0x%04x\n", cid, tid);
container = remove_list(&dev->waitlist, cid, tid);
if (container != NULL)
{
/* It means that requested command not implemented
* by modem
*/
container->result = -ENOSYS;
}
else
{
/* Discard the event packet */
is_discard = true;
m_warn("container is not found\n");
}
}
else
{
container = remove_list(&dev->waitlist, cid, tid);
handler = get_parsehdlr(cid, altver);
if (handler)
{
FAR uint8_t *payload = get_payload(
(FAR struct altcom_cmdhdr_s *)g_recvbuff);
if (container)
{
m_info("handler and container is found\n");
bitmap = get_bitmap(dev, cid, altver);
/* Perform parse handler */
container->result = handler(dev, payload,
get_payload_len(
(FAR struct altcom_cmdhdr_s *)g_recvbuff),
altver, container->outparam,
container->outparamlen, &bitmap);
}
else
{
FAR alt_evtbuf_inst_t *inst;
m_warn("container is not found\n");
/* If the state of the instance is NotWritable,
* instanse will be returned as NULL.
*/
inst = get_evtbuffinst_withlock(dev, cid, altver,
&bitmap);
if (inst)
{
/* Perform parse handler */
ret = handler(dev, payload, get_payload_len(
(FAR struct altcom_cmdhdr_s *)g_recvbuff),
altver, inst->outparam, inst->outparamlen,
&bitmap);
unlock_evtbufinst(inst, dev);
if (ret >= 0)
{
write_evtbitmap(dev, bitmap);
}
else
{
/* Discard the event packet */
is_discard = true;
}
}
else
{
/* Discard the event packet */
is_discard = true;
}
}
}
else if (container)
{
container->result = -ENOSYS;
m_warn("handler is not found\n");
}
else
{
/* Discard the event packet */
is_discard = true;
m_warn("container and handler is not found\n");
}
}
if (container)
{
if (container->cmdid & LTE_CMDOPT_ASYNC_BIT)
{
bitmap |= ALT1250_EVTBIT_REPLY;
}
else
{
bitmap = ALT1250_EVTBIT_REPLY;
}
write_evtbitmapwithlist(dev, bitmap, container);
}
if (is_discard)
{
dev->discardcnt++;
m_err("discard event %lu\n", dev->discardcnt);
}
else
{
pollnotify(dev);
}
sleep(1);
}
}
else if (ret == ALTMDM_RETURN_EXIT)
{
m_info("recieve ALTMDM_RETURN_EXIT\n");
is_running = false;
}
else
{
switch (ret)
{
case ALTMDM_RETURN_RESET_PKT:
{
m_info("recieve ALTMDM_RETURN_RESET_PKT\n");
set_senddisable(dev, true);
}
break;
case ALTMDM_RETURN_RESET_V1:
case ALTMDM_RETURN_RESET_V4:
{
uint32_t reason = altmdm_get_reset_reason();
m_info("recieve ALTMDM_RETURN_RESET_V1/V4\n");
ret = write_evtbuff_byidx(dev, 0, write_restart_param,
(FAR void *)&reason);
/* If there is a waiting list,
* replace it with the replay list.
*/
head = remove_list_all(&dev->waitlist);
write_evtbitmapwithlist(dev, ALT1250_EVTBIT_RESET, head);
pollnotify(dev);
}
break;
case ALTMDM_RETURN_EXIT:
{
m_info("recieve ALTMDM_RETURN_EXIT\n");
is_running = false;
}
break;
default:
DEBUGASSERT(0);
break;
}
DEBUGASSERT(0);
}
recvedlen = 0;
}
nxsem_post(&dev->rxthread_sem);
m_info("recv thread end\n");
pthread_exit(0);
return 0;
}
/****************************************************************************
* Name: alt1250_start_rxthread
****************************************************************************/
static int alt1250_start_rxthread(FAR struct alt1250_dev_s *dev,
bool senddisable)
{
int ret = OK;
nxmutex_init(&dev->waitlist.lock);
nxmutex_init(&dev->replylist.lock);
nxmutex_init(&dev->evtmaplock);
nxmutex_init(&dev->pfdlock);
nxmutex_init(&dev->senddisablelock);
nxmutex_init(&dev->select_inst.stat_lock);
sq_init(&dev->waitlist.queue);
sq_init(&dev->replylist.queue);
dev->senddisable = senddisable;
ret = kthread_create("altcom_recvthread",
SCHED_PRIORITY_DEFAULT,
CONFIG_DEFAULT_TASK_STACKSIZE,
altcom_recvthread,
(FAR char * const *)NULL);
if (ret < 0)
{
m_err("kthread create failed: %d\n", errno);
nxmutex_destroy(&dev->waitlist.lock);
nxmutex_destroy(&dev->replylist.lock);
nxmutex_destroy(&dev->evtmaplock);
nxmutex_destroy(&dev->pfdlock);
nxmutex_destroy(&dev->senddisablelock);
nxmutex_destroy(&dev->select_inst.stat_lock);
}
return ret;
}
/****************************************************************************
@ -1017,7 +1137,8 @@ static int alt1250_open(FAR struct file *filep)
if (dev->crefs > 0)
{
ret = -EPERM;
nxmutex_unlock(&dev->refslock);
return -EPERM;
}
/* Increment the count of open references on the driver */
@ -1026,43 +1147,17 @@ static int alt1250_open(FAR struct file *filep)
nxmutex_unlock(&dev->refslock);
if (ret == OK)
if (dev->rxthread_pid < 0)
{
nxmutex_init(&dev->waitlist.lock);
nxmutex_init(&dev->replylist.lock);
nxmutex_init(&dev->evtmaplock);
nxmutex_init(&dev->pfdlock);
nxmutex_init(&dev->senddisablelock);
nxmutex_init(&dev->select_inst.stat_lock);
dev->rxthread_pid = alt1250_start_rxthread(dev, true);
}
sq_init(&dev->waitlist.queue);
sq_init(&dev->replylist.queue);
dev->senddisable = true;
ret = pthread_create(&dev->recvthread, NULL,
(pthread_startroutine_t)altcom_recvthread,
(pthread_addr_t)dev);
if (ret < 0)
{
m_err("thread create failed: %d\n", errno);
ret = -errno;
nxmutex_destroy(&dev->waitlist.lock);
nxmutex_destroy(&dev->replylist.lock);
nxmutex_destroy(&dev->evtmaplock);
nxmutex_destroy(&dev->pfdlock);
nxmutex_destroy(&dev->senddisablelock);
nxmutex_destroy(&dev->select_inst.stat_lock);
nxmutex_lock(&dev->refslock);
dev->crefs--;
nxmutex_unlock(&dev->refslock);
}
else
{
pthread_setname_np(dev->recvthread, "altcom_recvthread");
}
if (dev->rxthread_pid < 0)
{
ret = dev->rxthread_pid;
nxmutex_lock(&dev->refslock);
dev->crefs--;
nxmutex_unlock(&dev->refslock);
}
return ret;
@ -1076,7 +1171,6 @@ static int alt1250_close(FAR struct file *filep)
{
FAR struct inode *inode;
FAR struct alt1250_dev_s *dev;
int ret = OK;
/* Get our private data structure */
@ -1090,31 +1184,28 @@ static int alt1250_close(FAR struct file *filep)
if (dev->crefs == 0)
{
ret = -EPERM;
nxmutex_unlock(&dev->refslock);
return -EPERM;
}
else
{
/* Decrement the count of open references on the driver */
dev->crefs--;
}
/* Decrement the count of open references on the driver */
dev->crefs--;
nxmutex_unlock(&dev->refslock);
if (ret == OK)
{
nxmutex_destroy(&dev->waitlist.lock);
nxmutex_destroy(&dev->replylist.lock);
nxmutex_destroy(&dev->evtmaplock);
nxmutex_destroy(&dev->pfdlock);
nxmutex_destroy(&dev->senddisablelock);
nxmutex_destroy(&dev->select_inst.stat_lock);
nxmutex_destroy(&dev->waitlist.lock);
nxmutex_destroy(&dev->replylist.lock);
nxmutex_destroy(&dev->evtmaplock);
nxmutex_destroy(&dev->pfdlock);
nxmutex_destroy(&dev->senddisablelock);
nxmutex_destroy(&dev->select_inst.stat_lock);
altmdm_fin();
pthread_join(dev->recvthread, NULL);
}
altmdm_fin();
dev->rxthread_pid = -1;
nxsem_wait_uninterruptible(&dev->rxthread_sem);
return ret;
return OK;
}
/****************************************************************************
@ -1262,6 +1353,91 @@ errout:
return ret;
}
#ifdef CONFIG_PM
/****************************************************************************
* Name: alt1250_pm_prepare
****************************************************************************/
static int alt1250_pm_prepare(struct pm_callback_s *cb, int domain,
enum pm_state_e pmstate)
{
int ret = OK;
bool power = false;
/* ALT1250's power management only support BOARD_PM_APPS */
if (domain != BOARD_PM_APPS)
{
return OK;
}
if (pmstate == PM_SLEEP)
{
power = altmdm_get_powersupply(g_alt1250_dev->lower);
if (!power)
{
/* If the modem doesn't turned on, system can enter sleep */
return OK;
}
ret = alt1250_send_daemon_request(ALT1250_EVTBIT_STOPAPI);
if (ret)
{
return ERROR;
}
else
{
return OK;
}
}
return ret;
}
/****************************************************************************
* Name: alt1250_pm_notify
****************************************************************************/
static void alt1250_pm_notify(struct pm_callback_s *cb, int domain,
enum pm_state_e pmstate)
{
bool power;
/* ALT1250's power management only supports BOARD_PM_APPS */
if ((domain == BOARD_PM_APPS) && (pmstate == PM_SLEEP))
{
power = altmdm_get_powersupply(g_alt1250_dev->lower);
if (power)
{
/* Set retry mode for SPI driver */
altmdm_set_pm_event(EVENT_RETRYREQ, true);
/* Send suspend request to daemon */
alt1250_send_daemon_request(ALT1250_EVTBIT_SUSPEND);
/* Set suspend mode for SPI driver */
altmdm_set_pm_event(EVENT_SUSPEND, true);
/* Waiting for entering sleep state */
nxsem_wait_uninterruptible(&g_alt1250_dev->rxthread_sem);
/* Enable LTE hibernation mode for wakeup from LTE */
g_alt1250_dev->lower->hiber_mode(true);
}
}
}
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
@ -1288,6 +1464,23 @@ FAR void *alt1250_register(FAR const char *devpath,
nxmutex_init(&priv->refslock);
nxsem_init(&priv->rxthread_sem, 0, 0);
g_alt1250_dev = priv;
#ifdef CONFIG_PM
ret = pm_register(&g_alt1250pmcb);
if (ret != OK)
{
m_err("Failed to register PM: %d\n", ret);
kmm_free(priv);
return NULL;
}
nxsem_init(&g_alt1250_res_s.sem, 0, 0);
#endif
ret = register_driver(devpath, &g_alt1250fops, 0666, priv);
if (ret < 0)
{
@ -1296,7 +1489,16 @@ FAR void *alt1250_register(FAR const char *devpath,
return NULL;
}
return priv;
priv->rxthread_pid = -1;
#ifdef CONFIG_PM
if (altmdm_get_powersupply(priv->lower))
{
priv->rxthread_pid = alt1250_start_rxthread(priv, false);
}
#endif
return (FAR void *)priv;
}
uint64_t get_event_lapibuffer(FAR struct alt1250_dev_s *dev,

View file

@ -30,43 +30,23 @@
#include <stdbool.h>
#include <stdint.h>
#include <nuttx/wireless/lte/lte.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define APICMD_ACTIVATEPDN_APNNAME_MAXLEN (101)
#define APICMD_ACTIVATEPDN_USERNAME_MAXLEN (64)
#define APICMD_ACTIVATEPDN_PASSWORD_MAXLEN (32)
#define APICMD_CELLINFO_CELLID_MIN (0)
#define APICMD_CELLINFO_CELLID_MAX (503)
#define APICMD_CELLINFO_EARFCN_MIN (0)
#define APICMD_CELLINFO_EARFCN_MAX (262143)
#define APICMD_CELLINFO_DIGIT_NUM_MIN (0)
#define APICMD_CELLINFO_DIGIT_NUM_MAX (9)
#define APICMD_CELLINFO_MCC_DIGIT (3)
#define APICMD_CELLINFO_MNC_DIGIT_MIN (2)
#define APICMD_CELLINFO_MNC_DIGIT_MAX (3)
#define APICMD_CELLINFO_GCID_MAX (16)
#define APICMD_CELLINFO_TIMEDIFF_INDEX_MAX (4095)
#define APICMD_CELLINFO_TA_MAX (1282)
#define APICMD_CELLINFO_SFN_MAX (0x03FF)
#define APICMD_CELLINFO_NEIGHBOR_CELL_NUM_MAX (32)
#define APICMD_CELLINFO_VALID_TIMEDIFFIDX (1 << 1)
#define APICMD_CELLINFO_VALID_TA (1 << 2)
#define APICMD_CELLINFO_VALID_SFN (1 << 3)
#define APICMD_CELLINFO_VALID_RSRP (1 << 4)
#define APICMD_CELLINFO_VALID_RSRQ (1 << 5)
#define APICMD_DATAALLOW_DATAALLOW_ALLOW (0)
#define APICMD_DATAALLOW_DATAALLOW_DISALLOW (1)
#define APICMD_DATAALLOW_DATAROAMALLOW_ALLOW (0)
#define APICMD_DATAALLOW_DATAROAMALLOW_DISALLOW (1)
#define APICMD_DEACTIVATEPDN_SESSIONID_MIN (0)
#define APICMD_DEACTIVATEPDN_SESSIONID_MAX (255)
#define APICMD_CELLINFO_CELLID_MAX (503)
#define APICMD_CELLINFO_EARFCN_MAX (262143)
#define APICMD_CELLINFO_DIGIT_NUM_MIN (0)
#define APICMD_CELLINFO_DIGIT_NUM_MAX (9)
#define APICMD_CELLINFO_MNC_DIGIT_MIN (2)
#define APICMD_CELLINFO_GCID_MAX (16)
#define APICMD_CELLINFO_VALID_TIMEDIFFIDX (1 << 1)
#define APICMD_CELLINFO_VALID_TA (1 << 2)
#define APICMD_CELLINFO_VALID_SFN (1 << 3)
#define APICMD_CELLINFO_VALID_RSRP (1 << 4)
#define APICMD_CELLINFO_VALID_RSRQ (1 << 5)
#define APICMD_EDRX_ACTTYPE_NOTUSE (0) /* eDRX is not running */
#define APICMD_EDRX_ACTTYPE_ECGSMIOT (1) /* EC-GSM-IoT (A/Gb mode) */
@ -81,157 +61,63 @@
#define APICMD_ERRINFO_ERRSTR_MAX_LEN (64)
#define APICMD_IMSCAP_ENABLE (0)
#define APICMD_IMSCAP_DISABLE (1)
#define APICMD_GETSIMINFO_MCC_DIXIT_MAX (3)
#define APICMD_GETSIMINFO_MNC_DIXIT_MAX (3)
#define APICMD_GETSIMINFO_SPN_MAX_LEN (16)
#define APICMD_GETSIMINFO_ICCID_MAX_LEN (10)
#define APICMD_GETSIMINFO_IMSI_LEN (15)
#define APICMD_GETSIMINFO_GID_LEN (128)
#define APICMD_IMEI_LEN 16
#define APICMD_IMSI_LEN 16
#define APICMD_IMSCAP_ENABLE (0)
#define APICMD_IMSCAP_DISABLE (1)
#define APICMD_NETINFO_PDNCOUNT_MAX (5)
#define APICMD_OPERATOR_LEN 17
#define APICMD_OPERATOR_LEN_V4 33
#define APICMD_OPERATOR_LEN_V4 33
#define APICMD_PDN_IMS_REG (0)
#define APICMD_PDN_IMS_UNREG (1)
#define APICMD_PDN_IMS_REG (0)
#define APICMD_PDN_IMS_UNREG (1)
#define APICMD_PDN_DATAALLOW_ALLOW (0)
#define APICMD_PDN_DATAALLOW_DISALLOW (1)
#define APICMD_PDN_DATAALLOW_ALLOW (0)
#define APICMD_PDN_DATAALLOW_DISALLOW (1)
#define APICMD_PDN_DATAROAMALLOW_ALLOW (0)
#define APICMD_PDN_DATAROAMALLOW_DISALLOW (1)
#define APICMD_PDN_DATAROAMALLOW_ALLOW (0)
#define APICMD_PDN_DATAROAMALLOW_DISALLOW (1)
#define APICMD_PDN_IPCOUNT_MAX (2)
#define APICMD_PDN_IPADDR_MAXLEN (40)
#define APICMD_PDN_DNSCOUNT_MAX (4)
#define APICMD_PDN_DNSCOUNT_MAX (4)
#define APICMD_QUALITY_DISABLE (0)
#define APICMD_QUALITY_ENABLE (1)
#define APICMD_QUALITY_RSRP_MIN (-140)
#define APICMD_QUALITY_RSRP_MAX (0)
#define APICMD_QUALITY_RSRQ_MIN (-60)
#define APICMD_QUALITY_RSRQ_MAX (0)
#define APICMD_QUALITY_SINR_MIN (-128)
#define APICMD_QUALITY_SINR_MAX (40)
#define APICMD_PHONENO_LEN 41
#define APICMD_SET_REP_EVT_DISABLE (0)
#define APICMD_SET_REP_EVT_ENABLE (1)
#define APICMD_PSM_TIMER_MIN (1)
#define APICMD_PSM_TIMER_MAX (31)
#define APICMD_SET_REP_EVT_LTIME (1 << 0)
#define APICMD_SET_REP_EVT_SIMD (1 << 1)
#define APICMD_SET_REP_EVT_SIMSTATE (1 << 2)
#define APICMD_QUALITY_DISABLE (0)
#define APICMD_QUALITY_ENABLE (1)
#define APICMD_QUALITY_RSRP_MIN (-140)
#define APICMD_QUALITY_RSRP_MAX (0)
#define APICMD_QUALITY_RSRQ_MIN (-60)
#define APICMD_QUALITY_RSRQ_MAX (0)
#define APICMD_QUALITY_SINR_MIN (-128)
#define APICMD_QUALITY_SINR_MAX (40)
#define APICMD_SET_REP_EVT_RES_OK (0)
#define APICMD_SET_REP_EVT_RES_ERR (1)
#define APICMD_RAT_RES_OK (0)
#define APICMD_RAT_RES_ERR (1)
#define APICMD_RAT_RAT_DEFAULT (1)
#define APICMD_RAT_RAT_CATM (2)
#define APICMD_RAT_RAT_NBIOT (3)
#define APICMD_RAT_RAT_GSM (4)
#define APICMD_RAT_RAT_C2D (5)
#define APICMD_RAT_RAT_N2D (6)
#define APICMD_RAT_RAT_G2D (7)
#define APICMD_RAT_NOT_PERSIS (0)
#define APICMD_RAT_PERSIS (1)
#define APICMD_RAT_RAT_MODE_SINGLE (0)
#define APICMD_RAT_RAT_MODE_MULTIPLE (1)
#define APICMD_RAT_SOURCE_NONE (0)
#define APICMD_RAT_SOURCE_HOST (1)
#define APICMD_RAT_SOURCE_LWM2M (2)
#define APICMD_REPORT_EVT_TYPE_LTIME (0)
#define APICMD_REPORT_EVT_TYPE_SIMD (1)
#define APICMD_REPORT_EVT_TYPE_SIMSTATE (2)
#define APICMD_SET_REPCELLINFO_INTERVAL_MIN (1)
#define APICMD_SET_REPCELLINFO_INTERVAL_MAX (4233600)
#define APICMD_SET_REP_EVT_DISABLE (0)
#define APICMD_SET_REP_EVT_ENABLE (1)
#define APICMD_SET_REP_EVT_LTIME (1 << 0)
#define APICMD_SET_REP_EVT_SIMD (1 << 1)
#define APICMD_SET_REP_EVT_SIMSTATE (1 << 2)
#define APICMD_SET_REP_EVT_REGSTATE (1 << 3)
#define APICMD_SET_REP_EVT_PSMSTATE (1 << 4)
#define APICMD_SET_REP_EVT_DYNPSM (1 << 5)
#define APICMD_SET_REP_EVT_DYNEDRX (1 << 6)
#define APICMD_SET_REP_EVT_CONNPHASE (1 << 7)
#define APICMD_SET_REP_EVT_ANTITAMPER (1 << 8)
#define APICMD_SET_REP_EVT_MAX (1 << 15)
#define APICMD_SET_REP_EVT_RES_OK (0)
#define APICMD_SET_REP_EVT_RES_ERR (1)
#define APICMD_REPORT_EVT_TYPE_LTIME (0)
#define APICMD_REPORT_EVT_TYPE_SIMD (1)
#define APICMD_REPORT_EVT_TYPE_SIMSTATE (2)
#define APICMD_REPORT_EVT_TYPE_REGSTATE (3)
#define APICMD_REPORT_EVT_TYPE_PSMSTATE (4)
#define APICMD_REPORT_EVT_TYPE_DYNPSM (5)
#define APICMD_REPORT_EVT_TYPE_DYNEDRX (6)
#define APICMD_REPORT_EVT_TYPE_CONNPHASE (7)
#define APICMD_REPORT_EVT_TYPE_ANTITAMPER (8)
#define APICMD_REPORT_EVT_SIMD_REMOVAL (0)
#define APICMD_REPORT_EVT_SIMD_INSERTION (1)
#define APICMD_REPORT_EVT_SIMD_REMOVAL (0)
#define APICMD_REPORT_EVT_SIMD_INSERTION (1)
#define APICMD_REPORT_EVT_SIMSTATE_DEACTIVATED (0)
#define APICMD_REPORT_EVT_SIMSTATE_SIM_INIT_WAIT_PIN_UNLOCK (1)
#define APICMD_REPORT_EVT_SIMSTATE_PERSONALIZATION_FAILED (2)
#define APICMD_REPORT_EVT_SIMSTATE_ACTIVATION_COMPLETED (3)
#define APICMD_REPORT_EVT_ALERTU_TEMP (0)
#define APICMD_REPORT_EVT_ALERTU_ANTIAMPER (1)
#define APICMD_REP_PSMST_NOT_ACTIVE (0)
#define APICMD_REP_PSMST_ACTIVE (1)
#define APICMD_REP_PSMST_ACTIVE_AND_CAMPED (2)
#define APICMD_REP_PSMST_CAMP_INTERRUPTED (3)
#define APICMD_REP_CONNPHASE_START_SCAN (0)
#define APICMD_REP_CONNPHASE_FAIL_SCAN (1)
#define APICMD_REP_CONNPHASE_ENTER_CAMPED (2)
#define APICMD_REP_CONNPHASE_CONNECTION_ESTABLISHMENT (3)
#define APICMD_REP_CONNPHASE_START_RESCAN (4)
#define APICMD_REP_CONNPHASE_ENTER_CONNECTED (5)
#define APICMD_REP_CONNPHASE_NO_SUITABLE_CELL (6)
#define APICMD_REP_CONNPHASE_REG_ATTEMPT_FAILED (7)
#define APICMD_REP_CONNPHASE_NOT_AVAIL (99)
#define APICMD_REP_CONPHASE_RAT_CATM (0)
#define APICMD_REP_CONPHASE_RAT_NBIOT (1)
#define APICMD_REP_CONPHASE_RAT_GSM (3)
#define APICMD_REP_CONPHASE_RAT_NOT_AVAIL (99)
#define APICMD_REP_CONPHASE_SCAN_MRU_ONLY (0)
#define APICMD_REP_CONPHASE_SCAN_MRU_AND_FULL_SCAN (1)
#define APICMD_REP_CONPHASE_SCAN_MRU_AND_COUNTRY_SCAN (2)
#define APICMD_REP_CONPHASE_SCAN_MRU_AND_LS (3)
#define APICMD_REP_CONPHASE_SCAN_MRU_NOT_AVAIL (99)
#define APICMD_REP_CONPHASE_SCAN_REASON_INIT_SCAN (0)
#define APICMD_REP_CONPHASE_SCAN_REASON_OUT_OF_COVERAGE (1)
#define APICMD_REP_CONPHASE_SCAN_REASON_HIGH_PRIORITY (2)
#define APICMD_REP_CONPHASE_SCAN_REASON_LIMITED_SERVICE (3)
#define APICMD_REP_CONPHASE_SCAN_REASON_COPS (4)
#define APICMD_REP_CONPHASE_SCAN_REASON_OTHER (5)
#define APICMD_REP_CONPHASE_SCAN_REASON_NOT_AVAIL (99)
#define APICMD_REPNETINFO_RES_OK (0)
#define APICMD_REPNETINFO_RES_ERR (1)
#define APICMD_REPNETINFO_REPORT_ENABLE (0)
#define APICMD_REPNETINFO_REPORT_DISABLE (1)
#define APICMD_REPNETINFO_NWSTAT_ATCH (0)
#define APICMD_REPNETINFO_NWSTAT_DTCH (1)
#define APICMD_SET_REPQUALITY_DISABLE (0)
#define APICMD_SET_REPQUALITY_ENABLE (1)
#define APICMD_SET_REPQUALITY_INTERVAL_MIN (1)
#define APICMD_SET_REPQUALITY_INTERVAL_MAX (4233600)
#define APICMD_SETPINCODE_PINCODE_LEN 9
@ -240,9 +126,6 @@
#define APICMD_SETPINLOCK_PINCODE_LEN 9
#define APICMD_VERSION_RES_BB_PRODUCT_LEN 5
#define APICMD_VERSION_RES_NP_PACKAGE_LEN 32
#define APICMD_FW_INJECTDATA_MAXLEN (4096)
#define APICMD_FW_INJECTDATA_MAXLEN_V4 (3000)
@ -258,7 +141,7 @@
begin_packed_struct struct apicmd_ipaddr_s
{
uint8_t iptype;
uint8_t address[APICMD_PDN_IPADDR_MAXLEN];
uint8_t address[LTE_IPADDR_MAX_LEN];
} end_packed_struct;
begin_packed_struct struct apicmd_pdnset_s
@ -268,7 +151,7 @@ begin_packed_struct struct apicmd_pdnset_s
uint32_t apntype;
uint8_t ipaddr_num;
struct apicmd_ipaddr_s
ip_address[APICMD_PDN_IPCOUNT_MAX];
ip_address[LTE_PDN_IPADDR_MAX_COUNT];
uint8_t imsregister;
uint8_t dataallow;
uint8_t dararoamingallow;
@ -281,7 +164,7 @@ begin_packed_struct struct apicmd_pdnset_v4_s
uint32_t apntype;
uint8_t ipaddr_num;
struct apicmd_ipaddr_s
ip_address[APICMD_PDN_IPCOUNT_MAX];
ip_address[LTE_PDN_IPADDR_MAX_COUNT];
uint8_t imsregister;
uint8_t dataallow;
uint8_t dararoamingallow;
@ -375,10 +258,10 @@ begin_packed_struct struct apicmd_cmddat_activatepdn_s
{
uint32_t apntype;
uint8_t iptype;
uint8_t apnname[APICMD_ACTIVATEPDN_APNNAME_MAXLEN];
uint8_t apnname[LTE_APN_LEN];
uint8_t authtype;
uint8_t username[APICMD_ACTIVATEPDN_USERNAME_MAXLEN];
uint8_t password[APICMD_ACTIVATEPDN_PASSWORD_MAXLEN];
uint8_t username[LTE_APN_USER_NAME_LEN];
uint8_t password[LTE_APN_PASSWD_LEN];
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_activatepdnres_s
@ -407,9 +290,9 @@ begin_packed_struct struct apicmd_cmddat_cellinfo_s
uint8_t valid;
uint32_t cell_id;
uint32_t earfcn;
uint8_t mcc[APICMD_CELLINFO_MCC_DIGIT];
uint8_t mcc[LTE_MCC_DIGIT];
uint8_t mnc_digit;
uint8_t mnc[APICMD_CELLINFO_MNC_DIGIT_MAX];
uint8_t mnc[LTE_MNC_DIGIT_MAX];
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_cellinfo_v4_s
@ -417,9 +300,9 @@ begin_packed_struct struct apicmd_cmddat_cellinfo_v4_s
uint8_t enability;
uint32_t cell_id;
uint32_t earfcn;
uint8_t mcc[APICMD_CELLINFO_MCC_DIGIT];
uint8_t mcc[LTE_MCC_DIGIT];
uint8_t mnc_digit;
uint8_t mnc[APICMD_CELLINFO_MNC_DIGIT_MAX];
uint8_t mnc[LTE_MNC_DIGIT_MAX];
uint8_t cgid[APICMD_CELLINFO_GCID_MAX + 1];
uint16_t tac;
uint16_t time_diffidx;
@ -429,7 +312,7 @@ begin_packed_struct struct apicmd_cmddat_cellinfo_v4_s
int16_t rsrq;
uint8_t neighbor_num;
struct apicmd_cmddat_neighbor_cell_s
neighbor_cell[APICMD_CELLINFO_NEIGHBOR_CELL_NUM_MAX];
neighbor_cell[LTE_NEIGHBOR_CELL_MAX];
} end_packed_struct;
/* structure for APICMDID_DATA_ALLOW */
@ -602,19 +485,19 @@ begin_packed_struct struct apicmd_cmddat_getsiminfo_res_s
{
uint8_t result;
uint32_t option;
uint8_t mcc[APICMD_GETSIMINFO_MCC_DIXIT_MAX];
uint8_t mcc[LTE_MCC_DIGIT];
uint8_t mnc_digit;
uint8_t mnc[APICMD_GETSIMINFO_MNC_DIXIT_MAX];
uint8_t mnc[LTE_MNC_DIGIT_MAX];
uint8_t spn_len;
uint8_t spn[APICMD_GETSIMINFO_SPN_MAX_LEN];
uint8_t spn[LTE_SIMINFO_SPN_LEN];
uint8_t iccid_len;
uint8_t iccid[APICMD_GETSIMINFO_ICCID_MAX_LEN];
uint8_t iccid[LTE_SIMINFO_ICCID_LEN];
uint8_t imsi_len;
uint8_t imsi[APICMD_GETSIMINFO_IMSI_LEN];
uint8_t imsi[LTE_SIMINFO_IMSI_LEN];
uint8_t gid1_len;
uint8_t gid1[APICMD_GETSIMINFO_GID_LEN];
uint8_t gid1[LTE_SIMINFO_GID_LEN];
uint8_t gid2_len;
uint8_t gid2[APICMD_GETSIMINFO_GID_LEN];
uint8_t gid2[LTE_SIMINFO_GID_LEN];
} end_packed_struct;
/* structure for APICMDID_GET_IMEI */
@ -622,7 +505,7 @@ begin_packed_struct struct apicmd_cmddat_getsiminfo_res_s
begin_packed_struct struct apicmd_cmddat_getimeires_s
{
uint8_t result;
uint8_t imei[APICMD_IMEI_LEN];
uint8_t imei[LTE_IMEI_LEN];
} end_packed_struct;
/* structure for APICMDID_GET_IMSI */
@ -631,7 +514,7 @@ begin_packed_struct struct apicmd_cmddat_getimsires_s
{
uint8_t result;
uint8_t errcause;
uint8_t imsi[APICMD_IMSI_LEN];
uint8_t imsi[LTE_IMSI_LEN];
} end_packed_struct;
/* structure for APICMDID_GET_LTIME */
@ -647,7 +530,7 @@ begin_packed_struct struct apicmd_cmddat_getltimeres_s
begin_packed_struct struct apicmd_cmddat_getoperatorres_s
{
uint8_t result;
uint8_t oper[APICMD_OPERATOR_LEN];
uint8_t oper[LTE_OPERATOR_LEN];
} end_packed_struct;
begin_packed_struct struct apicmd_cmddat_getoperatorres_v4_s
@ -662,7 +545,7 @@ begin_packed_struct struct apicmd_cmddat_phonenores_s
{
uint8_t result;
uint8_t errcause;
uint8_t phoneno[APICMD_PHONENO_LEN];
uint8_t phoneno[LTE_PHONENO_LEN];
} end_packed_struct;
/* structure for APICMDID_RADIO_OFF */
@ -928,8 +811,8 @@ begin_packed_struct struct apicmd_cmddat_setpsmres_s
begin_packed_struct struct apicmd_cmddat_getverres_s
{
uint8_t result;
uint8_t bb_product[APICMD_VERSION_RES_BB_PRODUCT_LEN];
uint8_t np_package[APICMD_VERSION_RES_NP_PACKAGE_LEN];
uint8_t bb_product[LTE_VER_BB_PRODUCT_LEN];
uint8_t np_package[LTE_VER_NP_PACKAGE_LEN];
} end_packed_struct;
/* structure for APICMDID_FW_INJECTDELTAIMG */

View file

@ -0,0 +1,217 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_errno.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 <arpa/inet.h>
#include "altcom_errno.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef ARRAY_SZ
# define ARRAY_SZ(array) (sizeof(array)/sizeof(array[0]))
#endif
#define TABLE_CONTENT(errno_name) { ALTCOM_##errno_name, errno_name }
/****************************************************************************
* Private Types
****************************************************************************/
struct converrno_s
{
int altcom_errno;
int nuttx_errno;
};
/****************************************************************************
* Private Data
****************************************************************************/
static const struct converrno_s g_converrno_tbl[] =
{
TABLE_CONTENT(E2BIG),
TABLE_CONTENT(EACCES),
TABLE_CONTENT(EADDRINUSE),
TABLE_CONTENT(EADDRNOTAVAIL),
TABLE_CONTENT(EADV),
TABLE_CONTENT(EAFNOSUPPORT),
TABLE_CONTENT(EAGAIN),
TABLE_CONTENT(EALREADY),
TABLE_CONTENT(EBADE),
TABLE_CONTENT(EBADF),
TABLE_CONTENT(EBADFD),
TABLE_CONTENT(EBADMSG),
TABLE_CONTENT(EBADR),
TABLE_CONTENT(EBADRQC),
TABLE_CONTENT(EBADSLT),
TABLE_CONTENT(EBFONT),
TABLE_CONTENT(EBUSY),
TABLE_CONTENT(ECANCELED),
TABLE_CONTENT(ECASECLASH),
TABLE_CONTENT(ECHILD),
TABLE_CONTENT(ECHRNG),
TABLE_CONTENT(ECOMM),
TABLE_CONTENT(ECONNABORTED),
TABLE_CONTENT(ECONNREFUSED),
TABLE_CONTENT(ECONNRESET),
TABLE_CONTENT(EDEADLK),
TABLE_CONTENT(EDEADLOCK),
TABLE_CONTENT(EDESTADDRREQ),
TABLE_CONTENT(EDOM),
TABLE_CONTENT(EDOTDOT),
TABLE_CONTENT(EDQUOT),
TABLE_CONTENT(EEXIST),
TABLE_CONTENT(EFAULT),
TABLE_CONTENT(EFBIG),
TABLE_CONTENT(EFTYPE),
TABLE_CONTENT(EHOSTDOWN),
TABLE_CONTENT(EHOSTUNREACH),
TABLE_CONTENT(EIDRM),
TABLE_CONTENT(EILSEQ),
TABLE_CONTENT(EINPROGRESS),
TABLE_CONTENT(EINTR),
TABLE_CONTENT(EINVAL),
TABLE_CONTENT(EIO),
TABLE_CONTENT(EISCONN),
TABLE_CONTENT(EISDIR),
TABLE_CONTENT(EL2HLT),
TABLE_CONTENT(EL2NSYNC),
TABLE_CONTENT(EL3HLT),
TABLE_CONTENT(EL3RST),
TABLE_CONTENT(ELBIN),
TABLE_CONTENT(ELIBACC),
TABLE_CONTENT(ELIBBAD),
TABLE_CONTENT(ELIBEXEC),
TABLE_CONTENT(ELIBMAX),
TABLE_CONTENT(ELIBSCN),
TABLE_CONTENT(ELNRNG),
TABLE_CONTENT(ELOOP),
TABLE_CONTENT(EMFILE),
TABLE_CONTENT(EMLINK),
TABLE_CONTENT(EMSGSIZE),
TABLE_CONTENT(EMULTIHOP),
TABLE_CONTENT(ENAMETOOLONG),
TABLE_CONTENT(ENETDOWN),
TABLE_CONTENT(ENETRESET),
TABLE_CONTENT(ENETUNREACH),
TABLE_CONTENT(ENFILE),
TABLE_CONTENT(ENMFILE),
TABLE_CONTENT(ENOANO),
TABLE_CONTENT(ENOBUFS),
TABLE_CONTENT(ENOCSI),
TABLE_CONTENT(ENODATA),
TABLE_CONTENT(ENODEV),
TABLE_CONTENT(ENOENT),
TABLE_CONTENT(ENOEXEC),
TABLE_CONTENT(ENOLCK),
TABLE_CONTENT(ENOLINK),
TABLE_CONTENT(ENOMEDIUM),
TABLE_CONTENT(ENOMEM),
TABLE_CONTENT(ENOMSG),
TABLE_CONTENT(ENONET),
TABLE_CONTENT(ENOPKG),
TABLE_CONTENT(ENOPROTOOPT),
TABLE_CONTENT(ENOSHARE),
TABLE_CONTENT(ENOSPC),
TABLE_CONTENT(ENOSR),
TABLE_CONTENT(ENOSTR),
TABLE_CONTENT(ENOSYS),
TABLE_CONTENT(ENOTBLK),
TABLE_CONTENT(ENOTCONN),
TABLE_CONTENT(ENOTDIR),
TABLE_CONTENT(ENOTEMPTY),
TABLE_CONTENT(ENOTRECOVERABLE),
TABLE_CONTENT(ENOTSOCK),
TABLE_CONTENT(ENOTSUP),
TABLE_CONTENT(ENOTTY),
TABLE_CONTENT(ENOTUNIQ),
TABLE_CONTENT(ENXIO),
TABLE_CONTENT(EOPNOTSUPP),
TABLE_CONTENT(EOVERFLOW),
TABLE_CONTENT(EOWNERDEAD),
TABLE_CONTENT(EPERM),
TABLE_CONTENT(EPFNOSUPPORT),
TABLE_CONTENT(EPIPE),
TABLE_CONTENT(EPROCLIM),
TABLE_CONTENT(EPROTO),
TABLE_CONTENT(EPROTONOSUPPORT),
TABLE_CONTENT(EPROTOTYPE),
TABLE_CONTENT(ERANGE),
TABLE_CONTENT(EREMCHG),
TABLE_CONTENT(EREMOTE),
TABLE_CONTENT(EROFS),
TABLE_CONTENT(ESHUTDOWN),
TABLE_CONTENT(ESOCKTNOSUPPORT),
TABLE_CONTENT(ESPIPE),
TABLE_CONTENT(ESRCH),
TABLE_CONTENT(ESRMNT),
TABLE_CONTENT(ESTALE),
TABLE_CONTENT(ESTRPIPE),
TABLE_CONTENT(ETIME),
TABLE_CONTENT(ETIMEDOUT),
TABLE_CONTENT(ETOOMANYREFS),
TABLE_CONTENT(ETXTBSY),
TABLE_CONTENT(EUNATCH),
TABLE_CONTENT(EUSERS),
TABLE_CONTENT(EXDEV),
TABLE_CONTENT(EXFULL)
};
/****************************************************************************
* Public Functions
****************************************************************************/
int altcom_errno2nuttx(int altcom_errno)
{
int i;
for (i = 0; i < ARRAY_SZ(g_converrno_tbl); i++)
{
if (g_converrno_tbl[i].altcom_errno == altcom_errno)
{
return g_converrno_tbl[i].nuttx_errno;
}
}
return altcom_errno;
}
int altcom_geterrcode(int32_t err_code)
{
int err;
err = ntohl(err_code);
if (err < 0)
{
err = altcom_errno2nuttx(-err);
err = -err;
}
return err;
}

View file

@ -0,0 +1,201 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_errno.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_ERRNO_H
#define __DRIVERS_MODEM_ALT1250_ALTCOM_ERRNO_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdint.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define ALTCOM_EPERM 1
#define ALTCOM_ENOENT 2
#define ALTCOM_ESRCH 3
#define ALTCOM_EINTR 4
#define ALTCOM_EIO 5
#define ALTCOM_ENXIO 6
#define ALTCOM_E2BIG 7
#define ALTCOM_ENOEXEC 8
#define ALTCOM_EBADF 9
#define ALTCOM_ECHILD 10
#define ALTCOM_EAGAIN 11
#define ALTCOM_ENOMEM 12
#define ALTCOM_EACCES 13
#define ALTCOM_EFAULT 14
#define ALTCOM_ENOTBLK 15
#define ALTCOM_EBUSY 16
#define ALTCOM_EEXIST 17
#define ALTCOM_EXDEV 18
#define ALTCOM_ENODEV 19
#define ALTCOM_ENOTDIR 20
#define ALTCOM_EISDIR 21
#define ALTCOM_EINVAL 22
#define ALTCOM_ENFILE 23
#define ALTCOM_EMFILE 24
#define ALTCOM_ENOTTY 25
#define ALTCOM_ETXTBSY 26
#define ALTCOM_EFBIG 27
#define ALTCOM_ENOSPC 28
#define ALTCOM_ESPIPE 29
#define ALTCOM_EROFS 30
#define ALTCOM_EMLINK 31
#define ALTCOM_EPIPE 32
#define ALTCOM_EDOM 33
#define ALTCOM_ERANGE 34
#define ALTCOM_ENOMSG 35
#define ALTCOM_EIDRM 36
#define ALTCOM_ECHRNG 37
#define ALTCOM_EL2NSYNC 38
#define ALTCOM_EL3HLT 39
#define ALTCOM_EL3RST 40
#define ALTCOM_ELNRNG 41
#define ALTCOM_EUNATCH 42
#define ALTCOM_ENOCSI 43
#define ALTCOM_EL2HLT 44
#define ALTCOM_EDEADLK 45
#define ALTCOM_ENOLCK 46
#define ALTCOM_EBADE 50
#define ALTCOM_EBADR 51
#define ALTCOM_EXFULL 52
#define ALTCOM_ENOANO 53
#define ALTCOM_EBADRQC 54
#define ALTCOM_EBADSLT 55
#define ALTCOM_EDEADLOCK 56
#define ALTCOM_EBFONT 57
#define ALTCOM_ENOSTR 60
#define ALTCOM_ENODATA 61
#define ALTCOM_ETIME 62
#define ALTCOM_ENOSR 63
#define ALTCOM_ENONET 64
#define ALTCOM_ENOPKG 65
#define ALTCOM_EREMOTE 66
#define ALTCOM_ENOLINK 67
#define ALTCOM_EADV 68
#define ALTCOM_ESRMNT 69
#define ALTCOM_ECOMM 70
#define ALTCOM_EPROTO 71
#define ALTCOM_EMULTIHOP 74
#define ALTCOM_ELBIN 75
#define ALTCOM_EDOTDOT 76
#define ALTCOM_EBADMSG 77
#define ALTCOM_EFTYPE 79
#define ALTCOM_ENOTUNIQ 80
#define ALTCOM_EBADFD 81
#define ALTCOM_EREMCHG 82
#define ALTCOM_ELIBACC 83
#define ALTCOM_ELIBBAD 84
#define ALTCOM_ELIBSCN 85
#define ALTCOM_ELIBMAX 86
#define ALTCOM_ELIBEXEC 87
#define ALTCOM_ENOSYS 88
#define ALTCOM_ENMFILE 89
#define ALTCOM_ENOTEMPTY 90
#define ALTCOM_ENAMETOOLONG 91
#define ALTCOM_ELOOP 92
#define ALTCOM_EOPNOTSUPP 95
#define ALTCOM_EPFNOSUPPORT 96
#define ALTCOM_ECONNRESET 104
#define ALTCOM_ENOBUFS 105
#define ALTCOM_EAFNOSUPPORT 106
#define ALTCOM_EPROTOTYPE 107
#define ALTCOM_ENOTSOCK 108
#define ALTCOM_ENOPROTOOPT 109
#define ALTCOM_ESHUTDOWN 110
#define ALTCOM_ECONNREFUSED 111
#define ALTCOM_EADDRINUSE 112
#define ALTCOM_ECONNABORTED 113
#define ALTCOM_ENETUNREACH 114
#define ALTCOM_ENETDOWN 115
#define ALTCOM_ETIMEDOUT 116
#define ALTCOM_EHOSTDOWN 117
#define ALTCOM_EHOSTUNREACH 118
#define ALTCOM_EINPROGRESS 119
#define ALTCOM_EALREADY 120
#define ALTCOM_EDESTADDRREQ 121
#define ALTCOM_EMSGSIZE 122
#define ALTCOM_EPROTONOSUPPORT 123
#define ALTCOM_ESOCKTNOSUPPORT 124
#define ALTCOM_EADDRNOTAVAIL 125
#define ALTCOM_ENETRESET 126
#define ALTCOM_EISCONN 127
#define ALTCOM_ENOTCONN 128
#define ALTCOM_ETOOMANYREFS 129
#define ALTCOM_EPROCLIM 130
#define ALTCOM_EUSERS 131
#define ALTCOM_EDQUOT 132
#define ALTCOM_ESTALE 133
#define ALTCOM_ENOTSUP 134
#define ALTCOM_ENOMEDIUM 135
#define ALTCOM_ENOSHARE 136
#define ALTCOM_ECASECLASH 137
#define ALTCOM_EILSEQ 138
#define ALTCOM_EOVERFLOW 139
#define ALTCOM_ECANCELED 140
#define ALTCOM_ENOTRECOVERABLE 141
#define ALTCOM_EOWNERDEAD 142
#define ALTCOM_ESTRPIPE 143
#define ALTCOM_EWOULDBLOCK ALTCOM_EAGAIN
#define ALTCOM_ERRNO_MIN ALTCOM_EPERM
#define ALTCOM_ERRNO_MAX ALTCOM_ESTRPIPE
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: altcom_errno2nuttx
*
* Description:
* Get Nuttx errno from ALTCOM errno.
*
* Input Parameters:
* altcom_errno - ALTCOM errno.
*
* Returned Value:
* Returns NuttX errno.
*
****************************************************************************/
int altcom_errno2nuttx(int altcom_errno);
/****************************************************************************
* Name: altcom_geterrcode
*
* Description:
* Get Nuttx errno from ALTCOM paccket.
*
* Input Parameters:
* err_code - The err_code of the ALTCOM packet.
*
* Returned Value:
* Returns NuttX errno.
*
****************************************************************************/
int altcom_geterrcode(int32_t err_code);
#endif /* __DRIVERS_MODEM_ALT1250_ALTCOM_ERRNO_H */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,257 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_hdlr_firmware.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 <stdint.h>
#include <stddef.h>
#include <string.h>
#include <errno.h>
#include <arpa/inet.h>
#include <nuttx/modem/alt1250.h>
#include <nuttx/wireless/lte/lte.h>
#include "altcom_cmd.h"
#include "altcom_errno.h"
/****************************************************************************
* Private Functions
****************************************************************************/
static void getver_parse_response(FAR struct apicmd_cmddat_getverres_s *resp,
FAR lte_version_t *version)
{
memset(version, 0, sizeof(*version));
strncpy(version->bb_product,
(FAR const char *)resp->bb_product, LTE_VER_BB_PRODUCT_LEN - 1);
strncpy(version->np_package,
(FAR const char *)resp->np_package, LTE_VER_NP_PACKAGE_LEN - 1);
}
/****************************************************************************
* Public Functions
****************************************************************************/
int32_t altcom_getver_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
int32_t size = 0;
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_GET_VERSION;
}
else if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_GET_VERSION_V4;
}
else
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_injectimage_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid)
{
int32_t size = 0;
FAR uint8_t *sending_data = (uint8_t *)arg[0];
int len = *(int *)arg[1];
bool mode = *(bool *)arg[2];
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
FAR struct apicmd_cmddat_fw_injectdeltaimg_s *out =
(FAR struct apicmd_cmddat_fw_injectdeltaimg_s *)pktbuf;
*altcid = APICMDID_FW_INJECTDELTAIMG;
len = (len > APICMD_FW_INJECTDATA_MAXLEN) ?
APICMD_FW_INJECTDATA_MAXLEN : len;
out->data_len = htonl(len);
out->inject_mode = mode ? LTEFW_INJECTION_MODE_NEW
: LTEFW_INJECTION_MODE_APPEND;
memcpy(out->data, sending_data, len);
size = sizeof(struct apicmd_cmddat_fw_injectdeltaimg_s);
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
FAR struct apicmd_cmddat_fw_injectdeltaimg_v4_s *out =
(FAR struct apicmd_cmddat_fw_injectdeltaimg_v4_s *)pktbuf;
*altcid = APICMDID_FW_INJECTDELTAIMG_V4;
len = (len > APICMD_FW_INJECTDATA_MAXLEN_V4) ?
APICMD_FW_INJECTDATA_MAXLEN_V4 : len;
out->data_len = htonl(len);
out->inject_mode = mode ? LTEFW_INJECTION_MODE_NEW
: LTEFW_INJECTION_MODE_APPEND;
memcpy(out->data, sending_data, len);
size = sizeof(struct apicmd_cmddat_fw_injectdeltaimg_v4_s) - 1 + len;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_getimagelen_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid)
{
int32_t size = 0;
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_FW_GETDELTAIMGLEN;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_FW_GETDELTAIMGLEN_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_execupdate_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid)
{
int32_t size = 0;
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_FW_EXECDELTAUPDATE;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_FW_EXECDELTAUPDATE_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_getupdateres_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid)
{
int32_t size = 0;
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_FW_GETUPDATERESULT;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_FW_GETUPDATERESULT_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_getver_pkt_parse(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)
{
FAR int *ret = (FAR int *)arg[0];
FAR lte_version_t *version = (FAR lte_version_t *)arg[1];
FAR struct apicmd_cmddat_getverres_s *in =
(FAR struct apicmd_cmddat_getverres_s *)pktbuf;
*ret = (LTE_RESULT_OK == in->result) ? 0 : -EPROTO;
if (*ret == 0)
{
/* Parse version information */
getver_parse_response(in, version);
}
return 0;
}
int32_t altcom_fwcommon_pkt_parse(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)
{
int32_t result_cmd;
int16_t injection_retcode;
FAR struct apicmd_cmddat_fw_deltaupcommres_s *in =
(FAR struct apicmd_cmddat_fw_deltaupcommres_s *)pktbuf;
/* Negative value in result_cmd means an error is occured.
* Zero indicates command successed or size of injected data
*/
result_cmd = altcom_geterrcode(in->api_result);
injection_retcode = ntohs(in->ltefw_result);
return (injection_retcode != 0) ? -injection_retcode : result_cmd;
}

View file

@ -0,0 +1,65 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_hdlr_firmware.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_FIRMWARE_H
#define __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_FIRMWARE_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <stdint.h>
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
int32_t altcom_getver_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_injectimage_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_getimagelen_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_execupdate_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_getupdateres_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_getver_pkt_parse(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);
int32_t altcom_fwcommon_pkt_parse(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);
#endif /* __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_FIRMWARE_H */

View file

@ -0,0 +1,476 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_hdlr_log.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 <stdint.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <arpa/inet.h>
#include "altcom_cmd_log.h"
#include "altcom_errno.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef MIN
# define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
static int copy_logfilename(FAR char *filename, size_t fnamelen,
FAR char *path)
{
int ret = OK;
size_t pathlen = strnlen(path, ALTCOM_PATH_LEN_MAX);
if ((ALTCOM_PATH_LEN_MAX > pathlen) &&
(strncmp(path, ALTCOM_LOGSPATH, strlen(ALTCOM_LOGSPATH)) == 0))
{
path += strlen(ALTCOM_LOGSPATH);
pathlen -= strlen(ALTCOM_LOGSPATH);
if (pathlen <= fnamelen)
{
strncpy(filename, path, fnamelen);
}
else
{
ret = -ENOBUFS;
}
}
else
{
ret = -EILSEQ;
}
return ret;
}
#ifdef CONFIG_MODEM_ALT1250_LOG_ACCESS
static int create_logpath(FAR char *filename, FAR char *path)
{
if (strlen(filename) + strlen(ALTCOM_LOGSPATH) >=
ALTCOM_LOG_ACCESS_PATH_LEN_MAX)
{
return -ENAMETOOLONG;
}
snprintf(path, ALTCOM_LOG_ACCESS_PATH_LEN_MAX, "%s%s", ALTCOM_LOGSPATH,
filename);
return OK;
}
#endif /* CONFIG_MODEM_ALT1250_LOG_ACCESS */
/****************************************************************************
* Public Functions
****************************************************************************/
int32_t altcom_logsave_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
FAR struct apicmd_cmddat_clogs_s *out =
(FAR struct apicmd_cmddat_clogs_s *)pktbuf;
size_t len = *(FAR size_t *)arg[0];
int32_t size = sizeof(struct apicmd_cmddat_clogs_s);
out->pathlen = len + strlen(ALTCOM_LOGSPATH);
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_CLOGS;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_CLOGS_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_loglist_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
FAR struct apicmddbg_getloglist_s *out =
(FAR struct apicmddbg_getloglist_s *)pktbuf;
size_t len = (size_t)arg[0];
int32_t size = sizeof(struct apicmddbg_getloglist_s);
out->listsize = LTE_LOG_LIST_SIZE;
out->pathlen = len + strlen(ALTCOM_LOGSPATH);
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_LOGLIST;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_LOGLIST_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
#ifdef CONFIG_MODEM_ALT1250_LOG_ACCESS
int32_t altcom_logopen_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
FAR struct apicmd_logopen_s *out = (FAR struct apicmd_logopen_s *)pktbuf;
FAR char *filename = (FAR char *)arg[0];
int32_t size = sizeof(struct apicmd_logopen_s);
int ret;
ret = create_logpath(filename, out->path);
if (ret < 0)
{
return ret;
}
out->flags = htonl(ALTCOM_LOG_OPEN_FLAGS);
out->mode = htonl(0);
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_LOGOPEN;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_LOGOPEN_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_logclose_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
FAR struct apicmd_logclose_s *out = (FAR struct apicmd_logclose_s *)pktbuf;
int fd = (int)arg[0];
int32_t size = sizeof(struct apicmd_logclose_s);
out->fd = htonl(fd);
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_LOGCLOSE;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_LOGCLOSE_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_logread_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
FAR struct apicmd_logread_s *out = (FAR struct apicmd_logread_s *)pktbuf;
int fd = (int)arg[0];
size_t rlen = (size_t)arg[1];
int32_t size = sizeof(struct apicmd_logread_s);
out->fd = htonl(fd);
out->readlen = (rlen > ALTCOM_LOG_READ_LEN_MAX) ?
htonl(ALTCOM_LOG_READ_LEN_MAX) : htonl(rlen);
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_LOGREAD;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_LOGREAD_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_loglseek_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
FAR struct apicmd_loglseek_s *out = (FAR struct apicmd_loglseek_s *)pktbuf;
int fd = (int)arg[0];
off_t offset = *(FAR off_t *)arg[1];
int whence = (int)arg[2];
int32_t size = sizeof(struct apicmd_loglseek_s);
switch (whence)
{
case SEEK_SET:
out->whence = htonl(ALTCOM_LOG_SEEK_SET);
break;
case SEEK_CUR:
out->whence = htonl(ALTCOM_LOG_SEEK_CUR);
break;
case SEEK_END:
out->whence = htonl(ALTCOM_LOG_SEEK_END);
break;
default:
return -EINVAL;
break;
}
out->fd = htonl(fd);
out->offset = htonl(offset);
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_LOGLSEEK;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_LOGLSEEK_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_logremove_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid)
{
FAR struct apicmd_logremove_s *out =
(FAR struct apicmd_logremove_s *)pktbuf;
FAR char *filename = (FAR char *)arg[0];
int32_t size = sizeof(struct apicmd_logremove_s);
int ret;
ret = create_logpath(filename, out->path);
if (ret < 0)
{
return ret;
}
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_LOGREMOVE;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_LOGREMOVE_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
#endif /* CONFIG_MODEM_ALT1250_LOG_ACCESS */
int32_t altcom_logsave_pkt_parse(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)
{
FAR struct apicmd_cmddat_clogsres_s *out =
(FAR struct apicmd_cmddat_clogsres_s *)pktbuf;
FAR char *fname = (FAR char *)arg[0];
size_t fnamelen = *(FAR size_t *)arg[1];
int32_t ret = altcom_geterrcode(out->altcom_result);
if ((ret == 0) && (fname != NULL))
{
if (ALTCOM_PATH_LEN_MAX > out->pathlen)
{
ret = copy_logfilename(fname, fnamelen, out->path);
}
else
{
ret = -EILSEQ;
}
}
return ret;
}
int32_t altcom_loglist_pkt_parse(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)
{
FAR struct apicmddbg_getloglistres_s *out =
(FAR struct apicmddbg_getloglistres_s *)pktbuf;
FAR char *list = (FAR char *)arg[0];
size_t nlists = (size_t)arg[1];
size_t fnamelen = (size_t)arg[2];
int32_t ret = altcom_geterrcode(out->altcom_result);
int i;
if (fnamelen != LTE_LOG_NAME_LEN)
{
return -ENOBUFS;
}
if (ret == 0)
{
if ((out->listsize > LTE_LOG_LIST_SIZE) ||
((out->listsize != 0) && (ALTCOM_PATH_LEN_MAX < out->pathlen)))
{
return -EILSEQ;
}
for (i = 0; i < MIN(nlists, out->listsize); i++)
{
ret = copy_logfilename(&list[i * fnamelen], fnamelen,
&out->list[i * out->pathlen]);
if (ret != OK)
{
break;
}
}
ret = (i == MIN(nlists, out->listsize)) ? i : ret;
}
else if (ret == -EPROTO)
{
ret = 0;
}
return ret;
}
#ifdef CONFIG_MODEM_ALT1250_LOG_ACCESS
int32_t altcom_logcommon_pkt_parse(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)
{
FAR struct apicmd_logcommonres_s *out =
(FAR struct apicmd_logcommonres_s *)pktbuf;
return ntohl(out->altcom_result);
}
int32_t altcom_logread_pkt_parse(FAR struct alt1250_dev_s *dev,
FAR uint8_t *pktbuf, size_t pktsz,
int8_t altver, FAR void **arg,
size_t arglen, FAR uint64_t *bitmap)
{
FAR struct apicmd_logreadres_s *out =
(FAR struct apicmd_logreadres_s *)pktbuf;
FAR void *buf = arg[0];
size_t len = (size_t)arg[1];
int32_t ret = ntohl(out->altcom_result);
if (ret > 0)
{
if (ret <= len)
{
memcpy(buf, out->readdata, ret);
}
else
{
ret = -EILSEQ;
}
}
return ret;
}
#endif /* CONFIG_MODEM_ALT1250_LOG_ACCESS */

View file

@ -0,0 +1,82 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_hdlr_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_HDLR_LOG_H
#define __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_LOG_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <stdint.h>
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
int32_t altcom_logsave_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_loglist_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
#ifdef CONFIG_MODEM_ALT1250_LOG_ACCESS
int32_t altcom_logopen_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_logclose_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_logread_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_loglseek_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_logremove_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
#endif /* CONFIG_MODEM_ALT1250_LOG_ACCESS */
int32_t altcom_logsave_pkt_parse(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);
int32_t altcom_loglist_pkt_parse(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);
#ifdef CONFIG_MODEM_ALT1250_LOG_ACCESS
int32_t altcom_logcommon_pkt_parse(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);
int32_t altcom_logread_pkt_parse(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);
#endif /* CONFIG_MODEM_ALT1250_LOG_ACCESS */
#endif /* __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_LOG_H */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,125 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_hdlr_net.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_NET_H
#define __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_NET_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <stdint.h>
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
int32_t altcom_getltime_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_getoper_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_getqual_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_getcell_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_getrat_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_setrat_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_getimscap_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_setrepqual_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_setrepcell_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_setrepevt_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_getltime_pkt_parse(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);
int32_t altcom_getoper_pkt_parse(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);
int32_t altcom_getqual_pkt_parse(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);
int32_t altcom_getcell_pkt_parse(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);
int32_t altcom_getrat_pkt_parse(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);
int32_t altcom_setrat_pkt_parse(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);
int32_t altcom_getimscap_pkt_parse(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);
int32_t altcom_setrepqual_pkt_parse(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);
int32_t altcom_setrepcell_pkt_parse(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);
int32_t altcom_repqual_pkt_parse(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);
int32_t altcom_repcell_pkt_parse(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);
int32_t altcom_setrepevt_pkt_parse(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);
int32_t altcom_repevt_pkt_parse(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);
#endif /* __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_NET_H */

View file

@ -0,0 +1,216 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_hdlr_other.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 <stdint.h>
#include <stddef.h>
#include <string.h>
#include <errno.h>
#include <arpa/inet.h>
#include <nuttx/modem/alt1250.h>
#include <nuttx/wireless/lte/lte.h>
#include "alt1250.h"
#include "altcom_cmd.h"
#include "altcom_lwm2m_hdlr.h"
#include "altcom_errno.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define ATCMD_HEADER "AT"
#define ATCMD_HEADER_LEN (2)
#define ATCMD_FOOTER '\r'
#define ATCMD_FOOTER_LEN (1)
/****************************************************************************
* Public Functions
****************************************************************************/
int32_t altcom_getimei_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
int32_t size = 0;
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_GET_IMEI;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_GET_IMEI_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_sendatcmd_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid)
{
int32_t size = 0;
FAR const char *cmd = (FAR const char *)arg[0];
int cmdlen = (int)arg[1];
size = cmdlen - ATCMD_HEADER_LEN;
memcpy(pktbuf, cmd + ATCMD_HEADER_LEN, size);
pktbuf[size - ATCMD_FOOTER_LEN] = '\0';
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
size = -ENOTSUP;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_SEND_ATCMD_V4;
}
else
#endif
{
size = -ENOTSUP;
}
return size;
}
int32_t altcom_errinfo_pkt_parse(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)
{
FAR lte_errinfo_t *info = (FAR lte_errinfo_t *)arg[0];
FAR struct apicmd_cmddat_errinfo_s *in =
(FAR struct apicmd_cmddat_errinfo_s *)pktbuf;
info->err_indicator = in->indicator;
info->err_result_code = ntohl(in->err_code);
info->err_no = altcom_errno2nuttx(ntohl(in->err_no));
memcpy(info->err_string, in->err_str, LTE_ERROR_STRING_MAX_LEN);
info->err_string[LTE_ERROR_STRING_MAX_LEN - 1] = '\0';
return 0;
}
int32_t altcom_getimei_pkt_parse(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)
{
FAR int *ret = (FAR int *)arg[0];
FAR char *imei = (FAR char *)arg[1];
FAR struct apicmd_cmddat_getimeires_s *in =
(FAR struct apicmd_cmddat_getimeires_s *)pktbuf;
*ret = (LTE_RESULT_OK == in->result) ? 0 : -EPROTO;
if (0 == *ret)
{
if (arglen > 2)
{
FAR size_t *len = (FAR size_t *)arg[2];
/* Is it enough length to include Null terminate?
* The length of LTE_IMEI_LEN includes the
* null terminator.
*/
if (*len < strnlen((FAR const char *)in->imei, LTE_IMEI_LEN))
{
return -ENOBUFS;
}
}
strncpy(imei, (FAR const char *)in->imei, LTE_IMEI_LEN);
}
return 0;
}
int32_t altcom_sendatcmd_pkt_parse(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)
{
FAR char *respbuff = (FAR char *)arg[0];
FAR int respbufflen = (int)arg[1];
FAR int *resplen = (FAR int *)arg[2];
if (respbufflen < pktsz)
{
return -ENOBUFS;
}
memcpy(respbuff, (FAR char *)pktbuf, pktsz);
*resplen = pktsz;
return 0;
}
int32_t altcom_urc_event_pkt_parse(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)
{
int32_t ret = -ENOTSUP;
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
uint32_t lcmdid = 0;
alt_evtbuf_inst_t *inst;
lwm2mstub_hndl_t lwm2m_urc_handler;
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
pktbuf[pktsz] = '\0';
m_info("===== URC =====\n%s"
"===============\n", pktbuf);
lwm2m_urc_handler = lwm2mstub_get_handler(&pktbuf, &pktsz, &lcmdid);
*bitmap = get_event_lapibuffer(dev, lcmdid, &inst);
if (*bitmap != 0ULL)
{
ret = lwm2m_urc_handler(pktbuf, pktsz,
inst->outparam, inst->outparamlen);
}
}
#endif
return ret;
}

View file

@ -0,0 +1,61 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_hdlr_other.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_OTHER_H
#define __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_OTHER_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <stdint.h>
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
int32_t altcom_getimei_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_sendatcmd_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_errinfo_pkt_parse(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);
int32_t altcom_getimei_pkt_parse(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);
int32_t altcom_sendatcmd_pkt_parse(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);
int32_t altcom_urc_event_pkt_parse(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);
#endif /* __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_OTHER_H */

View file

@ -0,0 +1,650 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_hdlr_pdn.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 <stdint.h>
#include <stddef.h>
#include <string.h>
#include <errno.h>
#include <arpa/inet.h>
#include <nuttx/modem/alt1250.h>
#include <nuttx/wireless/lte/lte.h>
#include "altcom_cmd.h"
/****************************************************************************
* Private Functions
****************************************************************************/
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
static int32_t altcombs_set_pdninfo(struct apicmd_pdnset_s *cmd_pdn,
lte_pdn_t *lte_pdn)
{
int32_t i;
if (!cmd_pdn || !lte_pdn)
{
return -EINVAL;
}
lte_pdn->session_id = cmd_pdn->session_id;
lte_pdn->active = cmd_pdn->activate;
lte_pdn->apn_type = htonl(cmd_pdn->apntype);
lte_pdn->ipaddr_num = cmd_pdn->ipaddr_num;
for (i = 0; i < lte_pdn->ipaddr_num; i++)
{
lte_pdn->address[i].ip_type = cmd_pdn->ip_address[i].iptype;
strncpy(lte_pdn->address[i].address,
(FAR char *)cmd_pdn->ip_address[i].address,
LTE_IPADDR_MAX_LEN - 1);
}
lte_pdn->ims_register = cmd_pdn->imsregister == APICMD_PDN_IMS_REG ?
LTE_IMS_REGISTERED : LTE_IMS_NOT_REGISTERED;
lte_pdn->data_allow = cmd_pdn->dataallow ==
APICMD_PDN_DATAALLOW_ALLOW ?
LTE_DATA_ALLOW : LTE_DATA_DISALLOW;
lte_pdn->data_roaming_allow = cmd_pdn->dararoamingallow ==
APICMD_PDN_DATAROAMALLOW_ALLOW ?
LTE_DATA_ALLOW : LTE_DATA_DISALLOW;
return 0;
}
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
static int32_t altcombs_set_pdninfo_v4(
FAR struct apicmd_pdnset_v4_s *cmd_pdn,
FAR lte_pdn_t *lte_pdn, FAR uint8_t *ndnsaddrs,
FAR struct sockaddr_storage *dnsaddrs)
{
int32_t i;
int af;
if (!cmd_pdn || !lte_pdn)
{
return -EINVAL;
}
lte_pdn->session_id = cmd_pdn->session_id;
lte_pdn->active = cmd_pdn->activate;
lte_pdn->apn_type = htonl(cmd_pdn->apntype);
lte_pdn->ipaddr_num = cmd_pdn->ipaddr_num;
for (i = 0; i < lte_pdn->ipaddr_num; i++)
{
lte_pdn->address[i].ip_type = cmd_pdn->ip_address[i].iptype;
strncpy(lte_pdn->address[i].address,
(FAR char *)cmd_pdn->ip_address[i].address,
LTE_IPADDR_MAX_LEN - 1);
}
lte_pdn->ims_register = cmd_pdn->imsregister;
lte_pdn->data_allow = cmd_pdn->dataallow;
lte_pdn->data_roaming_allow = cmd_pdn->dararoamingallow;
if (ndnsaddrs && dnsaddrs)
{
*ndnsaddrs = (cmd_pdn->dnsaddr_num > APICMD_PDN_DNSCOUNT_MAX) ?
APICMD_PDN_DNSCOUNT_MAX : cmd_pdn->dnsaddr_num;
for (i = 0; (i < APICMD_PDN_DNSCOUNT_MAX) && (i < *ndnsaddrs); i++)
{
af = (cmd_pdn->dns_address[i].iptype == LTE_IPTYPE_V4) ?
AF_INET : AF_INET6;
if (af == AF_INET)
{
FAR struct sockaddr_in *addr =
(FAR struct sockaddr_in *)&dnsaddrs[i];
addr->sin_family = AF_INET;
addr->sin_port = 0;
if (1 != inet_pton(af,
(FAR const char *)cmd_pdn->dns_address[i].address,
(FAR void *)&addr->sin_addr))
{
/* inet_pton() failed, then force break */
*ndnsaddrs = i;
break;
}
}
else
{
FAR struct sockaddr_in6 *addr =
(FAR struct sockaddr_in6 *)&dnsaddrs[i];
addr->sin6_family = AF_INET6;
addr->sin6_port = 0;
if (1 != inet_pton(af,
(FAR const char *)cmd_pdn->dns_address[i].address,
(FAR void *)&addr->sin6_addr))
{
/* inet_pton() failed, then force break */
*ndnsaddrs = i;
break;
}
}
}
}
return 0;
}
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
static void getnetinfo_parse_response(
FAR struct apicmd_cmddat_getnetinfores_s *resp,
FAR lte_netinfo_t *netinfo, uint8_t pdn_num)
{
uint8_t i;
netinfo->nw_stat = resp->netinfo.nw_stat;
netinfo->nw_err.err_type = resp->netinfo.err_info.err_type;
netinfo->nw_err.reject_cause.category =
resp->netinfo.err_info.reject_cause.category;
netinfo->nw_err.reject_cause.value =
resp->netinfo.err_info.reject_cause.value;
netinfo->pdn_num = resp->netinfo.pdn_count;
if ((0 < resp->netinfo.pdn_count) && (netinfo->pdn_stat))
{
for (i = 0; (i < resp->netinfo.pdn_count) && (i < pdn_num); i++)
{
altcombs_set_pdninfo(&resp->netinfo.pdn[i],
&netinfo->pdn_stat[i]);
}
}
}
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
static void getnetinfo_parse_response_v4(
FAR struct apicmd_cmddat_getnetinfores_v4_s *resp,
FAR lte_netinfo_t *netinfo, uint8_t pdn_num)
{
uint8_t i;
netinfo->nw_stat = resp->netinfo.nw_stat;
netinfo->nw_err.err_type = resp->netinfo.err_info.err_type;
netinfo->nw_err.reject_cause.category =
resp->netinfo.err_info.reject_cause.category;
netinfo->nw_err.reject_cause.value =
resp->netinfo.err_info.reject_cause.value;
netinfo->pdn_num = resp->netinfo.pdn_count;
if ((0 < resp->netinfo.pdn_count) && (netinfo->pdn_stat))
{
for (i = 0; (i < resp->netinfo.pdn_count) && (i < pdn_num); i++)
{
altcombs_set_pdninfo_v4(&resp->netinfo.pdn[i],
&netinfo->pdn_stat[i], NULL, NULL);
}
}
}
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
int32_t altcom_actpdn_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
int32_t size = 0;
FAR lte_apn_setting_t *apn = (FAR lte_apn_setting_t *)arg[0];
FAR struct apicmd_cmddat_activatepdn_s *out =
(FAR struct apicmd_cmddat_activatepdn_s *)pktbuf;
out->apntype = htonl(apn->apn_type);
if (apn->ip_type == LTE_IPTYPE_NON && altver == ALTCOM_VER1)
{
return -ENOTSUP;
}
out->iptype = apn->ip_type;
out->authtype = apn->auth_type;
strncpy((FAR char *)out->apnname, (FAR const char *)apn->apn,
sizeof(out->apnname));
if (apn->auth_type != LTE_APN_AUTHTYPE_NONE)
{
strncpy((FAR char *)out->username, (FAR const char *)apn->user_name,
sizeof(out->username));
strncpy((FAR char *)out->password, (FAR const char *)apn->password,
sizeof(out->password));
}
size = sizeof(struct apicmd_cmddat_activatepdn_s);
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_ACTIVATE_PDN;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_ACTIVATE_PDN_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_deactpdn_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
int32_t size = 0;
FAR uint8_t *session_id = (FAR uint8_t *)arg[0];
FAR struct apicmd_cmddat_deactivatepdn_s *out =
(FAR struct apicmd_cmddat_deactivatepdn_s *)pktbuf;
out->session_id = *session_id;
size = sizeof(struct apicmd_cmddat_deactivatepdn_s);
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_DEACTIVATE_PDN;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_DEACTIVATE_PDN_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_actpdncancel_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid)
{
int32_t size = 0;
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_ACTIVATE_PDN_CANCEL;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_ACTIVATE_PDN_CANCEL_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_getnetinfo_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid)
{
int32_t size = 0;
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_GET_NETINFO;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_GET_NETINFO_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_setrepnet_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid)
{
int32_t size = 0;
FAR struct apicmd_cmddat_set_repnetinfo_s *out =
(FAR struct apicmd_cmddat_set_repnetinfo_s *)pktbuf;
out->report = APICMD_REPNETINFO_REPORT_ENABLE;
size = sizeof(struct apicmd_cmddat_set_repnetinfo_s);
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_SETREP_NETINFO;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_SETREP_NETINFO_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_actpdn_pkt_parse(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)
{
FAR int *ret = (FAR int *)arg[0];
FAR lte_pdn_t *pdn = (FAR lte_pdn_t *)arg[1];
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
FAR struct apicmd_cmddat_activatepdnres_s *in =
(FAR struct apicmd_cmddat_activatepdnres_s *)pktbuf;
if (LTE_RESULT_OK == in->result)
{
/* Parse PDN information */
altcombs_set_pdninfo(&in->pdnset, pdn);
*ret = in->result;
}
else
{
*ret = (LTE_RESULT_CANCEL == in->result) ? -ECANCELED : -EPROTO;
}
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
FAR struct apicmd_cmddat_activatepdnres_v4_s *in =
(FAR struct apicmd_cmddat_activatepdnres_v4_s *)pktbuf;
if (LTE_RESULT_OK == in->result)
{
/* Parse PDN information */
altcombs_set_pdninfo_v4(&in->pdnset, pdn, NULL, NULL);
*ret = in->result;
}
else
{
*ret = (LTE_RESULT_CANCEL == in->result) ? -ECANCELED : -EPROTO;
}
}
else
#endif
{
return -ENOSYS;
}
return 0;
}
int32_t altcom_deactpdn_pkt_parse(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)
{
FAR int *ret = (FAR int *)arg[0];
FAR struct apicmd_cmddat_deactivatepdnres_s *in =
(FAR struct apicmd_cmddat_deactivatepdnres_s *)pktbuf;
*ret = (LTE_RESULT_OK == in->result) ? 0 : -EPROTO;
return 0;
}
int32_t altcom_actpdncancel_pkt_parse(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)
{
FAR int *ret = (FAR int *)arg[0];
FAR struct apicmd_cmddat_activatepdn_cancel_res_s *in =
(FAR struct apicmd_cmddat_activatepdn_cancel_res_s *)pktbuf;
*ret = 0;
if (LTE_RESULT_OK != in->result)
{
m_err("API command response is err.\n");
*ret = -EIO;
}
return 0;
}
int32_t altcom_getnetinfo_pkt_parse(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)
{
FAR int *ret = (FAR int *)arg[0];
FAR lte_netinfo_t *info = (FAR lte_netinfo_t *)arg[1];
FAR uint8_t *pdn_num = (FAR uint8_t *)arg[2];
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
FAR struct apicmd_cmddat_getnetinfores_s *in =
(FAR struct apicmd_cmddat_getnetinfores_s *)pktbuf;
*ret = (LTE_RESULT_OK == in->result) ? 0 : -EPROTO;
if (0 == *ret)
{
/* Parse network information */
getnetinfo_parse_response(in, info, *pdn_num);
}
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
FAR struct apicmd_cmddat_getnetinfores_v4_s *in =
(FAR struct apicmd_cmddat_getnetinfores_v4_s *)pktbuf;
*ret = (LTE_RESULT_OK == in->result) ? 0 : -EPROTO;
if (0 == *ret)
{
/* Parse network information */
getnetinfo_parse_response_v4(in, info, *pdn_num);
}
}
else
#endif
{
return -ENOSYS;
}
return 0;
}
int32_t altcom_setrepnet_pkt_parse(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)
{
FAR int *ret = (FAR int *)arg[0];
FAR struct apicmd_cmddat_set_repnetinfores_s *in =
(FAR struct apicmd_cmddat_set_repnetinfores_s *)pktbuf;
*ret = (APICMD_REPNETINFO_RES_OK == in->result ? 0 : -EIO);
return 0;
}
int32_t altcom_repnet_pkt_parse(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)
{
FAR lte_netinfo_t *netinfo = (FAR lte_netinfo_t *)arg[0];
FAR uint8_t *ndnsaddrs = (FAR uint8_t *)arg[1];
FAR struct sockaddr_storage *dnsaddrs =
(FAR struct sockaddr_storage *)arg[2];
int i = 0;
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
FAR struct apicmd_cmddat_rep_netinfo_s *in =
(FAR struct apicmd_cmddat_rep_netinfo_s *)pktbuf;
netinfo->nw_stat = in->netinfo.nw_stat;
netinfo->nw_err.err_type = in->netinfo.err_info.err_type;
netinfo->nw_err.reject_cause.category = in->netinfo.
err_info.reject_cause.category;
netinfo->nw_err.reject_cause.value = in->netinfo.
err_info.reject_cause.value;
netinfo->pdn_num = in->netinfo.pdn_count;
if (0 < in->netinfo.pdn_count)
{
for (i = 0; i < in->netinfo.pdn_count; i++)
{
altcombs_set_pdninfo(&in->netinfo.pdn[i],
&netinfo->pdn_stat[i]);
}
}
/* parse DNS address if exists */
if (pktsz == (sizeof(struct apicmd_cmddat_rep_netinfo_s)))
{
*ndnsaddrs = 0;
/* parse IPv4 DNS address */
if (*(uint32_t *)in->dnsaddrv4 != 0)
{
FAR struct sockaddr_in *v4addr =
(FAR struct sockaddr_in *)&dnsaddrs[0];
v4addr->sin_family = AF_INET;
v4addr->sin_port = 0;
memcpy(&v4addr->sin_addr, in->dnsaddrv4,
sizeof(v4addr->sin_addr));
(*ndnsaddrs)++;
}
/* parse IPv6 DNS address */
if (!((*(uint32_t *)&in->dnsaddrv6[0] == 0) &&
(*(uint32_t *)&in->dnsaddrv6[4] == 0) &&
(*(uint32_t *)&in->dnsaddrv6[8] == 0) &&
(*(uint32_t *)&in->dnsaddrv6[12] == 0)))
{
FAR struct sockaddr_in6 *v6addr =
(FAR struct sockaddr_in6 *)&dnsaddrs[*ndnsaddrs];
v6addr->sin6_family = AF_INET6;
v6addr->sin6_port = 0;
memcpy(&v6addr->sin6_addr, in->dnsaddrv6,
sizeof(v6addr->sin6_addr));
(*ndnsaddrs)++;
}
}
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
FAR struct apicmd_cmddat_rep_netinfo_v4_s *in =
(FAR struct apicmd_cmddat_rep_netinfo_v4_s *)pktbuf;
netinfo->nw_stat = in->netinfo.nw_stat;
netinfo->nw_err.err_type = in->netinfo.err_info.err_type;
netinfo->nw_err.reject_cause.category = in->netinfo.
err_info.reject_cause.category;
netinfo->nw_err.reject_cause.value = in->netinfo.
err_info.reject_cause.value;
netinfo->pdn_num = in->netinfo.pdn_count;
if (0 < in->netinfo.pdn_count)
{
for (i = 0; i < in->netinfo.pdn_count; i++)
{
if (i == 0)
{
altcombs_set_pdninfo_v4(&in->netinfo.pdn[i],
&netinfo->pdn_stat[i], ndnsaddrs, dnsaddrs);
}
else
{
altcombs_set_pdninfo_v4(&in->netinfo.pdn[i],
&netinfo->pdn_stat[i], NULL, NULL);
}
}
}
}
else
#endif
{
return -ENOSYS;
}
return 0;
}

View file

@ -0,0 +1,81 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_hdlr_pdn.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_PDN_H
#define __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_PDN_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <stdint.h>
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
int32_t altcom_actpdn_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_deactpdn_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_actpdncancel_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_getnetinfo_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_setrepnet_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_actpdn_pkt_parse(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);
int32_t altcom_deactpdn_pkt_parse(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);
int32_t altcom_actpdncancel_pkt_parse(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);
int32_t altcom_getnetinfo_pkt_parse(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);
int32_t altcom_setrepnet_pkt_parse(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);
int32_t altcom_repnet_pkt_parse(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);
#endif /* __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_PDN_H */

View file

@ -0,0 +1,293 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_hdlr_pin.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 <stdint.h>
#include <stddef.h>
#include <string.h>
#include <errno.h>
#include <arpa/inet.h>
#include <nuttx/modem/alt1250.h>
#include <nuttx/wireless/lte/lte.h>
#include "altcom_cmd.h"
/****************************************************************************
* Private Functions
****************************************************************************/
static void getpinset_parse_response(
FAR struct apicmd_cmddat_getpinsetres_s *resp,
FAR lte_getpin_t *pinset)
{
pinset->enable = resp->active;
pinset->status = resp->status;
pinset->pin_attemptsleft = resp->pin_attemptsleft;
pinset->puk_attemptsleft = resp->puk_attemptsleft;
pinset->pin2_attemptsleft = resp->pin2_attemptsleft;
pinset->puk2_attemptsleft = resp->puk2_attemptsleft;
}
/****************************************************************************
* Public Functions
****************************************************************************/
int32_t altcom_getpinset_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid)
{
int32_t size = 0;
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_GET_PINSET;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_GET_PINSET_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_setpinlock_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid)
{
int32_t size = 0;
FAR bool *enable = (FAR bool *)arg[0];
FAR char *pincode = (FAR char *)arg[1];
FAR struct apicmd_cmddat_setpinlock_s *out =
(FAR struct apicmd_cmddat_setpinlock_s *)pktbuf;
out->mode = *enable;
strncpy((FAR char *)out->pincode, pincode, sizeof(out->pincode));
size = sizeof(struct apicmd_cmddat_setpinlock_s);
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_SET_PIN_LOCK;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_SET_PIN_LOCK_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_setpincode_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid)
{
int32_t size = 0;
FAR int8_t *target_pin = (FAR int8_t *)arg[0];
FAR char *pincode = (FAR char *)arg[1];
FAR char *new_pincode = (FAR char *)arg[2];
FAR struct apicmd_cmddat_setpincode_s *out =
(FAR struct apicmd_cmddat_setpincode_s *)pktbuf;
if (LTE_TARGET_PIN == *target_pin)
{
out->chgtype = APICMD_SETPINCODE_CHGTYPE_PIN;
}
else
{
out->chgtype = APICMD_SETPINCODE_CHGTYPE_PIN2;
}
strncpy((FAR char *)out->pincode, pincode, sizeof(out->pincode));
strncpy((FAR char *)out->newpincode, new_pincode, sizeof(out->newpincode));
size = sizeof(struct apicmd_cmddat_setpincode_s);
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_SET_PIN_CODE;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_SET_PIN_CODE_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_enterpin_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
int32_t size = 0;
FAR char *pincode = (FAR char *)arg[0];
FAR char *new_pincode = (FAR char *)arg[1];
FAR struct apicmd_cmddat_enterpin_s *out =
(FAR struct apicmd_cmddat_enterpin_s *)pktbuf;
strncpy((FAR char *)out->pincode, pincode, sizeof(out->pincode));
if (new_pincode)
{
out->newpincodeuse = APICMD_ENTERPIN_NEWPINCODE_USE;
strncpy((FAR char *)out->newpincode,
new_pincode, sizeof(out->newpincode));
}
else
{
out->newpincodeuse = APICMD_ENTERPIN_NEWPINCODE_UNUSE;
}
size = sizeof(struct apicmd_cmddat_enterpin_s);
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_ENTER_PIN;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_ENTER_PIN_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_getpinset_pkt_parse(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)
{
FAR int *ret = (FAR int *)arg[0];
FAR lte_getpin_t *pinset = (FAR lte_getpin_t *)arg[1];
FAR struct apicmd_cmddat_getpinsetres_s *in =
(FAR struct apicmd_cmddat_getpinsetres_s *)pktbuf;
*ret = (LTE_RESULT_OK == in->result) ? 0 : -EPROTO;
if (0 == *ret)
{
/* Parse PIN settings */
getpinset_parse_response(in, pinset);
}
return 0;
}
int32_t altcom_setpinlock_pkt_parse(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)
{
FAR int *ret = (FAR int *)arg[0];
FAR uint8_t *attemptsleft = (FAR uint8_t *)arg[1];
FAR struct apicmd_cmddat_setpinlockres_s *in =
(FAR struct apicmd_cmddat_setpinlockres_s *)pktbuf;
*ret = (LTE_RESULT_OK == in->result) ? 0 : -EPROTO;
if (*ret != 0)
{
*attemptsleft = in->attemptsleft;
}
return 0;
}
int32_t altcom_setpincode_pkt_parse(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)
{
FAR int *ret = (FAR int *)arg[0];
FAR uint8_t *attemptsleft = (FAR uint8_t *)arg[1];
FAR struct apicmd_cmddat_setpincoderes_s *in =
(FAR struct apicmd_cmddat_setpincoderes_s *)pktbuf;
*ret = (LTE_RESULT_OK == in->result) ? 0 : -EPROTO;
if (*ret != 0)
{
*attemptsleft = in->attemptsleft;
}
return 0;
}
int32_t altcom_enterpin_pkt_parse(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)
{
FAR int *ret = (FAR int *)arg[0];
FAR uint8_t *simstat = (FAR uint8_t *)arg[1];
FAR uint8_t *attemptsleft = (FAR uint8_t *)arg[2];
FAR struct apicmd_cmddat_enterpinres_s *in =
(FAR struct apicmd_cmddat_enterpinres_s *)pktbuf;
*ret = (LTE_RESULT_OK == in->result) ? 0 : -EPROTO;
*simstat = in->simstat;
*attemptsleft = in->attemptsleft;
return 0;
}

View file

@ -0,0 +1,70 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_hdlr_pin.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_PIN_H
#define __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_PIN_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <stdint.h>
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
int32_t altcom_getpinset_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_setpinlock_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_setpincode_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_enterpin_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_getpinset_pkt_parse(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);
int32_t altcom_setpinlock_pkt_parse(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);
int32_t altcom_setpincode_pkt_parse(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);
int32_t altcom_enterpin_pkt_parse(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);
#endif /* __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_PIN_H */

View file

@ -0,0 +1,781 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_hdlr_psave.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 <stdint.h>
#include <stddef.h>
#include <string.h>
#include <errno.h>
#include <arpa/inet.h>
#include <nuttx/modem/alt1250.h>
#include <nuttx/wireless/lte/lte.h>
#include "altcom_cmd.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef ARRAY_SZ
# define ARRAY_SZ(array) (sizeof(array)/sizeof(array[0]))
#endif
#define ALTCOM_GETEDRX_TYPE_UE 0
#define ALTCOM_GETEDRX_TYPE_NEGOTIATED 1
#define ALTCOM_GETPSM_TYPE_UE 0
#define ALTCOM_GETPSM_TYPE_NEGOTIATED 1
#define ALTCOMBS_EDRX_CYCLE_WBS1_MIN (LTE_EDRX_CYC_512)
#define ALTCOMBS_EDRX_CYCLE_WBS1_MAX (LTE_EDRX_CYC_262144)
#define ALTCOMBS_EDRX_CYCLE_NBS1_MIN (LTE_EDRX_CYC_2048)
#define ALTCOMBS_EDRX_CYCLE_NBS1_MAX (LTE_EDRX_CYC_1048576)
#define ALTCOMBS_EDRX_PTW_WBS1_MIN (0)
#define ALTCOMBS_EDRX_PTW_WBS1_MAX (15)
#define ALTCOMBS_EDRX_PTW_NBS1_MIN (0)
#define ALTCOMBS_EDRX_PTW_NBS1_MAX (15)
#define ALTCOMBS_PSM_UNIT_T3324_MIN (LTE_PSM_T3324_UNIT_2SEC)
#define ALTCOMBS_PSM_UNIT_T3324_MAX (LTE_PSM_T3324_UNIT_6MIN)
#define ALTCOMBS_PSM_UNIT_T3412_MIN (LTE_PSM_T3412_UNIT_2SEC)
#define ALTCOMBS_PSM_UNIT_T3412_MAX (LTE_PSM_T3412_UNIT_320HOUR)
#define ALTCOMBS_EDRX_INVALID (255)
/****************************************************************************
* Private Data
****************************************************************************/
static const uint8_t g_edrx_ptw_nbs1_table[] =
{
LTE_EDRX_PTW_256,
LTE_EDRX_PTW_512,
LTE_EDRX_PTW_768,
LTE_EDRX_PTW_1024,
LTE_EDRX_PTW_1280,
LTE_EDRX_PTW_1536,
LTE_EDRX_PTW_1792,
LTE_EDRX_PTW_2048,
LTE_EDRX_PTW_2304,
LTE_EDRX_PTW_2560,
LTE_EDRX_PTW_2816,
LTE_EDRX_PTW_3072,
LTE_EDRX_PTW_3328,
LTE_EDRX_PTW_3584,
LTE_EDRX_PTW_3840,
LTE_EDRX_PTW_4096,
};
/****************************************************************************
* Private Functions
****************************************************************************/
static int32_t altcombs_convert_api_edrx_value(
FAR lte_edrx_setting_t *api_edrx,
FAR struct apicmd_cmddat_setedrx_s *cmd_edrx, uint8_t altver)
{
int i;
int table_size = 0;
if (!cmd_edrx || !api_edrx)
{
m_err("null param\n");
return -EINVAL;
}
/* act_type check for version V4 or later */
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
if (api_edrx->act_type == LTE_EDRX_ACTTYPE_WBS1)
{
cmd_edrx->acttype = APICMD_EDRX_ACTTYPE_WBS1;
}
else if (api_edrx->act_type == LTE_EDRX_ACTTYPE_NOTUSE)
{
cmd_edrx->acttype = APICMD_EDRX_ACTTYPE_NOTUSE;
}
else
{
m_err("Operation is not allowed[act_type : %d].\n",
api_edrx->act_type);
return -EPERM;
}
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
if (api_edrx->act_type == LTE_EDRX_ACTTYPE_WBS1)
{
cmd_edrx->acttype = APICMD_EDRX_ACTTYPE_WBS1;
}
else if (api_edrx->act_type == LTE_EDRX_ACTTYPE_NBS1)
{
cmd_edrx->acttype = APICMD_EDRX_ACTTYPE_NBS1;
}
else if (api_edrx->act_type == LTE_EDRX_ACTTYPE_NOTUSE)
{
cmd_edrx->acttype = APICMD_EDRX_ACTTYPE_NOTUSE;
}
else
{
m_err("Operation is not allowed[act_type : %d].\n",
api_edrx->act_type);
return -EPERM;
}
}
else
#endif
{
return -ENOSYS;
}
if (api_edrx->enable)
{
cmd_edrx->enable = LTE_ENABLE;
if (APICMD_EDRX_ACTTYPE_WBS1 == cmd_edrx->acttype)
{
if (api_edrx->edrx_cycle <= LTE_EDRX_CYC_262144)
{
cmd_edrx->edrx_cycle = api_edrx->edrx_cycle;
}
else
{
m_err("Invalid cycle :%ld\n", api_edrx->edrx_cycle);
return -EINVAL;
}
if (api_edrx->ptw_val <= LTE_EDRX_PTW_2048)
{
cmd_edrx->ptw_val = api_edrx->ptw_val;
}
else
{
m_err("Invalid PTW :%ld\n", api_edrx->ptw_val);
return -EINVAL;
}
}
else if (APICMD_EDRX_ACTTYPE_NBS1 == cmd_edrx->acttype)
{
if (api_edrx->edrx_cycle <= LTE_EDRX_CYC_1048576 &&
(api_edrx->edrx_cycle == LTE_EDRX_CYC_2048 ||
api_edrx->edrx_cycle == LTE_EDRX_CYC_4096 ||
api_edrx->edrx_cycle == LTE_EDRX_CYC_8192 ||
api_edrx->edrx_cycle >= LTE_EDRX_CYC_16384))
{
cmd_edrx->edrx_cycle = api_edrx->edrx_cycle;
}
else
{
m_err("Invalid cycle :%ld\n", api_edrx->edrx_cycle);
return -EINVAL;
}
table_size = ARRAY_SZ(g_edrx_ptw_nbs1_table);
for (i = 0; i < table_size; i++)
{
if (api_edrx->ptw_val == g_edrx_ptw_nbs1_table[i])
{
cmd_edrx->ptw_val = (uint8_t)i;
break;
}
}
if (i == table_size)
{
m_err("Invalid PTW :%ld\n", api_edrx->ptw_val);
return -EINVAL;
}
}
}
else
{
cmd_edrx->enable = LTE_DISABLE;
}
return 0;
}
static int32_t altcombs_convert_apicmd_edrx_value(
FAR struct apicmd_edrxset_s *cmd_edrx, FAR lte_edrx_setting_t *api_edrx)
{
if (!cmd_edrx || !api_edrx)
{
m_err("null param\n");
return -EINVAL;
}
if (cmd_edrx->enable == LTE_ENABLE)
{
api_edrx->enable = LTE_ENABLE;
if (cmd_edrx->acttype == APICMD_EDRX_ACTTYPE_NOTUSE)
{
api_edrx->act_type = LTE_EDRX_ACTTYPE_NOTUSE;
}
else if (cmd_edrx->acttype == APICMD_EDRX_ACTTYPE_WBS1)
{
api_edrx->act_type = LTE_EDRX_ACTTYPE_WBS1;
if (cmd_edrx->edrx_cycle >= ALTCOMBS_EDRX_CYCLE_WBS1_MIN &&
cmd_edrx->edrx_cycle <= ALTCOMBS_EDRX_CYCLE_WBS1_MAX)
{
api_edrx->edrx_cycle = cmd_edrx->edrx_cycle;
}
else
{
m_err("Invalid cycle :%d\n", cmd_edrx->edrx_cycle);
return -EINVAL;
}
if (cmd_edrx->ptw_val >= ALTCOMBS_EDRX_PTW_WBS1_MIN &&
cmd_edrx->ptw_val <= ALTCOMBS_EDRX_PTW_WBS1_MAX)
{
api_edrx->ptw_val = cmd_edrx->ptw_val;
}
else
{
m_err("Invalid PTW :%d\n", cmd_edrx->ptw_val);
return -EINVAL;
}
}
else if (cmd_edrx->acttype == APICMD_EDRX_ACTTYPE_NBS1)
{
api_edrx->act_type = LTE_EDRX_ACTTYPE_NBS1;
if (cmd_edrx->edrx_cycle <= LTE_EDRX_CYC_1048576 &&
(cmd_edrx->edrx_cycle == LTE_EDRX_CYC_2048 ||
cmd_edrx->edrx_cycle == LTE_EDRX_CYC_4096 ||
cmd_edrx->edrx_cycle == LTE_EDRX_CYC_8192 ||
cmd_edrx->edrx_cycle >= LTE_EDRX_CYC_16384))
{
api_edrx->edrx_cycle = cmd_edrx->edrx_cycle;
}
else
{
m_err("Invalid cycle :%d\n", cmd_edrx->edrx_cycle);
return -EINVAL;
}
if (cmd_edrx->ptw_val >= ALTCOMBS_EDRX_PTW_NBS1_MIN &&
cmd_edrx->ptw_val <= ALTCOMBS_EDRX_PTW_NBS1_MAX)
{
api_edrx->ptw_val = g_edrx_ptw_nbs1_table[cmd_edrx->ptw_val];
}
else
{
m_err("Invalid PTW :%d\n", cmd_edrx->ptw_val);
return -EINVAL;
}
}
else
{
m_err("Invalid acttype :%d\n", cmd_edrx->acttype);
return -EINVAL;
}
}
else if (cmd_edrx->enable == LTE_DISABLE)
{
api_edrx->enable = LTE_DISABLE;
}
else
{
m_err("Invalid enable :%d\n", cmd_edrx->enable);
return -EINVAL;
}
return 0;
}
static int32_t altcombs_set_psm(FAR struct apicmd_cmddat_psm_set_s *cmd_set,
FAR lte_psm_setting_t *api_set)
{
if (!cmd_set || !api_set)
{
return -EINVAL;
}
api_set->enable = cmd_set->enable;
api_set->req_active_time.unit = cmd_set->rat_time.unit;
api_set->req_active_time.time_val = cmd_set->rat_time.time_val;
api_set->ext_periodic_tau_time.unit = cmd_set->tau_time.unit;
api_set->ext_periodic_tau_time.time_val = cmd_set->tau_time.time_val;
return 0;
}
static void getce_parse_response(FAR struct apicmd_cmddat_getceres_s *resp,
FAR lte_ce_setting_t *ce)
{
ce->mode_a_enable = resp->mode_a_enable;
ce->mode_b_enable = resp->mode_b_enable;
}
/****************************************************************************
* Public Functions
****************************************************************************/
int32_t altcom_getedrx_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
int32_t size = 0;
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
size = 0;
*altcid = APICMDID_GET_EDRX;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
FAR struct apicmd_cmddat_getedrx_v4_s *out =
(FAR struct apicmd_cmddat_getedrx_v4_s *)pktbuf;
out->type = ALTCOM_GETEDRX_TYPE_UE;
size = sizeof(struct apicmd_cmddat_getedrx_v4_s);
*altcid = APICMDID_GET_EDRX_V4;
}
else
#endif
{
size = -ENOTSUP;
}
return size;
}
int32_t altcom_setedrx_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
int32_t size = 0;
FAR lte_edrx_setting_t *settings = (FAR lte_edrx_setting_t *)arg[0];
int ret = 0;
FAR struct apicmd_cmddat_setedrx_s *out =
(FAR struct apicmd_cmddat_setedrx_s *)pktbuf;
size = sizeof(struct apicmd_cmddat_setedrx_s);
ret = altcombs_convert_api_edrx_value(settings, out, altver);
if (ret < 0)
{
size = ret;
}
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_SET_EDRX;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_SET_EDRX_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_getdedrx_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
int32_t size = 0;
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
size = 0;
*altcid = APICMDID_GET_DYNAMICEDRX;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
FAR struct apicmd_cmddat_getedrx_v4_s *out =
(FAR struct apicmd_cmddat_getedrx_v4_s *)pktbuf;
out->type = ALTCOM_GETEDRX_TYPE_NEGOTIATED;
size = sizeof(struct apicmd_cmddat_getedrx_v4_s);
*altcid = APICMDID_GET_EDRX_V4;
}
else
#endif
{
size = -ENOTSUP;
}
return size;
}
int32_t altcom_getpsm_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
int32_t size = 0;
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
size = 0;
*altcid = APICMDID_GET_PSM;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
FAR struct apicmd_cmddat_getpsm_v4_s *out =
(FAR struct apicmd_cmddat_getpsm_v4_s *)pktbuf;
out->type = ALTCOM_GETPSM_TYPE_UE;
size = sizeof(struct apicmd_cmddat_getpsm_v4_s);
*altcid = APICMDID_GET_PSM_V4;
}
else
#endif
{
size = -ENOTSUP;
}
return size;
}
int32_t altcom_setpsm_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
int32_t size = 0;
FAR lte_psm_setting_t *settings = (FAR lte_psm_setting_t *)arg[0];
FAR struct apicmd_cmddat_setpsm_s *out =
(FAR struct apicmd_cmddat_setpsm_s *)pktbuf;
out->set.enable = settings->enable;
out->set.rat_time.unit = settings->req_active_time.unit;
out->set.rat_time.time_val = settings->req_active_time.time_val;
out->set.tau_time.unit = settings->ext_periodic_tau_time.unit;
out->set.tau_time.time_val = settings->ext_periodic_tau_time.time_val;
size = sizeof(struct apicmd_cmddat_setpsm_s);
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_SET_PSM;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_SET_PSM_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_getdpsm_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
int32_t size = 0;
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
size = 0;
*altcid = APICMDID_GET_DYNAMICPSM;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
FAR struct apicmd_cmddat_getpsm_v4_s *out =
(FAR struct apicmd_cmddat_getpsm_v4_s *)pktbuf;
out->type = ALTCOM_GETPSM_TYPE_NEGOTIATED;
size = sizeof(struct apicmd_cmddat_getpsm_v4_s);
*altcid = APICMDID_GET_PSM_V4;
}
else
#endif
{
size = -ENOTSUP;
}
return size;
}
int32_t altcom_getce_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
int32_t size = 0;
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_GET_CE;
}
else
#endif
{
size = -ENOTSUP;
}
return size;
}
int32_t altcom_setce_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
int32_t size = 0;
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
FAR lte_ce_setting_t *settings = (FAR lte_ce_setting_t *)arg[0];
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
FAR struct apicmd_cmddat_setce_s *out =
(FAR struct apicmd_cmddat_setce_s *)pktbuf;
out->mode_a_enable = (uint8_t)settings->mode_a_enable;
out->mode_b_enable = (uint8_t)settings->mode_b_enable;
size = sizeof(struct apicmd_cmddat_setce_s);
*altcid = APICMDID_SET_CE;
}
else
#endif
{
size = -ENOTSUP;
}
return size;
}
int32_t altcom_getedrx_pkt_parse(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)
{
FAR int *ret = (FAR int *)arg[0];
FAR lte_edrx_setting_t *settings = (FAR lte_edrx_setting_t *)arg[1];
FAR struct apicmd_cmddat_getedrxres_s *in =
(FAR struct apicmd_cmddat_getedrxres_s *)pktbuf;
FAR bool *is_getedrxevt = (FAR bool *)arg[2];
*is_getedrxevt = true;
*ret = (LTE_RESULT_OK == in->result) ? 0 : -EPROTO;
if (0 == *ret)
{
/* Checks and converts the eDRX value of the API command response. */
*ret = altcombs_convert_apicmd_edrx_value(&in->set, settings);
if (0 > *ret)
{
m_err("altcombs_convert_apicmd_edrx_value() failed: %ld\n", *ret);
*ret = -EFAULT;
}
}
return 0;
}
int32_t altcom_setedrx_pkt_parse(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)
{
FAR int *ret = (FAR int *)arg[0];
FAR struct apicmd_cmddat_setedrxres_s *in =
(FAR struct apicmd_cmddat_setedrxres_s *)pktbuf;
*ret = (LTE_RESULT_OK == in->result) ? 0 : -EPROTO;
return 0;
}
int32_t altcom_getdedrx_pkt_parse(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)
{
FAR int *ret = (FAR int *)arg[0];
FAR lte_edrx_setting_t *settings = (FAR lte_edrx_setting_t *)arg[1];
FAR struct apicmd_cmddat_getdynamicedrxres_s *in =
(FAR struct apicmd_cmddat_getdynamicedrxres_s *)pktbuf;
FAR bool *is_getdedrxevt = (FAR bool *)arg[2];
*is_getdedrxevt = true;
*ret = (LTE_RESULT_OK == in->result) ? 0 : -EPROTO;
if (0 == *ret)
{
/* Checks and converts the eDRX value of the API command response. */
*ret = altcombs_convert_apicmd_edrx_value(&in->set, settings);
if (0 > *ret)
{
m_err("altcombs_convert_apicmd_edrx_value() failed: %ld\n", *ret);
*ret = -EFAULT;
}
}
return 0;
}
int32_t altcom_getpsm_pkt_parse(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)
{
FAR int *ret = (FAR int *)arg[0];
FAR lte_psm_setting_t *settings = (FAR lte_psm_setting_t *)arg[1];
FAR bool *is_getpsmevt = (FAR bool *)arg[2];
FAR struct apicmd_cmddat_getpsmres_s *in =
(FAR struct apicmd_cmddat_getpsmres_s *)pktbuf;
*is_getpsmevt = true;
*ret = (LTE_RESULT_OK == in->result) ? 0 : -EPROTO;
if (0 == *ret)
{
/* Parse PSM settings */
*ret = altcombs_set_psm(&in->set, settings);
if (0 > *ret)
{
m_err("altcombs_set_psm() failed: %ld\n", *ret);
*ret = -EFAULT;
}
}
return 0;
}
int32_t altcom_setpsm_pkt_parse(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)
{
FAR int *ret = (FAR int *)arg[0];
FAR struct apicmd_cmddat_setpsmres_s *in =
(FAR struct apicmd_cmddat_setpsmres_s *)pktbuf;
*ret = (LTE_RESULT_OK == in->result) ? 0 : -EPROTO;
return 0;
}
int32_t altcom_getdpsm_pkt_parse(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)
{
FAR int *ret = (FAR int *)arg[0];
FAR lte_psm_setting_t *settings = (FAR lte_psm_setting_t *)arg[1];
FAR struct apicmd_cmddat_getdynamicpsmres_s *in =
(FAR struct apicmd_cmddat_getdynamicpsmres_s *)pktbuf;
FAR bool *is_getcpsmevt = (FAR bool *)arg[2];
*is_getcpsmevt = true;
*ret = (LTE_RESULT_OK == in->result) ? 0 : -EPROTO;
if (0 == *ret)
{
/* Parse PSM settings */
*ret = altcombs_set_psm(&in->set, settings);
if (0 > *ret)
{
m_err("altcombs_set_psm() failed: %ld\n", *ret);
*ret = -EFAULT;
}
}
return 0;
}
int32_t altcom_getce_pkt_parse(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)
{
FAR int *ret = (FAR int *)arg[0];
FAR lte_ce_setting_t *settings = (FAR lte_ce_setting_t *)arg[1];
FAR struct apicmd_cmddat_getceres_s *in =
(FAR struct apicmd_cmddat_getceres_s *)pktbuf;
*ret = (LTE_RESULT_OK == in->result) ? 0 : -EPROTO;
if (0 == *ret)
{
/* Parse CE settings */
getce_parse_response(in, settings);
}
return 0;
}
int32_t altcom_setce_pkt_parse(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)
{
FAR int *ret = (FAR int *)arg[0];
FAR struct apicmd_cmddat_setceres_s *in =
(FAR struct apicmd_cmddat_setceres_s *)pktbuf;
*ret = (LTE_RESULT_OK == in->result) ? 0 : -EPROTO;
return 0;
}

View file

@ -0,0 +1,95 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_hdlr_psave.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_PSAVE_H
#define __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_PSAVE_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <stdint.h>
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
int32_t altcom_getedrx_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_setedrx_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_getdedrx_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_getpsm_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_setpsm_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_getdpsm_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_getce_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_setce_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_getedrx_pkt_parse(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);
int32_t altcom_setedrx_pkt_parse(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);
int32_t altcom_getdedrx_pkt_parse(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);
int32_t altcom_getpsm_pkt_parse(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);
int32_t altcom_setpsm_pkt_parse(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);
int32_t altcom_getdpsm_pkt_parse(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);
int32_t altcom_getce_pkt_parse(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);
int32_t altcom_setce_pkt_parse(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);
#endif /* __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_PSAVE_H */

View file

@ -0,0 +1,121 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_hdlr_radio.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 <stdint.h>
#include <stddef.h>
#include <string.h>
#include <errno.h>
#include <arpa/inet.h>
#include <nuttx/modem/alt1250.h>
#include <nuttx/wireless/lte/lte.h>
#include "altcom_cmd.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int32_t altcom_radioon_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
int32_t size = 0;
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_RADIO_ON;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_RADIO_ON_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_radiooff_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
int32_t size = 0;
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_RADIO_OFF;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_RADIO_OFF_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_radioon_pkt_parse(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)
{
FAR int *ret = (FAR int *)arg[0];
FAR struct apicmd_cmddat_radioonres_s *in =
(FAR struct apicmd_cmddat_radioonres_s *)pktbuf;
*ret = (LTE_RESULT_OK == in->result) ? 0 : -EPROTO;
return 0;
}
int32_t altcom_radiooff_pkt_parse(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)
{
FAR int *ret = (FAR int *)arg[0];
FAR struct apicmd_cmddat_radiooffres_s *in =
(FAR struct apicmd_cmddat_radiooffres_s *)pktbuf;
*ret = (LTE_RESULT_OK == in->result) ? 0 : -EPROTO;
return 0;
}

View file

@ -0,0 +1,53 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_hdlr_radio.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_RADIO_H
#define __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_RADIO_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <stdint.h>
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
int32_t altcom_radioon_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_radiooff_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_radioon_pkt_parse(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);
int32_t altcom_radiooff_pkt_parse(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);
#endif /* __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_RADIO_H */

View file

@ -0,0 +1,300 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_hdlr_sim.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 <stdint.h>
#include <stddef.h>
#include <string.h>
#include <errno.h>
#include <arpa/inet.h>
#include <nuttx/modem/alt1250.h>
#include <nuttx/wireless/lte/lte.h>
#include "altcom_cmd.h"
/****************************************************************************
* Private Functions
****************************************************************************/
static void getsiminfo_parse_response(
FAR struct apicmd_cmddat_getsiminfo_res_s *resp,
FAR lte_siminfo_t *siminfo)
{
siminfo->option = ntohl(resp->option);
if (siminfo->option & LTE_SIMINFO_GETOPT_MCCMNC)
{
if (LTE_MNC_DIGIT_MAX < resp->mnc_digit)
{
resp->mnc_digit = LTE_MNC_DIGIT_MAX;
}
memcpy(siminfo->mcc, resp->mcc, LTE_MCC_DIGIT);
siminfo->mnc_digit = resp->mnc_digit;
memcpy(siminfo->mnc, resp->mnc, resp->mnc_digit);
}
if (siminfo->option & LTE_SIMINFO_GETOPT_SPN)
{
if (LTE_SIMINFO_SPN_LEN < resp->spn_len)
{
resp->spn_len = LTE_SIMINFO_SPN_LEN;
}
siminfo->spn_len = resp->spn_len;
memcpy(siminfo->spn, resp->spn, resp->spn_len);
}
if (siminfo->option & LTE_SIMINFO_GETOPT_ICCID)
{
if (LTE_SIMINFO_ICCID_LEN < resp->iccid_len)
{
resp->iccid_len = LTE_SIMINFO_ICCID_LEN;
}
siminfo->iccid_len = resp->iccid_len;
memcpy(siminfo->iccid, resp->iccid, resp->iccid_len);
}
if (siminfo->option & LTE_SIMINFO_GETOPT_IMSI)
{
if (LTE_SIMINFO_IMSI_LEN < resp->imsi_len)
{
resp->imsi_len = LTE_SIMINFO_IMSI_LEN;
}
siminfo->imsi_len = resp->imsi_len;
memcpy(siminfo->imsi, resp->imsi, resp->imsi_len);
}
if (siminfo->option & LTE_SIMINFO_GETOPT_GID1)
{
if (LTE_SIMINFO_GID_LEN < resp->gid1_len)
{
resp->gid1_len = LTE_SIMINFO_GID_LEN;
}
siminfo->gid1_len = resp->gid1_len;
memcpy(siminfo->gid1, resp->gid1, resp->gid1_len);
}
if (siminfo->option & LTE_SIMINFO_GETOPT_GID2)
{
if (LTE_SIMINFO_GID_LEN < resp->gid2_len)
{
resp->gid2_len = LTE_SIMINFO_GID_LEN;
}
siminfo->gid2_len = resp->gid2_len;
memcpy(siminfo->gid2, resp->gid2, resp->gid2_len);
}
}
/****************************************************************************
* Public Functions
****************************************************************************/
int32_t altcom_getphone_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
int32_t size = 0;
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_GET_PHONENO;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_GET_PHONENO_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_getimsi_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
int32_t size = 0;
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_GET_IMSI;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_GET_IMSI_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_getsiminfo_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid)
{
int32_t size = 0;
FAR uint32_t *option = (FAR uint32_t *)arg[0];
FAR struct apicmd_cmddat_getsiminfo_s *out =
(FAR struct apicmd_cmddat_getsiminfo_s *)pktbuf;
out->option = htonl(*option);
size = sizeof(struct apicmd_cmddat_getsiminfo_s);
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV1
if (altver == ALTCOM_VER1)
{
*altcid = APICMDID_GET_SIMINFO;
}
else
#endif
#ifndef CONFIG_MODEM_ALT1250_DISABLE_PV4
if (altver == ALTCOM_VER4)
{
*altcid = APICMDID_GET_SIMINFO_V4;
}
else
#endif
{
size = -ENOSYS;
}
return size;
}
int32_t altcom_getphone_pkt_parse(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)
{
FAR int *ret = (FAR int *)arg[0];
FAR uint8_t *errcause = (FAR uint8_t *)arg[1];
FAR char *phoneno = (FAR char *)arg[2];
FAR struct apicmd_cmddat_phonenores_s *in =
(FAR struct apicmd_cmddat_phonenores_s *)pktbuf;
*ret = (LTE_RESULT_OK == in->result) ? 0 : -EPROTO;
*errcause = in->errcause;
if (0 == *ret)
{
if (arglen > 3)
{
FAR size_t *len = (FAR size_t *)arg[3];
/* Is it enough length to include Null terminate?
* The length of LTE_PHONENO_LEN includes the
* null terminator.
*/
if (*len < strnlen((FAR const char *)in->phoneno,
LTE_PHONENO_LEN))
{
return -ENOBUFS;
}
}
strncpy(phoneno, (FAR const char *)in->phoneno, LTE_PHONENO_LEN);
}
return 0;
}
int32_t altcom_getimsi_pkt_parse(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)
{
FAR int *ret = (FAR int *)arg[0];
FAR uint8_t *errcause = (FAR uint8_t *)arg[1];
FAR char *imsi = (FAR char *)arg[2];
FAR struct apicmd_cmddat_getimsires_s *in =
(FAR struct apicmd_cmddat_getimsires_s *)pktbuf;
*ret = (LTE_RESULT_OK == in->result) ? 0 : -EPROTO;
*errcause = in->errcause;
if (0 == *ret)
{
if (arglen > 3)
{
FAR size_t *len = (FAR size_t *)arg[3];
/* Is it enough length to include Null terminate?
* The length of LTE_IMSI_LEN includes the null terminator.
*/
if (*len < strnlen((FAR const char *)in->imsi, LTE_IMSI_LEN))
{
return -ENOBUFS;
}
}
strncpy(imsi, (FAR const char *)in->imsi, LTE_IMSI_LEN);
}
return 0;
}
int32_t altcom_getsiminfo_pkt_parse(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)
{
FAR int *ret = (FAR int *)arg[0];
FAR lte_siminfo_t *siminfo = (FAR lte_siminfo_t *)arg[1];
FAR struct apicmd_cmddat_getsiminfo_res_s *in =
(FAR struct apicmd_cmddat_getsiminfo_res_s *)pktbuf;
*ret = (LTE_RESULT_OK == in->result) ? 0 : -EPROTO;
if (0 == *ret)
{
/* Parse SIM information */
getsiminfo_parse_response(in, siminfo);
}
return 0;
}

View file

@ -0,0 +1,61 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_hdlr_sim.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_SIM_H
#define __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_SIM_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <stdint.h>
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
int32_t altcom_getphone_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_getimsi_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_getsiminfo_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_getphone_pkt_parse(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);
int32_t altcom_getimsi_pkt_parse(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);
int32_t altcom_getsiminfo_pkt_parse(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);
#endif /* __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_SIM_H */

View file

@ -0,0 +1,314 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_hdlr_sms.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 <stdint.h>
#include <stddef.h>
#include <string.h>
#include <errno.h>
#include <arpa/inet.h>
#include "altcom_cmd_sms.h"
#include "altcom_errno.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int32_t altcom_smsinit_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
FAR struct apicmd_sms_init_req_s *out =
(FAR struct apicmd_sms_init_req_s *)pktbuf;
*altcid = APICMDID_SMS_INIT;
out->types = ALTCOM_SMS_MSG_TYPE_SEND | ALTCOM_SMS_MSG_TYPE_RECV |
ALTCOM_SMS_MSG_TYPE_DELIVER_REPORT;
out->storage_use = 1; /* always use storage */
return sizeof(struct apicmd_sms_init_req_s);
}
int32_t altcom_smsfin_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
*altcid = APICMDID_SMS_FIN;
return 0;
}
int32_t altcom_smssend_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid)
{
int32_t size = 0;
int i;
FAR struct apicmd_sms_send_req_s *out =
(FAR struct apicmd_sms_send_req_s *)pktbuf;
FAR struct sms_send_msg_s *msg = (FAR struct sms_send_msg_s *)arg[0];
uint16_t msglen = *((FAR uint16_t *)arg[1]);
bool en_status_report = *((FAR bool *)arg[2]);
FAR struct sms_sc_addr_s *scaddr = (FAR struct sms_sc_addr_s *)arg[3];
uint8_t chset = *((FAR uint8_t *)arg[4]);
FAR uint8_t *dest_toa = (FAR uint8_t *)arg[5];
if (msglen > pktsz)
{
return -ENOBUFS;
}
if ((msg->header.destaddrlen % 2) || (msg->header.datalen % 2) ||
(msg->header.destaddrlen > (SMS_MAX_ADDRLEN * 2)) ||
(msg->header.datalen > (SMS_MAX_DATALEN * 2)) ||
(scaddr->addrlen % 2) || (scaddr->addrlen > (SMS_MAX_ADDRLEN * 2)))
{
/* destaddrlen and datalen must be even numbers */
return -EINVAL;
}
out->sc_addr.toa = scaddr->toa;
out->sc_addr.length = scaddr->addrlen;
/* Swap sc address */
for (i = 0; i < (scaddr->addrlen / 2); i++)
{
out->sc_addr.address[i] = htons(scaddr->addr[i]);
}
out->valid_indicator = ALTCOM_SMS_MSG_VALID_UD;
out->valid_indicator |= en_status_report ? ALTCOM_SMS_MSG_VALID_SRR : 0;
out->dest_addr.toa = (dest_toa == NULL) ? 0 : *dest_toa;
out->dest_addr.length = msg->header.destaddrlen;
/* Swap destination address */
for (i = 0; i < (msg->header.destaddrlen / 2); i++)
{
out->dest_addr.address[i] = htons(msg->header.destaddr[i]);
}
switch (chset)
{
case SMS_CHSET_UCS2:
chset = ALTCOM_SMS_CHSET_UCS2;
break;
case SMS_CHSET_GSM7:
chset = ALTCOM_SMS_CHSET_GSM7;
break;
case SMS_CHSET_BINARY:
chset = ALTCOM_SMS_CHSET_BINARY;
break;
default:
return -EINVAL;
}
out->userdata.chset = ALTCOM_SMS_CHSET_UCS2;
out->userdata.data_len = htons(msg->header.datalen);
/* Swap data */
for (i = 0; i < (msg->header.datalen / 2); i++)
{
out->user_data[i] = htons(msg->data[i]);
}
*altcid = APICMDID_SMS_SEND;
size = sizeof(struct apicmd_sms_send_req_s) + msg->header.datalen;
return size;
}
int32_t altcom_smsdelete_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid)
{
FAR struct apicmd_sms_delete_s *out =
(FAR struct apicmd_sms_delete_s *)pktbuf;
uint16_t msg_index = *(FAR uint16_t *)arg[0];
*altcid = APICMDID_SMS_DELETE;
out->index = htons(msg_index);
out->types = 0;
return sizeof(struct apicmd_sms_delete_s);
}
int32_t altcom_smsreportrecv_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid)
{
FAR struct apicmd_sms_res_s *out =
(FAR struct apicmd_sms_res_s *)pktbuf;
*altcid = APICMDID_SMS_REPORT_RECV | ALTCOM_CMDID_REPLY_BIT;
out->result = htonl(0); /* always success */
return sizeof(struct apicmd_sms_res_s);
}
int32_t altcom_smscommon_pkt_parse(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)
{
FAR struct apicmd_sms_res_s *in =
(FAR struct apicmd_sms_res_s *)pktbuf;
return altcom_geterrcode(in->result);
}
int32_t altcom_smssend_pkt_parse(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)
{
FAR struct apicmd_sms_sendres_s *in =
(FAR struct apicmd_sms_sendres_s *)pktbuf;
FAR struct sms_refids_s *refid = (FAR struct sms_refids_s *)arg[0];
uint16_t msglen = *((FAR uint16_t *)arg[1]);
int32_t sendresult = altcom_geterrcode(in->result);
if (sendresult >= 0)
{
refid->nrefid = in->mr_num;
memcpy(refid->refid, in->mr_list, sizeof(refid->refid));
}
return (sendresult < 0) ? sendresult : msglen;
}
int32_t altcom_smsreportrecv_pkt_parse(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)
{
int i;
FAR struct apicmd_sms_reprecv_s *in =
(FAR struct apicmd_sms_reprecv_s *)pktbuf;
FAR uint16_t *msg_index = (FAR uint16_t *)arg[0];
FAR uint16_t *msg_sz = (FAR uint16_t *)arg[1];
FAR uint8_t *maxnum = (FAR uint8_t *)arg[2];
FAR uint8_t *seqnum = (FAR uint8_t *)arg[3];
FAR struct sms_recv_msg_header_s *msgheader =
(FAR struct sms_recv_msg_header_s *)arg[4];
*msg_index = ntohs(in->index);
*maxnum = 0;
*seqnum = 0;
if (in->msg.type == ALTCOM_SMS_MSG_TYPE_RECV)
{
FAR struct sms_deliver_msg_s *deliver =
(FAR struct sms_deliver_msg_s *)arg[4];
*msg_sz = sizeof(struct sms_deliver_msg_s) +
ntohs(in->msg.u.recv.userdata.data_len);
if (in->msg.u.recv.valid_indicator & ALTCOM_SMS_MSG_VALID_CONCAT_HDR)
{
*maxnum = in->msg.u.recv.concat_hdr.max_num;
*seqnum = in->msg.u.recv.concat_hdr.seq_num;
}
msgheader->msgtype = SMS_MSG_TYPE_DELIVER;
memcpy(&msgheader->send_time, &in->msg.u.recv.sc_time,
sizeof(msgheader->send_time));
msgheader->srcaddrlen = in->msg.u.recv.src_addr.length;
if (msgheader->srcaddrlen > SMS_MAX_ADDRLEN * 2)
{
m_err("Unexpected src addrlen: %u\n", msgheader->srcaddrlen);
return -EINVAL;
}
/* Swap source address */
for (i = 0; i < (msgheader->srcaddrlen / 2); i++)
{
msgheader->srcaddr[i] = ntohs(in->msg.u.recv.src_addr.address[i]);
}
msgheader->datalen = ntohs(in->msg.u.recv.userdata.data_len);
if (msgheader->datalen > (SMS_MAX_DATALEN * 2))
{
m_err("Unexpected datalen: %u\n", msgheader->datalen);
return -EINVAL;
}
/* Swap data */
for (i = 0; i < (msgheader->datalen / 2); i++)
{
deliver->data[i] = ntohs(in->msg.u.recv.user_data[i]);
}
m_info("[recv msg] msg size: %u\n", *msg_sz);
m_info(" maxnum: %u, seqnum: %u\n", *maxnum, *seqnum);
m_info(" msgtype: %u\n", msgheader->msgtype);
m_info(" srcaddrlen: %u\n", msgheader->srcaddrlen);
m_info(" datalen: %u\n", msgheader->datalen);
}
else if (in->msg.type == ALTCOM_SMS_MSG_TYPE_DELIVER_REPORT)
{
FAR struct sms_status_report_msg_s *report =
(FAR struct sms_status_report_msg_s *)arg[4];
*msg_sz = sizeof(struct sms_status_report_msg_s);
msgheader->msgtype = SMS_MSG_TYPE_STATUS_REPORT;
memcpy(&msgheader->send_time, &in->msg.u.delivery_report.sc_time,
sizeof(msgheader->send_time));
msgheader->srcaddrlen = 0;
memset(msgheader->srcaddr, 0, sizeof(msgheader->srcaddr));
msgheader->datalen = sizeof(struct sms_status_report_s);
report->status_report.refid = in->msg.u.delivery_report.ref_id;
report->status_report.status = in->msg.u.delivery_report.status;
memcpy(&report->status_report.discharge_time,
&in->msg.u.delivery_report.discharge_time,
sizeof(report->status_report.discharge_time));
m_info("[staus report] msg size: %u\n", *msg_sz);
m_info(" msgtype: %u\n", msgheader->msgtype);
m_info(" datalen: %u\n", msgheader->datalen);
m_info(" refid: %u\n", report->status_report.refid);
m_info(" status: %u\n", report->status_report.status);
}
else
{
return -EINVAL;
}
return 0;
}

View file

@ -0,0 +1,67 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_hdlr_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_HDLR_SMS_H
#define __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_SMS_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <stdint.h>
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
int32_t altcom_smsinit_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_smsfin_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_smssend_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_smsdelete_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_smsreportrecv_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_smscommon_pkt_parse(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);
int32_t altcom_smssend_pkt_parse(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);
int32_t altcom_smsreportrecv_pkt_parse(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);
#endif /* __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_SMS_H */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,101 @@
/****************************************************************************
* drivers/modem/alt1250/altcom_hdlr_socket.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_SOCKET_H
#define __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_SOCKET_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <stdint.h>
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
int32_t altcom_socket_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_close_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_accept_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_bind_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_connect_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_fcntl_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_getsockname_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_getsockopt_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_listen_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_recvfrom_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_sendto_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_setsockopt_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz,
FAR uint16_t *altcid);
int32_t altcom_select_pkt_compose(FAR void **arg, size_t arglen,
uint8_t altver, FAR uint8_t *pktbuf,
const size_t pktsz, FAR uint16_t *altcid);
int32_t altcom_sockcomm_pkt_parse(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);
int32_t altcom_scokaddr_pkt_parse(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);
int32_t altcom_getsockopt_pkt_parse(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);
int32_t altcom_recvfrom_pkt_parse(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);
int32_t altcom_select_pkt_parse(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);
#endif /* __DRIVERS_MODEM_ALT1250_ALTCOM_HDLR_SOCKET_H */

View file

@ -131,7 +131,7 @@ 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);
return ntohs(pkt->cmdid);
}
static inline uint16_t parse_tid4errind(FAR struct altcom_cmdhdr_s *hdr)
@ -139,7 +139,7 @@ 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);
return ntohs(pkt->transid);
}
static inline FAR uint8_t *get_payload(FAR struct altcom_cmdhdr_s *hdr)

View file

@ -45,15 +45,6 @@
* Pre-processor Definitions
****************************************************************************/
#define EVENT_POWERON (1 << 0)
#define EVENT_POWEROFF (1 << 1)
#define EVENT_RESET (1 << 2)
#define EVENT_WLOCK (1 << 3)
#define EVENT_TXREQ (1 << 4)
#define EVENT_RXREQ (1 << 5)
#define EVENT_TXSUSTO (1 << 6)
#define EVENT_DESTROY (1 << 7)
#define TX_DONE (1 << 0)
#define TX_CANCEL (1 << 1)
@ -147,6 +138,7 @@ typedef struct altmdm_dev_s
int txreq_size;
int is_destroy;
uint32_t reset_reason;
int retry_mode;
} altmdm_dev_t;
/****************************************************************************
@ -162,6 +154,7 @@ static int next_state_idle4rst(altmdm_state_t);
static int next_state_idlewto(altmdm_state_t);
static int next_state_idlewoto(altmdm_state_t);
static int next_state_idlewotx(altmdm_state_t);
static int next_state_hdrsreq(altmdm_state_t state);
static int next_state_decidedelay(altmdm_state_t);
static int next_state_destroy(altmdm_state_t);
@ -175,6 +168,7 @@ static uint32_t waitevt_state_idlewto(void);
static uint32_t waitevt_state_idlewoto(void);
static uint32_t waitevt_state_idlewotx(void);
static uint32_t waitevt_state_hdrsreq(void);
static uint32_t waitevt_state_gotsleep(void);
static uint32_t waitevt_state_bodysreq(void);
static uint32_t waitevt_state_sleeping(void);
static uint32_t waitevt_state_delaynext(void);
@ -249,14 +243,14 @@ static const struct state_func_s g_state_func[] =
TABLE_CONTENT(SLEEPSET, common, common, sleepset),
TABLE_CONTENT(TXPREPARE, common, common, txprepare),
TABLE_CONTENT(TXREQ, common, common, txreq),
TABLE_CONTENT(HDRSREQ, common, hdrsreq, hdrsreq),
TABLE_CONTENT(HDRSREQ, hdrsreq, hdrsreq, hdrsreq),
TABLE_CONTENT(HDRTRX, common, common, hdrtrx),
TABLE_CONTENT(SLEEPPKT, common, common, sleeppkt),
TABLE_CONTENT(BODYSREQ, common, bodysreq, bodysreq),
TABLE_CONTENT(BODYTRX, common, common, bodytrx),
TABLE_CONTENT(GOTRX, common, common, gotrx),
TABLE_CONTENT(GOTRST, common, common, gotrst),
TABLE_CONTENT(GOTSLEEP, common, common, gotsleep),
TABLE_CONTENT(GOTSLEEP, common, gotsleep, gotsleep),
TABLE_CONTENT(BACKTOIDLE, common, common, backtoidle),
TABLE_CONTENT(RETRECV, common, common, retrecv),
TABLE_CONTENT(FORCERST, common, common, forcerst),
@ -418,7 +412,8 @@ static void process_before_poweroff(void)
/* clear event without EVENT_POWERON */
altmdm_event_clear(&g_altmdm_dev.event, (allevt & ~(EVENT_POWERON)));
altmdm_event_clear(&g_altmdm_dev.event,
(allevt & ~(EVENT_POWERON | EVENT_DESTROY)));
g_altmdm_dev.lower->irqenable(false);
g_altmdm_dev.lower->set_wakeup(false);
g_altmdm_dev.lower->set_mready(false);
@ -475,7 +470,7 @@ static int next_state_poweroff(altmdm_state_t state)
static uint32_t waitevt_state_poweroff(void)
{
return altmdm_event_wait(&g_altmdm_dev.event,
EVENT_POWERON | EVENT_DESTROY, false, 0);
EVENT_POWERON | EVENT_DESTROY | EVENT_SUSPEND | EVENT_RESUME, false, 0);
}
static altmdm_state_t process_state_poweroff(uint32_t event,
@ -488,7 +483,7 @@ static altmdm_state_t process_state_poweroff(uint32_t event,
altmdm_event_clear(&g_altmdm_dev.event, EVENT_DESTROY);
state = ALTMDM_STATE_DESTORY;
}
else if (event & EVENT_POWERON)
else if (event & (EVENT_POWERON | EVENT_SUSPEND | EVENT_RESUME))
{
altmdm_event_clear(&g_altmdm_dev.event, EVENT_POWERON);
usec2timespec(RESET_INTERVAL, &interval);
@ -510,8 +505,16 @@ static altmdm_state_t process_state_poweroff(uint32_t event,
static int next_state_sleep(altmdm_state_t state)
{
uint32_t evt = altmdm_event_refer(&g_altmdm_dev.event);
g_altmdm_dev.lower->set_wakeup(false);
if ((evt & EVENT_SUSPEND) != 0)
{
set_return_code(ALTMDM_RETURN_SUSPENDED);
return 1;
}
return 0;
}
@ -526,7 +529,7 @@ static uint32_t waitevt_state_sleep(void)
event = altmdm_event_wait(&g_altmdm_dev.event,
EVENT_TXREQ | EVENT_RXREQ | EVENT_WLOCK | EVENT_POWEROFF | EVENT_RESET |
EVENT_DESTROY, false, 0);
EVENT_DESTROY | EVENT_SUSPEND, false, 0);
return event;
}
@ -534,6 +537,10 @@ static uint32_t waitevt_state_sleep(void)
static altmdm_state_t process_state_sleep(uint32_t event,
altmdm_state_t state)
{
/* The order of checking the events is related to processing
* priority, so be careful when making changes.
*/
if (event & EVENT_DESTROY)
{
altmdm_event_clear(&g_altmdm_dev.event, EVENT_DESTROY);
@ -553,6 +560,10 @@ static altmdm_state_t process_state_sleep(uint32_t event,
{
state = ALTMDM_STATE_IDLE4RST;
}
else if (event & EVENT_SUSPEND)
{
state = ALTMDM_STATE_SLEEP;
}
else if (event & (EVENT_TXREQ | EVENT_RXREQ))
{
state = ALTMDM_STATE_IDLEWTO;
@ -719,13 +730,17 @@ static uint32_t waitevt_state_idlewto(void)
{
return altmdm_event_wait(&g_altmdm_dev.event,
EVENT_TXREQ | EVENT_RXREQ | EVENT_WLOCK |
EVENT_POWEROFF | EVENT_RESET | EVENT_DESTROY,
EVENT_POWEROFF | EVENT_RESET | EVENT_DESTROY | EVENT_SUSPEND,
false, TIMEOUT_IDELEWTO_STATE);
}
static altmdm_state_t process_state_idlewto(uint32_t event,
altmdm_state_t state)
{
/* The order of checking the events is related to processing
* priority, so be careful when making changes.
*/
if (event & EVENT_DESTROY)
{
altmdm_event_clear(&g_altmdm_dev.event, EVENT_DESTROY);
@ -741,6 +756,10 @@ static altmdm_state_t process_state_idlewto(uint32_t event,
altmdm_event_clear(&g_altmdm_dev.event, EVENT_RESET);
state = ALTMDM_STATE_FORCERST;
}
else if (event & EVENT_SUSPEND)
{
state = ALTMDM_STATE_SLEEPSET;
}
else if (event & EVENT_TXREQ)
{
state = ALTMDM_STATE_TXPREPARE;
@ -972,6 +991,26 @@ static altmdm_state_t process_state_txreq(uint32_t event,
* HDRSREQ state
****************************************************************************/
static int next_state_hdrsreq(altmdm_state_t state)
{
uint32_t evt = altmdm_event_refer(&g_altmdm_dev.event);
if (get_vp() == VP_V4)
{
g_altmdm_dev.retry_mode = (evt & EVENT_RETRYREQ) ? 1 : 0;
if (g_altmdm_dev.retry_mode)
{
altmdm_set_retrypkt(&g_altmdm_dev.tx_pkt);
}
}
else
{
g_altmdm_dev.retry_mode = 0;
}
return 0;
}
static uint32_t waitevt_state_hdrsreq(void)
{
return altmdm_event_wait(&g_altmdm_dev.event,
@ -1032,9 +1071,20 @@ static altmdm_state_t process_state_hdrtrx(uint32_t event,
else
{
m_err("[altmdm] Header error. Current State is %d\n", state);
state = ALTMDM_STATE_FORCERST;
if (g_altmdm_dev.retry_mode)
{
state = ALTMDM_STATE_POWEROFF;
}
else
{
state = ALTMDM_STATE_FORCERST;
}
}
}
else if (is_reset_pkt(&g_altmdm_dev.rx_pkt) && g_altmdm_dev.retry_mode)
{
state = ALTMDM_STATE_POWEROFF;
}
else if (is_sleep_pkt(&g_altmdm_dev.tx_pkt))
{
state = ALTMDM_STATE_SLEEPPKT;
@ -1129,7 +1179,8 @@ static altmdm_state_t process_state_bodytrx(uint32_t event,
{
state = ALTMDM_STATE_GOTSLEEP;
}
else if (pkt_total_size(&g_altmdm_dev.rx_pkt) != 0)
else if (pkt_total_size(&g_altmdm_dev.rx_pkt) != 0 &&
g_altmdm_dev.retry_mode == 0)
{
state = ALTMDM_STATE_GOTRX;
}
@ -1230,16 +1281,39 @@ static altmdm_state_t process_state_gotrst(uint32_t event,
* GOTSLEEP state
****************************************************************************/
static altmdm_state_t process_state_gotsleep(uint32_t event,
altmdm_state_t state)
static uint32_t waitevt_state_gotsleep(void)
{
if (altmdm_is_sleeppkt_ok(&g_altmdm_dev.rx_pkt))
uint32_t evt = altmdm_event_refer(&g_altmdm_dev.event);
/* GOTSLEEP state only check current event flags for SUSPEND. */
if ((evt & EVENT_SUSPEND) != 0)
{
state = ALTMDM_STATE_SLEEPING;
return EVENT_SUSPEND;
}
else
{
state = ALTMDM_STATE_DECIDEDELAY;
return 0;
}
}
static altmdm_state_t process_state_gotsleep(uint32_t event,
altmdm_state_t state)
{
if (event & EVENT_SUSPEND)
{
state = ALTMDM_STATE_SLEEP;
}
else
{
if (altmdm_is_sleeppkt_ok(&g_altmdm_dev.rx_pkt))
{
state = ALTMDM_STATE_SLEEPING;
}
else
{
state = ALTMDM_STATE_DECIDEDELAY;
}
}
return state;
@ -1445,48 +1519,46 @@ int altmdm_init(FAR struct spi_dev_s *spidev,
g_altmdm_dev.rx_retcode = 0;
g_altmdm_dev.txreq_buff = NULL;
g_altmdm_dev.txreq_size = 0;
g_altmdm_dev.current_state = ALTMDM_STATE_POWEROFF;
g_altmdm_dev.vp = VP_NO_RESET;
g_altmdm_dev.retry_mode = 0;
lower->irqattach(sready_isr);
next_state_poweroff(g_altmdm_dev.current_state);
if (altmdm_get_powersupply(lower))
{
/* When the ALT1250 is turned on during initialization,
* it means that the ALT1250 has returned from hibernation.
* After recovery, ALTMDM state is Sleep.
* And this function is supported only when the protocol
* version is PV4.
*/
g_altmdm_dev.current_state = ALTMDM_STATE_SLEEP;
g_altmdm_dev.vp = VP_V4;
g_altmdm_dev.spidev = g_altmdm_dev.lower->poweron();
g_altmdm_dev.lower->set_mready(false);
g_altmdm_dev.lower->set_wakeup(false);
g_altmdm_dev.lower->irqenable(true);
altmdm_set_pm_event(EVENT_RETRYREQ, true);
next_state_sleep(g_altmdm_dev.current_state);
}
else
{
g_altmdm_dev.current_state = ALTMDM_STATE_POWEROFF;
g_altmdm_dev.vp = VP_NO_RESET;
next_state_poweroff(g_altmdm_dev.current_state);
}
return 0;
}
int altmdm_fin(void)
{
int ret = OK;
uint32_t evt;
altmdm_event_set(&g_altmdm_dev.event, EVENT_DESTROY);
nxsem_wait_uninterruptible(&g_altmdm_dev.lock_evt);
evt = altmdm_event_refer(&g_altmdm_dev.event);
/* Is already accepted DESTROY request? */
if (evt & EVENT_DESTROY)
{
ret = -EALREADY;
}
/* Is in DESTROY state? */
if (g_altmdm_dev.current_state == ALTMDM_STATE_DESTORY)
{
ret = -EALREADY;
}
if (ret == OK)
{
altmdm_event_set(&g_altmdm_dev.event, EVENT_DESTROY);
}
nxsem_post(&g_altmdm_dev.lock_evt);
return ret;
return OK;
}
int altmdm_poweron(void)
@ -1577,6 +1649,17 @@ int altmdm_poweroff(void)
return ret;
}
bool altmdm_get_powersupply(FAR const struct alt1250_lower_s *lower)
{
if (!lower || !lower->powerstatus)
{
m_err("Lower driver not registered.\n");
return false;
}
return lower->powerstatus();
}
int altmdm_reset(void)
{
nxsem_wait_uninterruptible(&g_altmdm_dev.lock_evt);
@ -1622,11 +1705,8 @@ int altmdm_read(FAR uint8_t *buff, int sz)
/* Going to next state */
if (next_state != g_altmdm_dev.current_state)
{
is_exit = g_state_func[next_state].goto_next(
g_altmdm_dev.current_state);
}
is_exit = g_state_func[next_state].goto_next(
g_altmdm_dev.current_state);
dump_current_all_status(&g_altmdm_dev, event, next_state, is_exit);
@ -1723,6 +1803,11 @@ int altmdm_give_wlock(void)
return cnt;
}
int altmdm_count_wlock(void)
{
return g_altmdm_dev.wcounter;
}
uint32_t altmdm_get_reset_reason(void)
{
return get_reset_reason();
@ -1740,4 +1825,16 @@ uint8_t altmdm_get_protoversion(void)
return (uint8_t)vp;
}
int altmdm_set_pm_event(uint32_t event, bool enable)
{
if (enable)
{
return altmdm_event_set(&g_altmdm_dev.event, event);
}
else
{
return altmdm_event_clear(&g_altmdm_dev.event, event);
}
}
#endif

View file

@ -33,12 +33,25 @@
* Pre-processor Definitions
****************************************************************************/
#define EVENT_POWERON (1 << 0)
#define EVENT_POWEROFF (1 << 1)
#define EVENT_RESET (1 << 2)
#define EVENT_WLOCK (1 << 3)
#define EVENT_TXREQ (1 << 4)
#define EVENT_RXREQ (1 << 5)
#define EVENT_TXSUSTO (1 << 6)
#define EVENT_DESTROY (1 << 7)
#define EVENT_SUSPEND (1 << 8)
#define EVENT_RESUME (1 << 9)
#define EVENT_RETRYREQ (1 << 10)
#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)
#define ALTMDM_RETURN_SUSPENDED (-7)
/****************************************************************************
* Public Function Prototypes
@ -151,6 +164,22 @@ int altmdm_take_wlock(void);
int altmdm_give_wlock(void);
/****************************************************************************
* Name: altmdm_count_wlock
*
* Description:
* Returns the count of wakelocks currently acquired.
*
* Input Parameters:
* None
*
* Returned Value:
* Returns the count of wakelocks currently acquired.
*
****************************************************************************/
int altmdm_count_wlock(void);
/****************************************************************************
* Name: altmdm_poweron
*
@ -185,6 +214,22 @@ int altmdm_poweron(void);
int altmdm_poweroff(void);
/****************************************************************************
* Name: altmdm_get_powersupply
*
* Description:
* Get the power supply status of the ALT1250.
*
* Input Parameters:
* Lower driver context
*
* Returned Value:
* Returns true on turned on, false is turned off.
*
****************************************************************************/
bool altmdm_get_powersupply(FAR const struct alt1250_lower_s *lower);
/****************************************************************************
* Name: altmdm_reset
*
@ -237,4 +282,22 @@ uint32_t altmdm_get_reset_reason(void);
uint8_t altmdm_get_protoversion(void);
/****************************************************************************
* Name: altmdm_set_pm_event
*
* Description:
* Set PM event flag for alt1250 receive thread..
*
* Input Parameters:
* event - Bitmap of the event to send/clear.
* enable - true: send, false: clear.
*
* Returned Value:
* Returns 0 on success.
* When an error occurs, a negative value is returned.
*
****************************************************************************/
int altmdm_set_pm_event(uint32_t event, bool enable);
#endif /* __DRIVERS_MODEM_ALT1250_ALTMDM_H */

View file

@ -87,6 +87,11 @@ void altmdm_set_sleeppkt(FAR altmdm_spipkt_t *pkt)
pkt->header |= ALTSPI_SLEEP_BIT;
}
void altmdm_set_retrypkt(FAR altmdm_spipkt_t *pkt)
{
pkt->header |= ALTSPI_BUFFFULL_BIT;
}
bool altmdm_is_valid_spipkt_header(FAR altmdm_spipkt_t *pkt)
{
uint16_t actual_size;

View file

@ -202,6 +202,22 @@ void altmdm_overwrite_body_size(FAR altmdm_spipkt_t *pkt, uint16_t sz);
void altmdm_set_sleeppkt(FAR altmdm_spipkt_t *pkt);
/****************************************************************************
* Name: altmdm_set_retrypkt
*
* Description:
* Set retry packet parameters to SPI packet structure.
*
* Input Parameters:
* pkt - Pointer to SPI packet structure.
*
* Returned Value:
* None
*
****************************************************************************/
void altmdm_set_retrypkt(FAR altmdm_spipkt_t *pkt);
/****************************************************************************
* Name: altmdm_is_valid_spipkt_header
*

View file

@ -58,8 +58,10 @@
#define ALT1250_IOC_SETEVTBUFF _MODEMIOC(3)
#define ALT1250_IOC_EXCHGCONTAINER _MODEMIOC(4)
#define ALT1250_EVTBIT_RESET (1ULL << 63)
#define ALT1250_EVTBIT_REPLY (1ULL << 62)
#define ALT1250_EVTBIT_RESET (1ULL << 63)
#define ALT1250_EVTBIT_REPLY (1ULL << 62)
#define ALT1250_EVTBIT_STOPAPI (1ULL << 61)
#define ALT1250_EVTBIT_SUSPEND (1ULL << 60)
/* Number of sockets */
@ -257,6 +259,7 @@
struct alt_power_s
{
uint32_t cmdid;
int resp;
};
typedef struct alt_container_s
@ -306,6 +309,8 @@ struct alt1250_lower_s
{
FAR struct spi_dev_s * (*poweron)(void);
void (*poweroff)(void);
bool (*powerstatus)(void);
int (*hiber_mode)(bool);
void (*reset)(void);
void (*irqattach)(xcpt_t handler);
void (*irqenable)(bool enable);
@ -339,7 +344,8 @@ struct alt1250_dev_s
mutex_t evtmaplock;
mutex_t pfdlock;
FAR struct pollfd *pfd;
pthread_t recvthread;
int rxthread_pid;
sem_t rxthread_sem;
FAR struct alt_evtbuffer_s *evtbuff;
uint32_t discardcnt;
mutex_t senddisablelock;

View file

@ -122,6 +122,10 @@
#define SIOCACANSTDFILTER _SIOC(0x0030) /* Add hardware-level standard ID filter */
#define SIOCDCANSTDFILTER _SIOC(0x0031) /* Delete hardware-level standard ID filter */
/* Network socket control ***************************************************/
#define SIOCDENYINETSOCK _SIOC(0x0033) /* Deny network socket. */
/****************************************************************************
* Public Type Definitions
****************************************************************************/

View file

@ -119,24 +119,6 @@
* Non-IP Data Delivery
*/
/* Internet protocol type: IP
* deprecated. Use LTE_IPTYPE_V4 instead.
*/
#define LTE_APN_IPTYPE_IP LTE_IPTYPE_V4
/* Internet protocol type: IPv6
* deprecated. Use LTE_IPTYPE_V6 instead.
*/
#define LTE_APN_IPTYPE_IPV6 LTE_IPTYPE_V6
/* Internet protocol type: IPv4/v6
* deprecated. Use LTE_IPTYPE_V4V6 instead.
*/
#define LTE_APN_IPTYPE_IPV4V6 LTE_IPTYPE_V4V6
#define LTE_APN_AUTHTYPE_NONE (0) /* PPP authentication type: NONE */
#define LTE_APN_AUTHTYPE_PAP (1) /* PPP authentication type: PAP */
#define LTE_APN_AUTHTYPE_CHAP (2) /* PPP authentication type: CHAP */
@ -213,18 +195,6 @@
#define LTE_VER_NP_PACKAGE_LEN (32)
/* Enable setting of PIN lock
* deprecated. Use LTE_ENABLE instead.
*/
#define LTE_PIN_ENABLE LTE_ENABLE
/* Disable setting of PIN lock
* deprecated. Use LTE_DISABLE instead.
*/
#define LTE_PIN_DISABLE LTE_DISABLE
/* PIN status: Not pending for any password */
#define LTE_PINSTAT_READY (0)
@ -333,18 +303,6 @@
#define LTE_MCC_DIGIT (3) /* Digit number of Mobile Country Code */
#define LTE_MNC_DIGIT_MAX (3) /* Max digit number of Mobile Network Code */
/* Digit number of mcc
* deprecated. Use LTE_MCC_DIGIT instead.
*/
#define LTE_CELLINFO_MCC_DIGIT LTE_MCC_DIGIT
/* Max digit number of mnc
* deprecated. Use LTE_MNC_DIGIT_MAX instead.
*/
#define LTE_CELLINFO_MNC_DIGIT_MAX LTE_MNC_DIGIT_MAX
#define LTE_EDRX_ACTTYPE_WBS1 (0) /* E-UTRAN (WB-S1 mode) */
#define LTE_EDRX_ACTTYPE_NBS1 (1) /* E-UTRAN (NB-S1 mode) */
#define LTE_EDRX_ACTTYPE_ECGSMIOT (2) /* EC-GSM-IoT (A/Gb mode) */
@ -485,6 +443,10 @@
#define LTE_RESTART_MODEM_INITIATED (1)
/* Modem restart cause: Modem firmware version error */
#define LTE_RESTART_VERSION_ERROR (2)
/* Error indicator for error code */
#define LTE_ERR_INDICATOR_ERRCODE (0x01)
@ -525,18 +487,6 @@
#define LTE_SIMINFO_GETOPT_GID2 (1 << 5)
/* Digit number of mcc
* deprecated. Use LTE_MCC_DIGIT instead.
*/
#define LTE_SIMINFO_MCC_DIGIT LTE_MCC_DIGIT
/* Max digit number of mnc
* deprecated. Use LTE_MNC_DIGIT_MAX instead.
*/
#define LTE_SIMINFO_MNC_DIGIT_MAX LTE_MNC_DIGIT_MAX
#define LTE_SIMINFO_SPN_LEN (16) /* Maximum length of SPN */
#define LTE_SIMINFO_ICCID_LEN (10) /* Maximum length of ICCCID */
#define LTE_SIMINFO_IMSI_LEN (15) /* Maximum length of IMSI */
@ -2042,4 +1992,16 @@ typedef void (*get_current_psm_cb_t)(uint32_t result,
typedef void (*get_quality_cb_t)(uint32_t result,
lte_quality_t *quality);
/* Definition of callback function.
*
* This callback function is used for nitifying a daemon
* context data for resume.
*
* [in] data : Context data body.
*
* [in] size : Context data size
*/
typedef void (*context_save_cb_t)(uint8_t *data, int size);
#endif /* __INCLUDE_NUTTX_WIRELESS_LTE_LTE_H */

View file

@ -30,6 +30,7 @@
#include <sys/types.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/net/sms.h>
#include <nuttx/wireless/wireless.h>
/****************************************************************************
* Pre-processor Definitions
@ -149,6 +150,14 @@
#define LTE_CMDID_LOGREAD _CMDGRP_NORMAL(0x38)
#define LTE_CMDID_LOGLSEEK _CMDGRP_NORMAL(0x39)
#define LTE_CMDID_LOGREMOVE _CMDGRP_NORMAL(0x3a)
#define LTE_CMDID_STOPAPI _CMDGRP_NORMAL(0x3b)
#define LTE_CMDID_SUSPEND _CMDGRP_NORMAL(0x3c)
#define LTE_CMDID_RESUME _CMDGRP_NORMAL(0x3d)
#define LTE_CMDID_RETRYDISABLE _CMDGRP_POWER(0x3e)
#define LTE_CMDID_GET_POWER_STAT _CMDGRP_POWER(0x3f)
#define LTE_CMDID_SETCTXCB _CMDGRP_NOMDM(0x40)
#define LTE_CMDID_COUNTWLOCK _CMDGRP_POWER(0x41)
#define LTE_CMDID_REPEVT_DUMMY _CMDGRP_EVENT(0x42)
#define LTE_CMDID_ACCEPT _CMDGRP_NORMAL(0x50)
#define LTE_CMDID_BIND _CMDGRP_NORMAL(0x51)
@ -312,6 +321,12 @@
#define LTE_CMDID_LWM2M_EXECRESP _CMDGRP_LWM2M(0x0119)
#define LTE_CMDID_LWM2M_OBSERVEUPDATE _CMDGRP_LWM2M(0x011A)
#define LTE_CMDID_LWM2M_CHANGERAT _CMDGRP_LWM2M(0x011B)
#define LTE_CMDID_LWM2M_GETRAT _CMDGRP_LWM2M(0x011C)
#define LTE_CMDID_LWM2M_GETQMODE _CMDGRP_LWM2M(0x011D)
#define LTE_CMDID_LWM2M_SETQMODE _CMDGRP_LWM2M(0x011E)
#define IS_LWM2M_EVENT(cid) (\
((cid) == LTE_CMDID_LWM2M_READ_EVT) || \
((cid) == LTE_CMDID_LWM2M_WRITE_EVT) || \
@ -321,6 +336,13 @@
((cid) == LTE_CMDID_LWM2M_SERVEROP_EVT) || \
((cid) == LTE_CMDID_LWM2M_FWUP_EVT) )
#define IS_LTE_REPORT_EVENT(cid) (\
((cid) == LTE_CMDID_REPNETINFO) || \
((cid) == LTE_CMDID_REPSIMSTAT) || \
((cid) == LTE_CMDID_REPLTIME) || \
((cid) == LTE_CMDID_REPQUAL) || \
((cid) == LTE_CMDID_REPCELL) )
/****************************************************************************
* Public Types
****************************************************************************/

View file

@ -96,6 +96,9 @@
* when we just want a socket for performing driver
* ioctls. This definition is not POSIX compliant.
*/
#define SOCK_SMS 7 /* Support SMS(Short Message Service) socket.
* This definition is not POSIX compliant.
*/
#define SOCK_PACKET 10 /* Obsolete and should not be used in new programs */
#define SOCK_CLOEXEC 02000000 /* Atomically set close-on-exec flag for the new
@ -292,6 +295,11 @@
#define SS_ALIGNSIZE (sizeof(FAR struct sockaddr *))
/* Implementation specific desired alignment */
/* Network socket control */
#define DENY_INET_SOCK_ENABLE 0x01 /* Deny to create INET socket */
#define DENY_INET_SOCK_DISABLE 0x02 /* Not deny to create INET socket */
/****************************************************************************
* Type Definitions
****************************************************************************/

View file

@ -41,6 +41,14 @@ config NETDEV_WIRELESS_IOCTL
---help---
Enable support for wireless device ioctl() commands
config NETDEV_MODEM_LTE_IOCTL
bool "Enable LTE ioctl()"
default n
select NETDEV_IOCTL
depends on MODEM
---help---
Enable support for modem device ioctl() commands
config NETDEV_IFINDEX
bool "Enable IF index support"
default n

View file

@ -70,6 +70,10 @@
# include <nuttx/wireless/cellular/cellular.h>
#endif
#ifdef CONFIG_NETDEV_MODEM_LTE_IOCTL
# include <nuttx/wireless/lte/lte_ioctl.h>
#endif
#include "arp/arp.h"
#include "socket/socket.h"
#include "netdev/netdev.h"
@ -1598,6 +1602,9 @@ ssize_t net_ioctl_arglen(int cmd)
case SIOCDELRT:
return sizeof(struct rtentry);
case SIOCDENYINETSOCK:
return sizeof(uint8_t);
default:
#ifdef CONFIG_NETDEV_IOCTL
# ifdef CONFIG_NETDEV_WIRELESS_IOCTL
@ -1627,6 +1634,20 @@ ssize_t net_ioctl_arglen(int cmd)
return sizeof(struct btreq_s);
}
# endif
# ifdef CONFIG_NETDEV_MODEM_LTE_IOCTL
if (_LTEIOCVALID(cmd))
{
switch (cmd)
{
case SIOCLTECMD:
return sizeof(struct lte_ioctl_data_s);
default:
return sizeof(struct lte_smsreq_s);
}
}
# endif
#endif
return -ENOTTY;