pkarashchenko commented on code in PR #1785: URL: https://github.com/apache/nuttx-apps/pull/1785#discussion_r1214639556
########## include/lte/lapi.h: ########## @@ -0,0 +1,81 @@ +/**************************************************************************** + * apps/include/lte/lapi.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 __APPS_INCLUDE_LTE_LAPI_H +#define __APPS_INCLUDE_LTE_LAPI_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <stdint.h> +#include "lte/lte_api.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + + #ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototyppes + ****************************************************************************/ + +/**************************************************************************** + * Name: lapi_evtinit + ****************************************************************************/ + +int lapi_evtinit(FAR const char *mqname); + +/**************************************************************************** + * Name: lapi_evtdestoy + ****************************************************************************/ + +void lapi_evtdestoy(void); + +/**************************************************************************** + * Name: lapi_evtyield + ****************************************************************************/ + +int lapi_evtyield(int timeout_ms); + +/**************************************************************************** + * Name: lapi_req + ****************************************************************************/ + +int lapi_req(uint32_t cmdid, FAR void *inp, size_t insz, FAR void *outp, + size_t outsz, FAR void *cb); Review Comment: ```suggestion int lapi_req(uint32_t cmdid, FAR void *inp, size_t insz, FAR void *outp, size_t outsz, FAR void *cb); ``` ########## include/lte/lte_fwupdate.h: ########## @@ -0,0 +1,155 @@ +/**************************************************************************** + * apps/include/lte/lte_fwupdate.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 __APPS_INCLUDE_LTE_LTE_FW_API_H Review Comment: ```suggestion #ifndef __APPS_INCLUDE_LTE_LTE_FWUPDATE_H ``` ########## include/lte/lte_api.h: ########## @@ -0,0 +1,1579 @@ +/**************************************************************************** + * apps/include/lte/lte_api.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 __APPS_INCLUDE_LTE_LTE_API_H +#define __APPS_INCLUDE_LTE_LTE_API_H + +/* - Abbreviations and terms + * - PDN : Packet Data Network + * + * Route for transferring packets between the terminal and LTE networks. + * + * - APN : Access Point Name + * + * Settings required when connecting to an LTE network. + * + * - IMSI : International Mobile Subscriber Identity + * + * International subscriber identification number recorded + * on the SIM card. + * + * - IMEI : International Mobile Equipment Identifier + * + * International identification number assigned to + * data communication terminals + * + * - PIN : Personal Identification Number + * + * - MCC : Mobile Country Code + * + * The mobile country code consists of three decimal digits. + * + * - MNC : Mobile Network Code + * + * The mobile network code consists of two or three decimal digits. + * + * - eDRX : extended Discontinuous Reception + * + * Communication technology that reduces power consumption + * by increasing the reception interval of various signals transmitted + * from LTE networks. + * + * - PSM : Power Saving Mode + * + * Communication technology that reduces power consumption + * by not communicating with the LTE network + * for a certain period of time. + * + * - CE : Coverage Enhancement + * + * Communication technology that attempts to resend data and eventually + * restores the original data even if the data is corrupted + * due to weak electric field communication. + * + * - RAT : Radio Access Technology + * + * Physical connection method for a radio based communication network. + * + * - LTE API system + * - Network connection API + * + * Radio ON / OFF, PDN connection establishment / destruction. + * + * - Communication quality and communication state API + * + * Acquisition of radio status, communication status, and local time. + * + * - SIM card control API + * + * Get phone number / IMSI, set the PIN, get SIM status. + * + * - Modem setting API + * + * Get modem firmware version and IMEI. Update communication settings. + * + * - API call type + * + * There are two types of LTE API: synchronous and asynchronous. + * + * - Synchronous API + * - Notifies the processing result as a return value. + * + * - Blocks the task that called the API until + * processing is completed on the modem. + * + * - If the return value is -EPROTO, you can get the error code + * with lte_get_errinfo. + * + * - If the argument attribute is out, the argument must be allocated + * by the caller. + * + * - Asynchronous API + * - The processing result is notified by callback. + * The callback is invoked in the task context. + * + * - Blocks the task that called the API until it requests + * processing from the modem. + * + * - Notifies the processing request result as a return value. + * + * - The callback is registered with the argument of each API. + * Registration is canceled when the processing result is notified. + * + * - The same API cannot be called until the processing result is notified + * by the callback.(-EINPROGRESS is notified with a return value.) + * + * - If the callback reports an error (LTE_RESULT_ERROR), + * detailed error information can be acquired with lte_get_errinfo. + * + * For some APIs, both synchronous and asynchronous APIs are available. + * The correspondence table of API is as follows. + * + * + * | Synchronous API | Asynchronous API | + * | ---------------------------- | --------------------------------- | + * | lte_initialize | | + * | lte_finalize | | + * | lte_set_report_restart | | + * | lte_power_on | | + * | lte_power_off | | + * | lte_set_report_netinfo | | + * | lte_set_report_simstat | | + * | lte_set_report_localtime | | + * | lte_set_report_quality | | + * | lte_set_report_cellinfo | | + * | lte_get_errinfo | | + * | lte_activate_pdn_cancel | | + * | lte_radio_on_sync | lte_radio_on (deprecated) | + * | lte_radio_off_sync | lte_radio_off (deprecated) | + * | lte_activate_pdn_sync | lte_activate_pdn | + * | lte_deactivate_pdn_sync | lte_deactivate_pdn (deprecated) | + * | lte_data_allow_sync | lte_data_allow (deprecated) | + * | lte_get_netinfo_sync | lte_get_netinfo (deprecated) | + * | lte_get_imscap_sync | lte_get_imscap (deprecated) | + * | lte_get_version_sync | lte_get_version (deprecated) | + * | lte_get_phoneno_sync | lte_get_phoneno (deprecated) | + * | lte_get_imsi_sync | lte_get_imsi (deprecated) | + * | lte_get_imei_sync | lte_get_imei (deprecated) | + * | lte_get_pinset_sync | lte_get_pinset (deprecated) | + * | lte_set_pinenable_sync | lte_set_pinenable (deprecated) | + * | lte_change_pin_sync | lte_change_pin (deprecated) | + * | lte_enter_pin_sync | lte_enter_pin (deprecated) | + * | lte_get_localtime_sync | lte_get_localtime (deprecated) | + * | lte_get_operator_sync | lte_get_operator (deprecated) | + * | lte_get_edrx_sync | lte_get_edrx (deprecated) | + * | lte_set_edrx_sync | lte_set_edrx (deprecated) | + * | lte_get_psm_sync | lte_get_psm (deprecated) | + * | lte_set_psm_sync | lte_set_psm (deprecated) | + * | lte_get_ce_sync | lte_get_ce (deprecated) | + * | lte_set_ce_sync | lte_set_ce (deprecated) | + * | lte_get_siminfo_sync | lte_get_siminfo (deprecated) | + * | lte_get_current_edrx_sync | lte_get_current_edrx (deprecated) | + * | lte_get_current_psm_sync | lte_get_current_psm (deprecated) | + * | lte_get_quality_sync | lte_get_quality (deprecated) | + * | lte_get_cellinfo_sync | | + * | lte_get_rat_sync | | + * | lte_set_rat_sync | | + * | lte_get_ratinfo_sync | | + * | lte_acquire_wakelock | | + * | lte_release_wakelock | | + * | lte_send_atcmd_sync | | + * | lte_factory_reset_sync | | + * | lte_set_context_save_cb | | + * | lte_hibernation_resume | | + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <stdbool.h> +#include <stdint.h> +#include <nuttx/wireless/lte/lte.h> + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/* Initialize resources used in LTE API. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_initialize(void); + +/* Release resources used in LTE API. + * + * return On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_finalize(void); + +/* Register the callback to notify that the modem has started up. + * + * The callback will be invoked if the modem starts successfully + * after calling lte_power_on. Some APIs have to wait until + * this callback is invoked. If no wait, those API return + * with an error. (-ENETDOWN) + * + * The callback is also invoked when the modem is restarted. + * The cause of the restart can be obtained from the callback argument. + * + * This function must be called after lte_initialize. + * + * Attention to the following + * when LTE_RESTART_MODEM_INITIATED is set. + * - Asynchronous API callbacks for which results have not been + * notified are canceled and becomes available. + * + * - The processing result of the synchronous API + * being called results in an error. (Return value is -ENETDOWN) + * The errno is ENETDOWN for the socket API. + * + * - It should close the socket by user application. + * + * [in] restart_callback: Callback function to notify that + * modem restarted. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_set_report_restart(restart_report_cb_t restart_callback); + +/* Power on the modem. + * + * The callback which registered by lte_set_report_restart + * will be invoked if the modem starts successfully. + * + * This function must be called after lte_set_report_restart. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_power_on(void); + +/* Power off the modem + * + * Attention to the following when this API calling. + * - For asynchronous API + * - callback is canceled. + * + * - For synchronous API + * - API returns with an error. + * - The return value is -ENETDOWN for the LTE API. + * - The errno is ENETDOWN for the socket API. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_power_off(void); + +/* With the radio on, to start the LTE network search. + * + * Attention to the following when this API calling. + * - If SIM is PIN locked, the result will be an error. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_radio_on_sync(void); + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* With the radio on, to start the LTE network search. + * The use of this API is deprecated. + * Use lte_radio_on_sync() instead. + * + * Attention to the following when this API calling. + * - If SIM is PIN locked, the result will be an error. + * + * [in] callback: Callback function to notify that + * radio on is completed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_radio_on(radio_on_cb_t callback); + +#endif /* CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API */ + +/* Exit LTE network searches with the radio off. + * + * If this function is called when a PDN has already been constructed, + * the PDN is discarded. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_radio_off_sync(void); + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* Exit LTE network searches with the radio off. + * The use of this API is deprecated. + * Use lte_radio_off_sync() instead. + * + * If this function is called when a PDN has already been constructed, + * the PDN is discarded. + * + * [in] callback: Callback function to notify that + * radio off is completed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_radio_off(radio_off_cb_t callback); + +#endif /* CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API */ + +/* Get LTE network information. + * + * The maximum number of PDNs status areas must be allocated + * before calls this API. + * + * [in] pdn_num: Number of pdn_stat allocated by the user. + * The range is from LTE_PDN_SESSIONID_MIN to + * LTE_PDN_SESSIONID_MAX. + * + * [out] info: The LTE network information. + * See lte_netinfo_t + * + * attention Immediately after successful PDN construction + * using lte_activate_pdn_sync() or lte_activate_pdn(), + * session information such as IP address + * may not be acquired correctly. + * If you want to use this API after successfully construction + * the PDN, wait at least 1 second before executing it. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_get_netinfo_sync(uint8_t pdn_num, lte_netinfo_t *info); + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* Get LTE network information. + * The use of this API is deprecated. + * Use lte_get_netinfo_sync() instead. + * + * [in] callback: Callback function to notify that + * get network information completed. + * + * attention Immediately after successful PDN construction + * using lte_activate_pdn_sync() or lte_activate_pdn(), + * session information such as IP address + * may not be acquired correctly. + * If you want to use this API after successfully construction + * the PDN, wait at least 1 second before executing it. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_get_netinfo(get_netinfo_cb_t callback); + +#endif /* CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API */ + +/* Constructs a PDN with the specified APN settings. + * + * When constructs the initial PDN, + * LTE_APN_TYPE_IA must be set to the APN type. + * + * When PDN construction is successful, + * an IP address is given from the LTE network. + * + * attention Attention to the following when this API calling. + * - The initial PDN construction may take a few minutes + * depending on radio conditions. + * + * - If API is not returned, please check if the APN settings are correct. + * + * [in] apn: The pointer of the apn setting. + * See lte_apn_setting_t for valid parameters. + * + * [out] pdn: The construction PDN information. + * See lte_pdn_t. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + * If canceling, -ECANCELED is returned. + */ + +int lte_activate_pdn_sync(lte_apn_setting_t *apn, lte_pdn_t *pdn); + +/* Constructs a PDN with the specified APN settings. + * + * When constructs the initial PDN, + * LTE_APN_TYPE_IA must be set to the APN type. + * + * When PDN construction is successful, + * an IP address is given from the LTE network. + * + * attention Attention to the following when this API calling. + * - The initial PDN construction may take a few minutes + * depending on radio conditions. + * + * - If the callback is not notified, please check + * if the APN settings are correct. + * + * [in] apn: The pointer of the apn setting. + * See lte_apn_setting_t for valid parameters. + * + * [in] callback: Callback function to notify that + * PDN activation completed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_activate_pdn(lte_apn_setting_t *apn, activate_pdn_cb_t callback); + +/* Cancel PDN construction. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_activate_pdn_cancel(void); + +/* Discard the constructed PDN. + * + * Discards the PDN corresponding to the session ID + * obtained by lte_activate_pdn. + * + * When the discard process is successful, the IP address assigned to + * the modem is released to the LTE network. + * + * [in] session_id: The numeric value of the session ID. + * Use the value obtained by the lte_activate_pdn. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_deactivate_pdn_sync(uint8_t session_id); + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* Discard the constructed PDN. + * The use of this API is deprecated. + * Use lte_deactivate_pdn_sync() instead. + * + * Discards the PDN corresponding to the session ID + * obtained by lte_activate_pdn. + * + * When the discard process is successful, the IP address assigned to + * the modem is released to the LTE network. + * + * [in] session_id: The numeric value of the session ID. + * Use the value obtained by the lte_activate_pdn. + * + * [in] callback: Callback function to notify that + * LTE PDN deactivation completed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_deactivate_pdn(uint8_t session_id, deactivate_pdn_cb_t callback); + +#endif /* CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API */ + +/* Allow or disallow to data communication for specified PDN. + * + * attention This function is not supported. + * + * [in] session_id: The numeric value of the session ID. + * Use the value obtained by the lte_activate_pdn. + * + * [in] allow: Allow or disallow to data communication for + * all network. Definition is as below. + * - LTE_DATA_ALLOW + * - LTE_DATA_DISALLOW + * + * [in] roaming_allow: Allow or disallow to data communication for + * roaming network. Definition is as below. + * - LTE_DATA_ALLOW + * - LTE_DATA_DISALLOW + * + * -EOPNOTSUPP is returned. + */ + +int lte_data_allow_sync(uint8_t session_id, uint8_t allow, + uint8_t roaming_allow); + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* Allow or disallow to data communication for specified PDN. + * The use of this API is deprecated. + * + * attention This function is not supported. + * + * [in] session_id: The numeric value of the session ID. + * Use the value obtained by the lte_activate_pdn. + * + * [in] allow: Allow or disallow to data communication for + * all network. Definition is as below. + * - LTE_DATA_ALLOW + * - LTE_DATA_DISALLOW + * + * [in] roaming_allow: Allow or disallow to data communication for + * roaming network. Definition is as below. + * - LTE_DATA_ALLOW + * - LTE_DATA_DISALLOW + * + * [in] callback: Callback function to notify that + * configuration has changed. + * + * -EOPNOTSUPP is returned. + */ + +int lte_data_allow(uint8_t session_id, uint8_t allow, + uint8_t roaming_allow, data_allow_cb_t callback); + +#endif /* CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API */ + +/* Get whether the modem supports IMS or not. + * + * [out] imscap: The IMS capability. + * As below value stored. + * - LTE_ENABLE + * - LTE_DISABLE + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_get_imscap_sync(bool *imscap); + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* Get whether the modem supports IMS or not. + * The use of this API is deprecated. + * Use lte_get_imscap_sync() instead. + * + * [in] callback: Callback function to notify when + * getting IMS capability is completed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_get_imscap(get_imscap_cb_t callback); + +#endif /* CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API */ + +/* Acquires the FW version information of the modem. + * + * [out] version: The version information of the modem. + * See lte_version_t + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_get_version_sync(lte_version_t *version); + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* Acquires the FW version information of the modem. + * The use of this API is deprecated. + * Use lte_get_version_sync() instead. + * + * [in] callback: Callback function to notify when + * getting the version is completed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_get_version(get_ver_cb_t callback); + +#endif /* CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API */ + +/* Get phone number from SIM. + * + * [out] phoneno: A character string indicating phone number. + * It is terminated with '\0'. + * The maximum number of phone number areas + * must be allocated. See LTE_PHONENO_LEN. + * [in] len: Length of the buffer for storing phone number. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +#ifdef CONFIG_LTE_LAPI_KEEP_COMPATIBILITY +int lte_get_phoneno_sync(char *phoneno); +#else +int lte_get_phoneno_sync(char *phoneno, size_t len); +#endif + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* Get phone number from SIM. + * The use of this API is deprecated. + * Use lte_get_phoneno_sync() instead. + * + * [in] callback: Callback function to notify when + * getting the phone number is completed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_get_phoneno(get_phoneno_cb_t callback); + +#endif /* CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API */ + +/* Get International Mobile Subscriber Identity from SIM. + * + * [out] imsi: A character string indicating IMSI. + * It is terminated with '\0'. + * The maximum number of IMSI areas + * must be allocated. See LTE_IMSI_LEN. + * [in] len: Length of the buffer for storing IMSI. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +#ifdef CONFIG_LTE_LAPI_KEEP_COMPATIBILITY +int lte_get_imsi_sync(char *imsi); +#else +int lte_get_imsi_sync(char *imsi, size_t len); +#endif + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* Get International Mobile Subscriber Identity from SIM. + * The use of this API is deprecated. + * Use lte_get_imsi_sync() instead. + * + * [in] callback: Callback function to notify when + * getting IMSI is completed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_get_imsi(get_imsi_cb_t callback); + +#endif /* CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API */ + +/* Get International Mobile Equipment Identifier from the modem. + * + * [out] imei: A character string indicating IMEI. + * It is terminated with '\0'. + * The maximum number of IMEI areas + * must be allocated. See LTE_IMEI_LEN. + * [in] len: Length of the buffer for storing IMEI. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +#ifdef CONFIG_LTE_LAPI_KEEP_COMPATIBILITY +int lte_get_imei_sync(char *imei); +#else +int lte_get_imei_sync(char *imei, size_t len); +#endif + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* Get International Mobile Equipment Identifier from the modem. + * The use of this API is deprecated. + * Use lte_get_imei_sync() instead. + * + * [in] callback: Callback function to notify when + * getting IMEI is completed + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_get_imei(get_imei_cb_t callback); + +#endif /* CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API */ + +/* Get Personal Identification Number settings. + * + * [out] pinset: PIN settings information. + * See lte_getpin_t. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_get_pinset_sync(lte_getpin_t *pinset); + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* Get Personal Identification Number settings. + * The use of this API is deprecated. + * Use lte_get_pinset_sync() instead. + * + * [in] callback: Callback function to notify when + * getting the PIN setting is completed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_get_pinset(get_pinset_cb_t callback); + +#endif /* CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API */ + +/* Set Personal Identification Number enable. + * + * [in] enable: "Enable" or "Disable". + * Definition is as below. + * - LTE_ENABLE + * - LTE_DISABLE + * + * [in] pincode: Current PIN code. Minimum number of digits is 4. + * Maximum number of digits is 8, end with '\0'. + * (i.e. Max 9 byte) + * + * [out] attemptsleft: Number of attempts left. + * Set only if failed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_set_pinenable_sync(bool enable, char *pincode, + uint8_t *attemptsleft); + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* Set Personal Identification Number enable. + * The use of this API is deprecated. + * Use lte_set_pinenable_sync() instead. + * + * [in] enable: "Enable" or "Disable". + * Definition is as below. + * - LTE_ENABLE + * - LTE_DISABLE + * + * [in] pincode: Current PIN code. Minimum number of digits is 4. + * Maximum number of digits is 8, end with '\0'. + * (i.e. Max 9 byte) + * + * [in] callback: Callback function to notify that + * setting of PIN enables/disables is completed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_set_pinenable(bool enable, char *pincode, + set_pinenable_cb_t callback); + +#endif /* CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API */ + +/* Change Personal Identification Number. + * + * It can be changed only when PIN is enable. + * + * [in] target_pin: Target of change PIN. + * Definition is as below. + * - LTE_TARGET_PIN + * - LTE_TARGET_PIN2 + * + * [in] pincode: Current PIN code. Minimum number of digits is 4. + * Maximum number of digits is 8, end with '\0'. + * (i.e. Max 9 byte) + * + * [in] new_pincode: New PIN code. Minimum number of digits is 4. + * Maximum number of digits is 8, end with '\0'. + * (i.e. Max 9 byte) + * + * [out] attemptsleft: Number of attempts left. + * Set only if failed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_change_pin_sync(int8_t target_pin, char *pincode, + char *new_pincode, uint8_t *attemptsleft); Review Comment: FAR ########## include/lte/lte_fwupdate.h: ########## @@ -0,0 +1,155 @@ +/**************************************************************************** + * apps/include/lte/lte_fwupdate.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 __APPS_INCLUDE_LTE_LTE_FW_API_H +#define __APPS_INCLUDE_LTE_LTE_FW_API_H + +/* API call type + * + * | Sync API | + * | ----------------------------- | + * | ltefwupdate_initialize | + * | ltefwupdate_injectrest | + * | ltefwupdate_injected_datasize | + * | ltefwupdate_execute | + * | ltefwupdate_result | + * + * attention + * This API notifies the progress of the update by the callback set by + * lte_set_report_restart(). You must call lte_set_report_restart() + * before lte_power_on(). + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <stdint.h> +#include <nuttx/wireless/lte/lte.h> + +#include "lte_fw_def.h" + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/* Initialze injection delta image to LTE modem. + * + * Initialize LTE modem delta image injection with some data of top of delta + * image. + * + * [in] initial_data: Pointer to top data of update image. + * [in] len: Size of initial_data. + * + * Return value : Positive value is the injected length. Negative value is + * any error. In error case, the value can be below values. + * + * - LTEFW_RESULT_NOT_ENOUGH_INJECTSTORAGE + * - LTEFW_RESULT_DELTAIMAGE_HDR_CRC_ERROR + * - LTEFW_RESULT_DELTAIMAGE_HDR_UNSUPPORTED + * - EINVAL + * - ENODATA + * + */ + +int ltefwupdate_initialize(const char *initial_data, int len); + +/* Inject rest delta image to LTE modem. + * + * Inject the rest of the delta image following the data injected + * by the ltefwupdate_initialize() and ltefwupdate_injectrest() functions. + * + * [in] rest_data: Pointer to top data of update image. + * [in] len: Size of initial_data. + * + * Return value : Positive value is the injected length. Negative value is + * any error. In error case, the value can be below values. + * + * - LTEFW_RESULT_NOT_ENOUGH_INJECTSTORAGE + * - LTEFW_RESULT_DELTAIMAGE_HDR_CRC_ERROR + * - LTEFW_RESULT_DELTAIMAGE_HDR_UNSUPPORTED + * - EINVAL + * - ENODATA + * + */ + +int ltefwupdate_injectrest(const char *rest_data, int len); Review Comment: FAR ########## include/lte/lte_api.h: ########## @@ -0,0 +1,1579 @@ +/**************************************************************************** + * apps/include/lte/lte_api.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 __APPS_INCLUDE_LTE_LTE_API_H +#define __APPS_INCLUDE_LTE_LTE_API_H + +/* - Abbreviations and terms + * - PDN : Packet Data Network + * + * Route for transferring packets between the terminal and LTE networks. + * + * - APN : Access Point Name + * + * Settings required when connecting to an LTE network. + * + * - IMSI : International Mobile Subscriber Identity + * + * International subscriber identification number recorded + * on the SIM card. + * + * - IMEI : International Mobile Equipment Identifier + * + * International identification number assigned to + * data communication terminals + * + * - PIN : Personal Identification Number + * + * - MCC : Mobile Country Code + * + * The mobile country code consists of three decimal digits. + * + * - MNC : Mobile Network Code + * + * The mobile network code consists of two or three decimal digits. + * + * - eDRX : extended Discontinuous Reception + * + * Communication technology that reduces power consumption + * by increasing the reception interval of various signals transmitted + * from LTE networks. + * + * - PSM : Power Saving Mode + * + * Communication technology that reduces power consumption + * by not communicating with the LTE network + * for a certain period of time. + * + * - CE : Coverage Enhancement + * + * Communication technology that attempts to resend data and eventually + * restores the original data even if the data is corrupted + * due to weak electric field communication. + * + * - RAT : Radio Access Technology + * + * Physical connection method for a radio based communication network. + * + * - LTE API system + * - Network connection API + * + * Radio ON / OFF, PDN connection establishment / destruction. + * + * - Communication quality and communication state API + * + * Acquisition of radio status, communication status, and local time. + * + * - SIM card control API + * + * Get phone number / IMSI, set the PIN, get SIM status. + * + * - Modem setting API + * + * Get modem firmware version and IMEI. Update communication settings. + * + * - API call type + * + * There are two types of LTE API: synchronous and asynchronous. + * + * - Synchronous API + * - Notifies the processing result as a return value. + * + * - Blocks the task that called the API until + * processing is completed on the modem. + * + * - If the return value is -EPROTO, you can get the error code + * with lte_get_errinfo. + * + * - If the argument attribute is out, the argument must be allocated + * by the caller. + * + * - Asynchronous API + * - The processing result is notified by callback. + * The callback is invoked in the task context. + * + * - Blocks the task that called the API until it requests + * processing from the modem. + * + * - Notifies the processing request result as a return value. + * + * - The callback is registered with the argument of each API. + * Registration is canceled when the processing result is notified. + * + * - The same API cannot be called until the processing result is notified + * by the callback.(-EINPROGRESS is notified with a return value.) + * + * - If the callback reports an error (LTE_RESULT_ERROR), + * detailed error information can be acquired with lte_get_errinfo. + * + * For some APIs, both synchronous and asynchronous APIs are available. + * The correspondence table of API is as follows. + * + * + * | Synchronous API | Asynchronous API | + * | ---------------------------- | --------------------------------- | + * | lte_initialize | | + * | lte_finalize | | + * | lte_set_report_restart | | + * | lte_power_on | | + * | lte_power_off | | + * | lte_set_report_netinfo | | + * | lte_set_report_simstat | | + * | lte_set_report_localtime | | + * | lte_set_report_quality | | + * | lte_set_report_cellinfo | | + * | lte_get_errinfo | | + * | lte_activate_pdn_cancel | | + * | lte_radio_on_sync | lte_radio_on (deprecated) | + * | lte_radio_off_sync | lte_radio_off (deprecated) | + * | lte_activate_pdn_sync | lte_activate_pdn | + * | lte_deactivate_pdn_sync | lte_deactivate_pdn (deprecated) | + * | lte_data_allow_sync | lte_data_allow (deprecated) | + * | lte_get_netinfo_sync | lte_get_netinfo (deprecated) | + * | lte_get_imscap_sync | lte_get_imscap (deprecated) | + * | lte_get_version_sync | lte_get_version (deprecated) | + * | lte_get_phoneno_sync | lte_get_phoneno (deprecated) | + * | lte_get_imsi_sync | lte_get_imsi (deprecated) | + * | lte_get_imei_sync | lte_get_imei (deprecated) | + * | lte_get_pinset_sync | lte_get_pinset (deprecated) | + * | lte_set_pinenable_sync | lte_set_pinenable (deprecated) | + * | lte_change_pin_sync | lte_change_pin (deprecated) | + * | lte_enter_pin_sync | lte_enter_pin (deprecated) | + * | lte_get_localtime_sync | lte_get_localtime (deprecated) | + * | lte_get_operator_sync | lte_get_operator (deprecated) | + * | lte_get_edrx_sync | lte_get_edrx (deprecated) | + * | lte_set_edrx_sync | lte_set_edrx (deprecated) | + * | lte_get_psm_sync | lte_get_psm (deprecated) | + * | lte_set_psm_sync | lte_set_psm (deprecated) | + * | lte_get_ce_sync | lte_get_ce (deprecated) | + * | lte_set_ce_sync | lte_set_ce (deprecated) | + * | lte_get_siminfo_sync | lte_get_siminfo (deprecated) | + * | lte_get_current_edrx_sync | lte_get_current_edrx (deprecated) | + * | lte_get_current_psm_sync | lte_get_current_psm (deprecated) | + * | lte_get_quality_sync | lte_get_quality (deprecated) | + * | lte_get_cellinfo_sync | | + * | lte_get_rat_sync | | + * | lte_set_rat_sync | | + * | lte_get_ratinfo_sync | | + * | lte_acquire_wakelock | | + * | lte_release_wakelock | | + * | lte_send_atcmd_sync | | + * | lte_factory_reset_sync | | + * | lte_set_context_save_cb | | + * | lte_hibernation_resume | | + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <stdbool.h> +#include <stdint.h> +#include <nuttx/wireless/lte/lte.h> + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/* Initialize resources used in LTE API. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_initialize(void); + +/* Release resources used in LTE API. + * + * return On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_finalize(void); + +/* Register the callback to notify that the modem has started up. + * + * The callback will be invoked if the modem starts successfully + * after calling lte_power_on. Some APIs have to wait until + * this callback is invoked. If no wait, those API return + * with an error. (-ENETDOWN) + * + * The callback is also invoked when the modem is restarted. + * The cause of the restart can be obtained from the callback argument. + * + * This function must be called after lte_initialize. + * + * Attention to the following + * when LTE_RESTART_MODEM_INITIATED is set. + * - Asynchronous API callbacks for which results have not been + * notified are canceled and becomes available. + * + * - The processing result of the synchronous API + * being called results in an error. (Return value is -ENETDOWN) + * The errno is ENETDOWN for the socket API. + * + * - It should close the socket by user application. + * + * [in] restart_callback: Callback function to notify that + * modem restarted. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_set_report_restart(restart_report_cb_t restart_callback); + +/* Power on the modem. + * + * The callback which registered by lte_set_report_restart + * will be invoked if the modem starts successfully. + * + * This function must be called after lte_set_report_restart. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_power_on(void); + +/* Power off the modem + * + * Attention to the following when this API calling. + * - For asynchronous API + * - callback is canceled. + * + * - For synchronous API + * - API returns with an error. + * - The return value is -ENETDOWN for the LTE API. + * - The errno is ENETDOWN for the socket API. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_power_off(void); + +/* With the radio on, to start the LTE network search. + * + * Attention to the following when this API calling. + * - If SIM is PIN locked, the result will be an error. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_radio_on_sync(void); + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* With the radio on, to start the LTE network search. + * The use of this API is deprecated. + * Use lte_radio_on_sync() instead. + * + * Attention to the following when this API calling. + * - If SIM is PIN locked, the result will be an error. + * + * [in] callback: Callback function to notify that + * radio on is completed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_radio_on(radio_on_cb_t callback); + +#endif /* CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API */ + +/* Exit LTE network searches with the radio off. + * + * If this function is called when a PDN has already been constructed, + * the PDN is discarded. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_radio_off_sync(void); + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* Exit LTE network searches with the radio off. + * The use of this API is deprecated. + * Use lte_radio_off_sync() instead. + * + * If this function is called when a PDN has already been constructed, + * the PDN is discarded. + * + * [in] callback: Callback function to notify that + * radio off is completed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_radio_off(radio_off_cb_t callback); + +#endif /* CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API */ + +/* Get LTE network information. + * + * The maximum number of PDNs status areas must be allocated + * before calls this API. + * + * [in] pdn_num: Number of pdn_stat allocated by the user. + * The range is from LTE_PDN_SESSIONID_MIN to + * LTE_PDN_SESSIONID_MAX. + * + * [out] info: The LTE network information. + * See lte_netinfo_t + * + * attention Immediately after successful PDN construction + * using lte_activate_pdn_sync() or lte_activate_pdn(), + * session information such as IP address + * may not be acquired correctly. + * If you want to use this API after successfully construction + * the PDN, wait at least 1 second before executing it. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_get_netinfo_sync(uint8_t pdn_num, lte_netinfo_t *info); + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* Get LTE network information. + * The use of this API is deprecated. + * Use lte_get_netinfo_sync() instead. + * + * [in] callback: Callback function to notify that + * get network information completed. + * + * attention Immediately after successful PDN construction + * using lte_activate_pdn_sync() or lte_activate_pdn(), + * session information such as IP address + * may not be acquired correctly. + * If you want to use this API after successfully construction + * the PDN, wait at least 1 second before executing it. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_get_netinfo(get_netinfo_cb_t callback); + +#endif /* CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API */ + +/* Constructs a PDN with the specified APN settings. + * + * When constructs the initial PDN, + * LTE_APN_TYPE_IA must be set to the APN type. + * + * When PDN construction is successful, + * an IP address is given from the LTE network. + * + * attention Attention to the following when this API calling. + * - The initial PDN construction may take a few minutes + * depending on radio conditions. + * + * - If API is not returned, please check if the APN settings are correct. + * + * [in] apn: The pointer of the apn setting. + * See lte_apn_setting_t for valid parameters. + * + * [out] pdn: The construction PDN information. + * See lte_pdn_t. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + * If canceling, -ECANCELED is returned. + */ + +int lte_activate_pdn_sync(lte_apn_setting_t *apn, lte_pdn_t *pdn); + +/* Constructs a PDN with the specified APN settings. + * + * When constructs the initial PDN, + * LTE_APN_TYPE_IA must be set to the APN type. + * + * When PDN construction is successful, + * an IP address is given from the LTE network. + * + * attention Attention to the following when this API calling. + * - The initial PDN construction may take a few minutes + * depending on radio conditions. + * + * - If the callback is not notified, please check + * if the APN settings are correct. + * + * [in] apn: The pointer of the apn setting. + * See lte_apn_setting_t for valid parameters. + * + * [in] callback: Callback function to notify that + * PDN activation completed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_activate_pdn(lte_apn_setting_t *apn, activate_pdn_cb_t callback); + +/* Cancel PDN construction. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_activate_pdn_cancel(void); + +/* Discard the constructed PDN. + * + * Discards the PDN corresponding to the session ID + * obtained by lte_activate_pdn. + * + * When the discard process is successful, the IP address assigned to + * the modem is released to the LTE network. + * + * [in] session_id: The numeric value of the session ID. + * Use the value obtained by the lte_activate_pdn. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_deactivate_pdn_sync(uint8_t session_id); + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* Discard the constructed PDN. + * The use of this API is deprecated. + * Use lte_deactivate_pdn_sync() instead. + * + * Discards the PDN corresponding to the session ID + * obtained by lte_activate_pdn. + * + * When the discard process is successful, the IP address assigned to + * the modem is released to the LTE network. + * + * [in] session_id: The numeric value of the session ID. + * Use the value obtained by the lte_activate_pdn. + * + * [in] callback: Callback function to notify that + * LTE PDN deactivation completed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_deactivate_pdn(uint8_t session_id, deactivate_pdn_cb_t callback); + +#endif /* CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API */ + +/* Allow or disallow to data communication for specified PDN. + * + * attention This function is not supported. + * + * [in] session_id: The numeric value of the session ID. + * Use the value obtained by the lte_activate_pdn. + * + * [in] allow: Allow or disallow to data communication for + * all network. Definition is as below. + * - LTE_DATA_ALLOW + * - LTE_DATA_DISALLOW + * + * [in] roaming_allow: Allow or disallow to data communication for + * roaming network. Definition is as below. + * - LTE_DATA_ALLOW + * - LTE_DATA_DISALLOW + * + * -EOPNOTSUPP is returned. + */ + +int lte_data_allow_sync(uint8_t session_id, uint8_t allow, + uint8_t roaming_allow); + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* Allow or disallow to data communication for specified PDN. + * The use of this API is deprecated. + * + * attention This function is not supported. + * + * [in] session_id: The numeric value of the session ID. + * Use the value obtained by the lte_activate_pdn. + * + * [in] allow: Allow or disallow to data communication for + * all network. Definition is as below. + * - LTE_DATA_ALLOW + * - LTE_DATA_DISALLOW + * + * [in] roaming_allow: Allow or disallow to data communication for + * roaming network. Definition is as below. + * - LTE_DATA_ALLOW + * - LTE_DATA_DISALLOW + * + * [in] callback: Callback function to notify that + * configuration has changed. + * + * -EOPNOTSUPP is returned. + */ + +int lte_data_allow(uint8_t session_id, uint8_t allow, + uint8_t roaming_allow, data_allow_cb_t callback); + +#endif /* CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API */ + +/* Get whether the modem supports IMS or not. + * + * [out] imscap: The IMS capability. + * As below value stored. + * - LTE_ENABLE + * - LTE_DISABLE + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_get_imscap_sync(bool *imscap); + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* Get whether the modem supports IMS or not. + * The use of this API is deprecated. + * Use lte_get_imscap_sync() instead. + * + * [in] callback: Callback function to notify when + * getting IMS capability is completed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_get_imscap(get_imscap_cb_t callback); + +#endif /* CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API */ + +/* Acquires the FW version information of the modem. + * + * [out] version: The version information of the modem. + * See lte_version_t + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_get_version_sync(lte_version_t *version); + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* Acquires the FW version information of the modem. + * The use of this API is deprecated. + * Use lte_get_version_sync() instead. + * + * [in] callback: Callback function to notify when + * getting the version is completed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_get_version(get_ver_cb_t callback); + +#endif /* CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API */ + +/* Get phone number from SIM. + * + * [out] phoneno: A character string indicating phone number. + * It is terminated with '\0'. + * The maximum number of phone number areas + * must be allocated. See LTE_PHONENO_LEN. + * [in] len: Length of the buffer for storing phone number. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +#ifdef CONFIG_LTE_LAPI_KEEP_COMPATIBILITY +int lte_get_phoneno_sync(char *phoneno); +#else +int lte_get_phoneno_sync(char *phoneno, size_t len); +#endif + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* Get phone number from SIM. + * The use of this API is deprecated. + * Use lte_get_phoneno_sync() instead. + * + * [in] callback: Callback function to notify when + * getting the phone number is completed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_get_phoneno(get_phoneno_cb_t callback); + +#endif /* CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API */ + +/* Get International Mobile Subscriber Identity from SIM. + * + * [out] imsi: A character string indicating IMSI. + * It is terminated with '\0'. + * The maximum number of IMSI areas + * must be allocated. See LTE_IMSI_LEN. + * [in] len: Length of the buffer for storing IMSI. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +#ifdef CONFIG_LTE_LAPI_KEEP_COMPATIBILITY +int lte_get_imsi_sync(char *imsi); +#else +int lte_get_imsi_sync(char *imsi, size_t len); +#endif + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* Get International Mobile Subscriber Identity from SIM. + * The use of this API is deprecated. + * Use lte_get_imsi_sync() instead. + * + * [in] callback: Callback function to notify when + * getting IMSI is completed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_get_imsi(get_imsi_cb_t callback); + +#endif /* CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API */ + +/* Get International Mobile Equipment Identifier from the modem. + * + * [out] imei: A character string indicating IMEI. + * It is terminated with '\0'. + * The maximum number of IMEI areas + * must be allocated. See LTE_IMEI_LEN. + * [in] len: Length of the buffer for storing IMEI. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +#ifdef CONFIG_LTE_LAPI_KEEP_COMPATIBILITY +int lte_get_imei_sync(char *imei); +#else +int lte_get_imei_sync(char *imei, size_t len); +#endif + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* Get International Mobile Equipment Identifier from the modem. + * The use of this API is deprecated. + * Use lte_get_imei_sync() instead. + * + * [in] callback: Callback function to notify when + * getting IMEI is completed + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_get_imei(get_imei_cb_t callback); + +#endif /* CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API */ + +/* Get Personal Identification Number settings. + * + * [out] pinset: PIN settings information. + * See lte_getpin_t. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_get_pinset_sync(lte_getpin_t *pinset); + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* Get Personal Identification Number settings. + * The use of this API is deprecated. + * Use lte_get_pinset_sync() instead. + * + * [in] callback: Callback function to notify when + * getting the PIN setting is completed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_get_pinset(get_pinset_cb_t callback); + +#endif /* CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API */ + +/* Set Personal Identification Number enable. + * + * [in] enable: "Enable" or "Disable". + * Definition is as below. + * - LTE_ENABLE + * - LTE_DISABLE + * + * [in] pincode: Current PIN code. Minimum number of digits is 4. + * Maximum number of digits is 8, end with '\0'. + * (i.e. Max 9 byte) + * + * [out] attemptsleft: Number of attempts left. + * Set only if failed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_set_pinenable_sync(bool enable, char *pincode, + uint8_t *attemptsleft); + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* Set Personal Identification Number enable. + * The use of this API is deprecated. + * Use lte_set_pinenable_sync() instead. + * + * [in] enable: "Enable" or "Disable". + * Definition is as below. + * - LTE_ENABLE + * - LTE_DISABLE + * + * [in] pincode: Current PIN code. Minimum number of digits is 4. + * Maximum number of digits is 8, end with '\0'. + * (i.e. Max 9 byte) + * + * [in] callback: Callback function to notify that + * setting of PIN enables/disables is completed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_set_pinenable(bool enable, char *pincode, + set_pinenable_cb_t callback); + +#endif /* CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API */ + +/* Change Personal Identification Number. + * + * It can be changed only when PIN is enable. + * + * [in] target_pin: Target of change PIN. + * Definition is as below. + * - LTE_TARGET_PIN + * - LTE_TARGET_PIN2 + * + * [in] pincode: Current PIN code. Minimum number of digits is 4. + * Maximum number of digits is 8, end with '\0'. + * (i.e. Max 9 byte) + * + * [in] new_pincode: New PIN code. Minimum number of digits is 4. + * Maximum number of digits is 8, end with '\0'. + * (i.e. Max 9 byte) + * + * [out] attemptsleft: Number of attempts left. + * Set only if failed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_change_pin_sync(int8_t target_pin, char *pincode, + char *new_pincode, uint8_t *attemptsleft); + +#ifdef CONFIG_LTE_LAPI_ENABLE_DEPRECATED_API + +/* Change Personal Identification Number. + * The use of this API is deprecated. + * Use lte_change_pin_sync() instead. + * + * It can be changed only when PIN is enable. + * + * [in] target_pin: Target of change PIN. + * Definition is as below. + * - LTE_TARGET_PIN + * - LTE_TARGET_PIN2 + * + * [in] pincode: Current PIN code. Minimum number of digits is 4. + * Maximum number of digits is 8, end with '\0'. + * (i.e. Max 9 byte) + * + * [in] new_pincode: New PIN code. Minimum number of digits is 4. + * Maximum number of digits is 8, end with '\0'. + * (i.e. Max 9 byte) + * + * [in] callback: Callback function to notify that + * change of PIN is completed. + * + * On success, 0 is returned. On failure, + * negative value is returned according to <errno.h>. + */ + +int lte_change_pin(int8_t target_pin, char *pincode, + char *new_pincode, change_pin_cb_t callback); Review Comment: FAR ########## lte/alt1250/alt1250_dbg.h: ########## @@ -0,0 +1,44 @@ +/**************************************************************************** + * apps/lte/alt1250/alt1250_dbg.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 __APPS_LTE_ALT1250_ALT1250_DBG_H +#define __APPS_LTE_ALT1250_ALT1250_DBG_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <stdio.h> +#include <debug.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifdef CONFIG_LTE_ALT1250_DEBUG_MSG +# define err_alt1250(v, ...) _err(v, ##__VA_ARGS__) Review Comment: ```suggestion # define err_alt1250(v, ...) nerr(v, ##__VA_ARGS__) ``` ########## lte/alt1250/alt1250_atcmd.c: ########## @@ -0,0 +1,932 @@ +/**************************************************************************** + * apps/lte/alt1250/alt1250_atcmd.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <nuttx/net/usrsock.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "alt1250_dbg.h" +#include "alt1250_daemon.h" +#include "alt1250_atcmd.h" +#include "alt1250_devif.h" +#include "alt1250_postproc.h" +#include "alt1250_container.h" +#include "alt1250_usockevent.h" + +#include <lte/lte_lwm2m.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Data Type + ****************************************************************************/ + +struct atcmd_postprocarg_t +{ + atcmd_postproc_t proc; + unsigned long arg; +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static void *atcmd_oargs[3]; +static int atcmd_reply_len; +static struct atcmd_postprocarg_t postproc_argument; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * name: postproc_internal_atcmd + ****************************************************************************/ + +static int postproc_internal_atcmd(FAR struct alt1250_s *dev, + FAR struct alt_container_s *reply, + FAR struct usock_s *usock, + FAR int32_t *usock_result, + FAR uint32_t *usock_xid, + FAR struct usock_ackinfo_s *ackinfo, + unsigned long arg) +{ + int ret = REP_NO_ACK; + struct atcmd_postprocarg_t *parg = (struct atcmd_postprocarg_t *)arg; Review Comment: FAR ########## lte/alt1250/alt1250_socket.c: ########## @@ -0,0 +1,195 @@ +/**************************************************************************** + * apps/lte/alt1250/alt1250_socket.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 <unistd.h> +#include <fcntl.h> +#include <assert.h> +#include <sys/ioctl.h> + +#include "alt1250_dbg.h" +#include "alt1250_daemon.h" +#include "alt1250_usockif.h" +#include "alt1250_socket.h" +#include "alt1250_select.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * name: usocket_search + ****************************************************************************/ + +FAR struct usock_s *usocket_search(FAR struct alt1250_s *dev, int usockid) +{ + struct usock_s *ret = NULL; + + dbg_alt1250("%s usockid: %d\n", __func__, usockid); + + if (usockid >= 0 && usockid < ARRAY_SZ(dev->sockets)) + { + ret = &dev->sockets[usockid]; + } + + return ret; +} + +/**************************************************************************** + * name: usocket_alloc + ****************************************************************************/ + +FAR struct usock_s *usocket_alloc(FAR struct alt1250_s *dev, int16_t type) +{ + int i; + int base; + int array_num; + FAR struct usock_s *sock; + + switch (type) + { + case SOCK_CTRL: + case SOCK_SMS: + base = SOCKET_COUNT; + array_num = CONFIG_LTE_ALT1250_CONTROL_SOCKETS; + break; + + default: + base = 0; + array_num = SOCKET_COUNT; + break; + } + + sock = &dev->sockets[base]; + + for (i = base; i < base + array_num; i++, sock++) + { + if (sock->state == SOCKET_STATE_CLOSED) + { + sock->usockid = i; + sock->altsockid = -1; + sock->state = SOCKET_STATE_PREALLOC; + sock->select_condition = SELECT_WRITABLE | SELECT_READABLE; + dbg_alt1250("allocated usockid: %d, type: %d\n", i, type); + return sock; + } + } + + return NULL; +} + +/**************************************************************************** + * name: usocket_free + ****************************************************************************/ + +void usocket_free(FAR struct usock_s *sock) +{ + sock->state = SOCKET_STATE_CLOSED; +} + +/**************************************************************************** + * name: usocket_freeall + ****************************************************************************/ + +void usocket_freeall(FAR struct alt1250_s *dev) +{ + int i; + FAR struct usock_s *sock; + + for (i = 0; i < ARRAY_SZ(dev->sockets); i++) + { + sock = &dev->sockets[i]; + usocket_free(sock); + } +} + +/**************************************************************************** + * name: usocket_commitstate + ****************************************************************************/ + +void usocket_commitstate(FAR struct alt1250_s *dev) +{ + restart_select(dev); +} + +/**************************************************************************** + * name: usocket_smssock_num + ****************************************************************************/ + +int usocket_smssock_num(FAR struct alt1250_s *dev) +{ + int i; + int num = 0; + FAR struct usock_s *sock; + + for (i = 0; i < ARRAY_SZ(dev->sockets); i++) + { + sock = &dev->sockets[i]; + if (IS_SMS_SOCKET(sock) && sock->state == SOCKET_STATE_PREALLOC) + { + num++; + } + } + + return num; +} + +/**************************************************************************** + * name: usocket_smssock_readready + ****************************************************************************/ + +void usocket_smssock_readready(FAR struct alt1250_s *dev) +{ + int i; + FAR struct usock_s *sock; + + for (i = 0; i < ARRAY_SZ(dev->sockets); i++) Review Comment: ```suggestion for (i = 0; i < nitems(dev->sockets); i++) ``` ########## lte/alt1250/alt1250_socket.h: ########## @@ -0,0 +1,249 @@ +/**************************************************************************** + * apps/lte/alt1250/alt1250_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 __LTE_ALT1250_ALT1250_SOCKET_H__ Review Comment: ```suggestion #ifndef __APPS_LTE_ALT1250_ALT1250_SOCKET_H ``` ########## lte/alt1250/alt1250_socket.h: ########## @@ -0,0 +1,249 @@ +/**************************************************************************** + * apps/lte/alt1250/alt1250_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 __LTE_ALT1250_ALT1250_SOCKET_H__ +#define __LTE_ALT1250_ALT1250_SOCKET_H__ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/net/usrsock.h> +#include <nuttx/net/sms.h> +#include <assert.h> + +#include "alt1250_usockif.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define SELECT_WRITABLE (1 << 1) +#define SELECT_READABLE (1 << 2) +#define SELECTABLE_MASK (SELECT_WRITABLE | SELECT_READABLE) Review Comment: ```suggestion #define SELECT_READABLE (1 << 2) #define SELECTABLE_MASK (SELECT_WRITABLE | SELECT_READABLE) ``` ########## lte/alt1250/alt1250_socket.h: ########## @@ -0,0 +1,249 @@ +/**************************************************************************** + * apps/lte/alt1250/alt1250_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 __LTE_ALT1250_ALT1250_SOCKET_H__ +#define __LTE_ALT1250_ALT1250_SOCKET_H__ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/net/usrsock.h> +#include <nuttx/net/sms.h> +#include <assert.h> + +#include "alt1250_usockif.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define SELECT_WRITABLE (1 << 1) +#define SELECT_READABLE (1 << 2) +#define SELECTABLE_MASK (SELECT_WRITABLE | SELECT_READABLE) + +#define USOCKET_SET_REQUEST(sock, _reqid, _xid) { \ + (sock)->request.reqid = _reqid; \ + (sock)->request.xid = _xid; \ Review Comment: ```suggestion (sock)->request.reqid = (_reqid); \ (sock)->request.xid = (_xid); \ ``` ########## lte/alt1250/alt1250_usockevent.h: ########## @@ -0,0 +1,74 @@ +/**************************************************************************** + * apps/lte/alt1250/alt1250_usockevent.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 __LTE_ALT1250_ALT1250_USOCKEVENT_H__ +#define __LTE_ALT1250_ALT1250_USOCKEVENT_H__ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/net/usrsock.h> + +#include "alt1250_usockif.h" +#include "alt1250_daemon.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define NEED_CONTAINER_FREE (1<<16) +#define W_CONTAINER_FREE(a) ((a) | NEED_CONTAINER_FREE) +#define WO_CONTAINER_FREE(a) (a) + +#define IS_NEED_CONTAINER_FREE(r) ((r) & NEED_CONTAINER_FREE) + +#define REP_SEND_ACK W_CONTAINER_FREE(1) +#define REP_SEND_ACK_WOFREE WO_CONTAINER_FREE(2) +#define REP_SEND_INPROG W_CONTAINER_FREE(3) +#define REP_SEND_DACK W_CONTAINER_FREE(4) +#define REP_SEND_TERM W_CONTAINER_FREE(5) +#define REP_NO_CONTAINER WO_CONTAINER_FREE(6) +#define REP_NO_ACK W_CONTAINER_FREE(7) +#define REP_NO_ACK_WOFREE WO_CONTAINER_FREE(8) +#define REP_MODEM_RESET WO_CONTAINER_FREE(9) +#define REP_SEND_ACK_TXREADY W_CONTAINER_FREE(10) +#define REP_SEND_DACK_RXREADY W_CONTAINER_FREE(11) + +/**************************************************************************** + * Public Data Type + ****************************************************************************/ + +typedef int (*usrsock_reqhandler_t)(FAR struct alt1250_s *dev, + FAR struct usrsock_request_buff_s *req, + FAR int32_t *usock_result, + FAR uint32_t *usock_xid, + FAR struct usock_ackinfo_s *ackinfo); + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +int usock_reply(int ufd, int action_code, int32_t result, + uint32_t xid, FAR struct usock_ackinfo_s *ackinfo); Review Comment: ```suggestion int usock_reply(int ufd, int action_code, int32_t result, uint32_t xid, FAR struct usock_ackinfo_s *ackinfo); ``` ########## lte/alt1250/alt1250_usockevent.h: ########## @@ -0,0 +1,74 @@ +/**************************************************************************** + * apps/lte/alt1250/alt1250_usockevent.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 __LTE_ALT1250_ALT1250_USOCKEVENT_H__ +#define __LTE_ALT1250_ALT1250_USOCKEVENT_H__ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/net/usrsock.h> + +#include "alt1250_usockif.h" +#include "alt1250_daemon.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define NEED_CONTAINER_FREE (1<<16) +#define W_CONTAINER_FREE(a) ((a) | NEED_CONTAINER_FREE) Review Comment: ```suggestion #define NEED_CONTAINER_FREE (1 << 16) #define W_CONTAINER_FREE(a) ((a) | NEED_CONTAINER_FREE) ``` ########## lte/alt1250/alt1250_socket.h: ########## @@ -0,0 +1,249 @@ +/**************************************************************************** + * apps/lte/alt1250/alt1250_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 __LTE_ALT1250_ALT1250_SOCKET_H__ +#define __LTE_ALT1250_ALT1250_SOCKET_H__ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/net/usrsock.h> +#include <nuttx/net/sms.h> +#include <assert.h> + +#include "alt1250_usockif.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define SELECT_WRITABLE (1 << 1) +#define SELECT_READABLE (1 << 2) +#define SELECTABLE_MASK (SELECT_WRITABLE | SELECT_READABLE) + +#define USOCKET_SET_REQUEST(sock, _reqid, _xid) { \ + (sock)->request.reqid = _reqid; \ + (sock)->request.xid = _xid; \ +} + +#define USOCKET_SET_SOCKTYPE(sock, _domain, _type, _protocol) { \ + (sock)->domain = _domain; \ + (sock)->type = _type; \ + (sock)->protocol = _protocol; \ +} + +#define USOCKET_SET_REQADDRLEN(sock, _addrlen) \ + { (sock)->sock_req.addrbuflen.addr.addrlen = _addrlen; } + +#define USOCKET_SET_REQBACKLOG(sock, _backlog) \ + { (sock)->sock_req.backlog = _backlog; } + +#define USOCKET_SET_REQBUFLEN(sock, _buflen) \ + { (sock)->sock_req.addrbuflen.buflen = _buflen; } + +#define USOCKET_SET_REQSOCKOPT(sock, _level, _opt, _optlen) { \ + (sock)->sock_req.opt.level = _level; \ + (sock)->sock_req.opt.option = _opt; \ + (sock)->sock_req.opt.optlen = _optlen; \ +} + +#define USOCKET_REQID(sock) ((sock)->request.reqid) +#define USOCKET_XID(sock) ((sock)->request.xid) +#define USOCKET_DOMAIN(sock) ((sock)->domain) +#define USOCKET_TYPE(sock) ((sock)->type) +#define USOCKET_PROTOCOL(sock) ((sock)->protocol) +#define USOCKET_REQADDRLEN(sock) ((sock)->sock_req.addrbuflen.addr.addrlen) +#define USOCKET_REQADDR(sock) ((sock)->sock_req.addrbuflen.addr.addr) +#define USOCKET_REQBACKLOG(sock) ((sock)->sock_req.backlog) +#define USOCKET_REQBUFLEN(sock) ((sock)->sock_req.addrbuflen.buflen) +#define USOCKET_REQOPTLEVEL(sock) ((sock)->sock_req.opt.level) +#define USOCKET_REQOPTOPT(sock) ((sock)->sock_req.opt.option) +#define USOCKET_REQOPTLEN(sock) ((sock)->sock_req.opt.optlen) +#define USOCKET_REQOPTVAL(sock) ((sock)->sock_req.opt.value) +#define USOCKET_STATE(sock) ((sock)->state) +#define USOCKET_ALTSOCKID(sock) ((sock)->altsockid) +#define USOCKET_USOCKID(sock) ((sock)->usockid) +#define USOCKET_REFID(sock) (&(sock)->refids) + +#define USOCKET_REP_RESPONSE(sock) ((sock)->sock_reply.outparams) +#define USOCKET_REP_RESULT(sock) (&(sock)->sock_reply.rep_result) +#define USOCKET_REP_ERRCODE(sock) (&(sock)->sock_reply.rep_errcode) +#define USOCKET_REP_ADDRLEN(sock) \ + (&(sock)->sock_reply.sock_reply_opt.addr.addrlen) +#define USOCKET_REP_ADDR(sock) \ + (&(sock)->sock_reply.sock_reply_opt.addr.addr) +#define USOCKET_REP_OPTLEN(sock) \ + (&(sock)->sock_reply.sock_reply_opt.opt.optlen) +#define USOCKET_REP_OPTVAL(sock) \ + (&(sock)->sock_reply.sock_reply_opt.opt.value[0]) + +#define USOCKET_SET_RESPONSE(sock, n, p) \ + do \ + { \ + int iii = (n); \ + if (iii < _OUTPUT_ARG_MAX) \ + { \ + (sock)->sock_reply.outparams[iii] = (p); \ + } \ + else \ + { \ + ASSERT(0); \ + } \ + } \ + while(0); + +#define USOCKET_SET_ALTSOCKID(sock, id) { (sock)->altsockid = id; } +#define USOCKET_SET_STATE(sock, st) { (sock)->state = st; } +#define USOCKET_SET_SELECTABLE(sock, rw) { \ + (sock)->select_condition |= (rw); \ +} +#define USOCKET_CLR_SELECTABLE(sock, rw) { \ + (sock)->select_condition &= ~(rw); \ +} + +#define IS_STATE_SELECTABLE(s) (((s)->state != SOCKET_STATE_CLOSED) \ + && ((s)->state != SOCKET_STATE_PREALLOC) \ + && ((s)->state != SOCKET_STATE_ABORTED) \ + && ((s)->state != SOCKET_STATE_CLOSING) \ + && ((s)->state != SOCKET_STATE_OPEN)) + +#define IS_STATE_READABLE(s) ((s)->select_condition & SELECT_READABLE) +#define IS_STATE_WRITABLE(s) ((s)->select_condition & SELECT_WRITABLE) + +#define IS_SMS_SOCKET(s) ((s)->type == SOCK_SMS) + +#define _OUTPUT_ARG_MAX 7 +#define _OPTVAL_LEN_MAX 16 + +#define usocket_smssock_writeready(d, s) \ + (usockif_sendtxready((d)->usockfd, USOCKET_USOCKID((s)))) Review Comment: ```suggestion (usockif_sendtxready((d)->usockfd, USOCKET_USOCKID(s))) ``` ########## include/lte/lte_log.h: ########## @@ -0,0 +1,187 @@ +/**************************************************************************** + * apps/include/lte/lte_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 __APPS_INCLUDE_LTE_LTE_LOG_H +#define __APPS_INCLUDE_LTE_LTE_LOG_H + +/* API call type + * + * | Sync API | + * | --------------- | + * | lte_log_collect | + * | lte_log_getlist | + * | lte_log_open | + * | lte_log_close | + * | lte_log_read | + * | lte_log_remove | + * | lte_log_lseek | + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <sys/types.h> +#include <nuttx/wireless/lte/lte.h> + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/* Collect LTE modem FW logs and store them in the LTE modem storage. + * + * [out] output_fname: Buffer to store the name of the saved file. + * If the saved file name is not needed, set it to NULL. + * [in] len: Buffer length for output_fname. Sets LTE_LOG_NAME_LEN, + * except when the saved file name is not needed. + * + * Return value : Returns 0 on success. On error, a negative value is + * returned. The following values may be returned + * in error cases. + * + * - ENOBUFS + * - ENOTSUP + * + */ + +int lte_log_collect(char output_fname[], size_t len); + +/* Get a list of logs stored in the LTE modem storage. + * + * [in] listsize: Number of arrays in which to store file names. The maximum + * number of arrays is LTE_LOG_LIST_SIZE. + * [in] fnamelen: Buffer length for list. Sets LTE_LOG_NAME_LEN. + * [in] list: Buffer to store the list of saved file names. + * + * Return value : Returns the number of stored file names on success. + * On error, a negative value is returned. The following + * values may be returned in error cases. + * + * - EINVAL + * - ENOBUFS + * - ENOTSUP + * + */ + +int lte_log_getlist(size_t listsize, size_t fnamelen, + char list[listsize][fnamelen]); + +#ifdef CONFIG_LTE_LAPI_LOG_ACCESS + +/* Open a log file on LTE modem. + * + * [in] filename: Log file name to open. + * + * Return value : Returns the file descriptor on success. + * On error, a negative value is returned. The following + * values may be returned in error cases. + * + * - EINVAL + * - ENAMETOOLONG + * - ENOTSUP + * + */ + +int lte_log_open(const char *filename); + +/* Close a log file descriptor. + * + * [in] fd: File descriptor. + * + * Return value : Returns the 0 on success. + * On error, a negative value is returned. The following + * values may be returned in error cases. + * + * - EINVAL + * - ENOTSUP + * + */ + +int lte_log_close(int fd); + +/* Read data from log file on LTE modem. + * + * [in] fd: File descriptor. + * [out] buf: Buffer to read. + * [in] len: Read length. + * + * Return value : Returns the number of bytes read on success. + * On error, a negative value is returned. The following + * values may be returned in error cases. + * + * - EINVAL + * - ENOTSUP + * + */ + +ssize_t lte_log_read(int fd, void *buf, size_t len); + +/* Remove a file on LTE modem. + * + * [in] filename: Log file name to remove. + * + * Return value : Returns the 0 on success. + * On error, a negative value is returned. The following + * values may be returned in error cases. + * + * - ENAMETOOLONG + * - ENOTSUP + * + */ + +int lte_log_remove(const char *filename); Review Comment: FAR ########## lte/alt1250/alt1250_atcmd.c: ########## @@ -0,0 +1,932 @@ +/**************************************************************************** + * apps/lte/alt1250/alt1250_atcmd.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <nuttx/net/usrsock.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "alt1250_dbg.h" +#include "alt1250_daemon.h" +#include "alt1250_atcmd.h" +#include "alt1250_devif.h" +#include "alt1250_postproc.h" +#include "alt1250_container.h" +#include "alt1250_usockevent.h" + +#include <lte/lte_lwm2m.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Data Type + ****************************************************************************/ + +struct atcmd_postprocarg_t +{ + atcmd_postproc_t proc; + unsigned long arg; +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static void *atcmd_oargs[3]; Review Comment: FAR ########## include/lte/lte_log.h: ########## @@ -0,0 +1,187 @@ +/**************************************************************************** + * apps/include/lte/lte_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 __APPS_INCLUDE_LTE_LTE_LOG_H +#define __APPS_INCLUDE_LTE_LTE_LOG_H + +/* API call type + * + * | Sync API | + * | --------------- | + * | lte_log_collect | + * | lte_log_getlist | + * | lte_log_open | + * | lte_log_close | + * | lte_log_read | + * | lte_log_remove | + * | lte_log_lseek | + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <sys/types.h> +#include <nuttx/wireless/lte/lte.h> + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/* Collect LTE modem FW logs and store them in the LTE modem storage. + * + * [out] output_fname: Buffer to store the name of the saved file. + * If the saved file name is not needed, set it to NULL. + * [in] len: Buffer length for output_fname. Sets LTE_LOG_NAME_LEN, + * except when the saved file name is not needed. + * + * Return value : Returns 0 on success. On error, a negative value is + * returned. The following values may be returned + * in error cases. + * + * - ENOBUFS + * - ENOTSUP + * + */ + +int lte_log_collect(char output_fname[], size_t len); Review Comment: Maybe can go with more traditional `char *output_fname`. I'm not sure if C89 will allow such constructions ########## lte/alt1250/alt1250_socket.h: ########## @@ -0,0 +1,249 @@ +/**************************************************************************** + * apps/lte/alt1250/alt1250_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 __LTE_ALT1250_ALT1250_SOCKET_H__ +#define __LTE_ALT1250_ALT1250_SOCKET_H__ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/net/usrsock.h> +#include <nuttx/net/sms.h> +#include <assert.h> + +#include "alt1250_usockif.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define SELECT_WRITABLE (1 << 1) +#define SELECT_READABLE (1 << 2) +#define SELECTABLE_MASK (SELECT_WRITABLE | SELECT_READABLE) + +#define USOCKET_SET_REQUEST(sock, _reqid, _xid) { \ + (sock)->request.reqid = _reqid; \ + (sock)->request.xid = _xid; \ +} + +#define USOCKET_SET_SOCKTYPE(sock, _domain, _type, _protocol) { \ + (sock)->domain = _domain; \ + (sock)->type = _type; \ + (sock)->protocol = _protocol; \ +} + +#define USOCKET_SET_REQADDRLEN(sock, _addrlen) \ + { (sock)->sock_req.addrbuflen.addr.addrlen = _addrlen; } + +#define USOCKET_SET_REQBACKLOG(sock, _backlog) \ + { (sock)->sock_req.backlog = _backlog; } + +#define USOCKET_SET_REQBUFLEN(sock, _buflen) \ + { (sock)->sock_req.addrbuflen.buflen = _buflen; } + +#define USOCKET_SET_REQSOCKOPT(sock, _level, _opt, _optlen) { \ + (sock)->sock_req.opt.level = _level; \ + (sock)->sock_req.opt.option = _opt; \ + (sock)->sock_req.opt.optlen = _optlen; \ +} + +#define USOCKET_REQID(sock) ((sock)->request.reqid) +#define USOCKET_XID(sock) ((sock)->request.xid) +#define USOCKET_DOMAIN(sock) ((sock)->domain) +#define USOCKET_TYPE(sock) ((sock)->type) +#define USOCKET_PROTOCOL(sock) ((sock)->protocol) +#define USOCKET_REQADDRLEN(sock) ((sock)->sock_req.addrbuflen.addr.addrlen) +#define USOCKET_REQADDR(sock) ((sock)->sock_req.addrbuflen.addr.addr) +#define USOCKET_REQBACKLOG(sock) ((sock)->sock_req.backlog) +#define USOCKET_REQBUFLEN(sock) ((sock)->sock_req.addrbuflen.buflen) +#define USOCKET_REQOPTLEVEL(sock) ((sock)->sock_req.opt.level) +#define USOCKET_REQOPTOPT(sock) ((sock)->sock_req.opt.option) +#define USOCKET_REQOPTLEN(sock) ((sock)->sock_req.opt.optlen) +#define USOCKET_REQOPTVAL(sock) ((sock)->sock_req.opt.value) +#define USOCKET_STATE(sock) ((sock)->state) +#define USOCKET_ALTSOCKID(sock) ((sock)->altsockid) +#define USOCKET_USOCKID(sock) ((sock)->usockid) +#define USOCKET_REFID(sock) (&(sock)->refids) + +#define USOCKET_REP_RESPONSE(sock) ((sock)->sock_reply.outparams) +#define USOCKET_REP_RESULT(sock) (&(sock)->sock_reply.rep_result) +#define USOCKET_REP_ERRCODE(sock) (&(sock)->sock_reply.rep_errcode) +#define USOCKET_REP_ADDRLEN(sock) \ + (&(sock)->sock_reply.sock_reply_opt.addr.addrlen) +#define USOCKET_REP_ADDR(sock) \ + (&(sock)->sock_reply.sock_reply_opt.addr.addr) +#define USOCKET_REP_OPTLEN(sock) \ + (&(sock)->sock_reply.sock_reply_opt.opt.optlen) +#define USOCKET_REP_OPTVAL(sock) \ + (&(sock)->sock_reply.sock_reply_opt.opt.value[0]) + +#define USOCKET_SET_RESPONSE(sock, n, p) \ + do \ + { \ + int iii = (n); \ + if (iii < _OUTPUT_ARG_MAX) \ + { \ + (sock)->sock_reply.outparams[iii] = (p); \ + } \ + else \ + { \ + ASSERT(0); \ + } \ + } \ + while(0); Review Comment: ```suggestion while(0) ``` ########## include/lte/lte_lwm2m.h: ########## @@ -0,0 +1,323 @@ +/**************************************************************************** + * apps/include/lte/lte_lwm2m.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 __APPS_INCLUDE_LTE_LTE_LWM2M_H +#define __APPS_INCLUDE_LTE_LTE_LWM2M_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <stdint.h> +#include <nuttx/wireless/lte/lte.h> + +#define LWM2MSTUB_RESOURCE_HANDLENOCARE (0) +#define LWM2MSTUB_RESOURCE_HANDLEHOST (1) +#define LWM2MSTUB_RESOURCE_HANDLEMODEMH (2) + +#define LWM2MSTUB_MAX_WRITE_SIZE (1500) +#define LWM2MSTUB_MAX_TOKEN_SIZE (8 * 2 + 1) + +#define LWM2MSTUB_MAX_SERVER_NAME (256) +#define LWM2MSTUB_MAX_DEVID (256) +#define LWM2MSTUB_MAX_SEQKEY (256) + +#define LWM2MSTUB_CONDVALID_MINPERIOD (1<<0) +#define LWM2MSTUB_CONDVALID_MAXPERIOD (1<<1) +#define LWM2MSTUB_CONDVALID_GRATERTHAN (1<<2) +#define LWM2MSTUB_CONDVALID_LESSTHAN (1<<3) +#define LWM2MSTUB_CONDVALID_STEP (1<<4) + +#define LWM2MSTUB_FWUP_PEND_DL (0) +#define LWM2MSTUB_FWUP_PEND_UPD (1) +#define LWM2MSTUB_FWUP_COMP_DL (2) +#define LWM2MSTUB_FWUP_FAIL_DL (3) +#define LWM2MSTUB_FWUP_CANCELED (4) + +#define LWM2MSTUB_CMD_REGISTER (0) +#define LWM2MSTUB_CMD_DEREGISTER (1) +#define LWM2MSTUB_CMD_UPDATERESIGER (2) + +#define LWM2MSTUB_STATE_NOTREGISTERD (0) +#define LWM2MSTUB_STATE_REGISTPENDING (1) +#define LWM2MSTUB_STATE_REGISTERD (2) +#define LWM2MSTUB_STATE_REGISTERFAILED (3) +#define LWM2MSTUB_STATE_UPDATEPENDING (4) +#define LWM2MSTUB_STATE_DEREGISTPENDING (5) +#define LWM2MSTUB_STATE_BSHOLDOFF (6) +#define LWM2MSTUB_STATE_BSREQUESTED (7) +#define LWM2MSTUB_STATE_BSONGOING (8) +#define LWM2MSTUB_STATE_BSDONE (9) +#define LWM2MSTUB_STATE_BSFAILED (10) + +#define LWM2MSTUB_RESOP_READ (0) +#define LWM2MSTUB_RESOP_WRITE (1) +#define LWM2MSTUB_RESOP_RW (2) +#define LWM2MSTUB_RESOP_EXEC (3) + +#define LWM2MSTUB_RESINST_SINGLE (0) +#define LWM2MSTUB_RESINST_MULTI (1) + +#define LWM2MSTUB_RESDATA_NONE (0) +#define LWM2MSTUB_RESDATA_STRING (1) +#define LWM2MSTUB_RESDATA_INT (2) +#define LWM2MSTUB_RESDATA_UNSIGNED (3) +#define LWM2MSTUB_RESDATA_FLOAT (4) +#define LWM2MSTUB_RESDATA_BOOL (5) +#define LWM2MSTUB_RESDATA_OPAQUE (6) +#define LWM2MSTUB_RESDATA_TIME (7) +#define LWM2MSTUB_RESDATA_OBJLINK (8) + +#define LWM2MSTUB_SECUREMODE_PSK (0) +#define LWM2MSTUB_SECUREMODE_RPK (1) +#define LWM2MSTUB_SECUREMODE_CERT (2) +#define LWM2MSTUB_SECUREMODE_NOSEC (3) +#define LWM2MSTUB_SECUREMODE_CERTEST (4) + +#define LWM2MSTUB_CONNECT_REGISTER (0) +#define LWM2MSTUB_CONNECT_DEREGISTER (1) +#define LWM2MSTUB_CONNECT_REREGISTER (2) +#define LWM2MSTUB_CONNECT_BOOTSTRAP (3) + +#define LWM2MSTUB_RESP_CHANGED (0) +#define LWM2MSTUB_RESP_CONTENT (1) +#define LWM2MSTUB_RESP_BADREQ (2) +#define LWM2MSTUB_RESP_UNAUTH (3) +#define LWM2MSTUB_RESP_NOURI (4) +#define LWM2MSTUB_RESP_NOTALLOW (5) +#define LWM2MSTUB_RESP_NOTACCEPT (6) +#define LWM2MSTUB_RESP_UNSUPPORT (7) +#define LWM2MSTUB_RESP_INTERNALERROR (8) + +/* Client received "Write" operation */ + +#define LWM2MSTUB_OP_WRITE (0) + +/* Client received "Execute" operation */ + +#define LWM2MSTUB_OP_EXEC (1) + +/* Client received "Write Attributes" operation */ + +#define LWM2MSTUB_OP_WATTR (4) + +/* Client received "Discover" operation */ + +#define LWM2MSTUB_OP_DISCOVER (5) + +/* Client received "Read" operation */ + +#define LWM2MSTUB_OP_READ (6) + +/* Client received "Observe" operation */ + +#define LWM2MSTUB_OP_OBSERVE (7) + +/* Client received "Cancel observation" operation */ + +#define LWM2MSTUB_OP_CANCELOBS (8) + +/* Client is offline now. */ + +#define LWM2MSTUB_OP_OFFLINE (9) + +/* Client is online now. */ + +#define LWM2MSTUB_OP_ONLINE (10) + +/* Client sent observation notification to a server. */ + +#define LWM2MSTUB_OP_SENDNOTICE (11) + +/* Client received wakeup SMS. */ + +#define LWM2MSTUB_OP_RCVWUP (12) + +/* Client received notification acknowledge. */ + +#define LWM2MSTUB_OP_RCVOBSACK (13) + +/* Client ON: LMM2M client exits Client OFF state + * and tries to re-connect server due to explicitly + * AT Command registration request. + */ + +#define LWM2MSTUB_OP_CLIENTON (14) + +/* Client OFF: LWM2M client has exhausted server connection retries. */ + +#define LWM2MSTUB_OP_CLIENTOFF (15) + +/* Confirmable NOTIFY failed. */ + +#define LWM2MSTUB_OP_FAILNOTIFY (16) + +/* Bootstrap finished and completed successfully. */ + +#define LWM2MSTUB_OP_BSFINISH (20) + +/* Registration finished and completed successfully. + * all server observation requests are cleaned, + * the host should clean host objects observation rules too. + */ + +#define LWM2MSTUB_OP_REGSUCCESS (21) + +/* Register update finished and completed successfully. */ + +#define LWM2MSTUB_OP_REGUPDATED (22) + +/* De-register finished and completed successfully. */ + +#define LWM2MSTUB_OP_DEREGSUCCESS (23) + +/* Notification was not saved and not sent to server */ + +#define LWM2MSTUB_OP_NOSENDNOTICE (24) + +struct lwm2mstub_resource_s +{ + int res_id; + int operation; + int inst_type; + int data_type; + int handl; +}; + +struct lwm2mstub_instance_s +{ + int object_id; + int object_inst; + int res_id; + int res_inst; +}; + +struct lwm2mstub_ovcondition_s +{ + uint8_t valid_mask; + unsigned int min_period; + unsigned int max_period; + double gt_cond; + double lt_cond; + double step_val; +}; + +struct lwm2mstub_serverinfo_s +{ + int object_inst; + int state; + bool bootstrap; + bool nonip; + int security_mode; + uint32_t lifetime; + char server_uri[LWM2MSTUB_MAX_SERVER_NAME]; + char device_id[LWM2MSTUB_MAX_DEVID]; + char security_key[LWM2MSTUB_MAX_SEQKEY]; +}; + +typedef void (*lwm2mstub_write_cb_t)(int seq_no, int srv_id, + struct lwm2mstub_instance_s *inst, char *value, int len); + +typedef void (*lwm2mstub_read_cb_t)(int seq_no, int srv_id, + struct lwm2mstub_instance_s *inst); + +typedef void (*lwm2mstub_exec_cb_t)(int seq_no, int srv_id, + struct lwm2mstub_instance_s *inst); + +typedef void (*lwm2mstub_ovstart_cb_t)(int seq_no, int srv_id, + struct lwm2mstub_instance_s *inst, char *token, + struct lwm2mstub_ovcondition_s *cond); + +typedef void (*lwm2mstub_ovstop_cb_t)(int seq_no, int srv_id, + struct lwm2mstub_instance_s *inst, char *token); Review Comment: FAR ########## lte/alt1250/alt1250_atcmd.c: ########## @@ -0,0 +1,932 @@ +/**************************************************************************** + * apps/lte/alt1250/alt1250_atcmd.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <nuttx/net/usrsock.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "alt1250_dbg.h" +#include "alt1250_daemon.h" +#include "alt1250_atcmd.h" +#include "alt1250_devif.h" +#include "alt1250_postproc.h" +#include "alt1250_container.h" +#include "alt1250_usockevent.h" + +#include <lte/lte_lwm2m.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Data Type + ****************************************************************************/ + +struct atcmd_postprocarg_t +{ + atcmd_postproc_t proc; + unsigned long arg; +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static void *atcmd_oargs[3]; +static int atcmd_reply_len; +static struct atcmd_postprocarg_t postproc_argument; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * name: postproc_internal_atcmd + ****************************************************************************/ + +static int postproc_internal_atcmd(FAR struct alt1250_s *dev, + FAR struct alt_container_s *reply, + FAR struct usock_s *usock, + FAR int32_t *usock_result, + FAR uint32_t *usock_xid, + FAR struct usock_ackinfo_s *ackinfo, + unsigned long arg) +{ + int ret = REP_NO_ACK; + struct atcmd_postprocarg_t *parg = (struct atcmd_postprocarg_t *)arg; + + dev->recvfrom_processing = false; + + err_alt1250("Internal ATCMD Resp : %s\n", (char *)reply->outparam[0]); + + if (parg->proc != NULL) + { + ret = parg->proc(dev, reply, + (FAR char *)reply->outparam[0], *(int *)reply->outparam[2], Review Comment: ```suggestion (FAR char *)reply->outparam[0], *(FAR int *)reply->outparam[2], ``` ########## lte/alt1250/alt1250_util.h: ########## @@ -0,0 +1,49 @@ +/**************************************************************************** + * apps/lte/alt1250/alt1250_util.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 __LTE_ALT1250_ALT1250_UTIL_H__ Review Comment: ```suggestion #ifndef __APPS_LTE_ALT1250_ALT1250_UTIL_H ``` ########## lte/alt1250/alt1250_usockevent.h: ########## @@ -0,0 +1,74 @@ +/**************************************************************************** + * apps/lte/alt1250/alt1250_usockevent.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 __LTE_ALT1250_ALT1250_USOCKEVENT_H__ Review Comment: ```suggestion #ifndef __APPS_LTE_ALT1250_ALT1250_USOCKEVENT_H ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
