/* * Copyright (c) 2022 OpenLuat & AirM2M * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef __LUAT_MOBILE_H__ #define __LUAT_MOBILE_H__ #include "luat_base.h" /** * @defgroup luatos_mobile 移动网络相关接口 * @{ */ /** * @brief 获取IMEI * * @param sim_id sim位置,对于双卡双待的设备,选0或者1,其他设备随意 * @param buff[OUT] IMEI数据 * @param buf_len 用户传入缓存的大小,如果底层数据量大于buf_len,只会传出buf_len大小的数据 * @return int <= 0错误 >0实际传出的大小 */ int luat_mobile_get_imei(int sim_id, char* buff, size_t buf_len); /** * @brief 获取SN,如果用户没有调用luat_mobile_set_sn接口写过SN,默认值为空 * * @param buff[OUT] SN数据 * @param buf_len 用户传入缓存的大小,EC618平台底层支持的最大长度为32字节,如果底层数据量大于buf_len,只会传出buf_len大小的数据 * @return int <= 0错误 >0实际传出的大小 */ int luat_mobile_get_sn(char* buff, size_t buf_len); /** * @brief 设置SN * * @param buff SN数据,必须是ascii值大于等于0x21小于等于0x7e的可见ascii字符 * @param buf_len SN数据长度;EC618平台底层支持的最大长度为32字节,如果buf_len大于32,只会保存前32字节的数据 * @return int = 0成功, = -1失败 */ int luat_mobile_set_sn(char* buff, uint8_t buf_len); /** * @brief 获取MUID,并不一定存在 * * @param buff[OUT] MUID数据 * @param buf_len 用户传入缓存的大小,如果底层数据量大于buf_len,只会传出buf_len大小的数据 * @return int <= 0错误 >0实际传出的大小 */ int luat_mobile_get_muid(char* buff, size_t buf_len); /** * @brief 获取SIM卡的ICCID * * @param sim_id sim位置,对于双卡双待的设备,选0或者1,其他设备随意 * @param buff[OUT] ICCID数据 * @param buf_len 用户传入缓存的大小,如果底层数据量大于buf_len,只会传出buf_len大小的数据 * @return int <= 0错误 >0实际传出的大小 */ int luat_mobile_get_iccid(int sim_id, char* buff, size_t buf_len); /** * @brief 获取SIM卡的IMSI * * @param sim_id sim位置,对于双卡双待的设备,选0或者1,其他设备随意 * @param buff[OUT] IMSI数据 * @param buf_len 用户传入缓存的大小,如果底层数据量大于buf_len,只会传出buf_len大小的数据 * @return int <= 0错误 >0实际传出的大小 */ int luat_mobile_get_imsi(int sim_id, char* buff, size_t buf_len); /** * @brief 当前使用的SIM卡的位置,并不一定支持 * * @param id[OUT] sim位置,对于双卡双待的设备,输出0或者1,其他设备输出0 * @return int =0成功,其他失败 */ int luat_mobile_get_sim_id(int *id); /** * @brief 改变使用的SIM卡的位置,并不一定支持 * * @param id sim位置,对于双卡的设备,选0或者1,其他为自动选择模式。非双卡的设备不支持 * @return int =0成功,其他失败 */ int luat_mobile_set_sim_id(int id); /** * @brief 获取配置的apn name,并不一定支持 * * @param sim_id sim位置,对于双卡双待的设备,选0或者1,其他设备随意 * @param cid cid位置 1~6 * @param buff[OUT] apn name * @param buf_len 用户传入缓存的大小,如果底层数据量大于buf_len,只会传出buf_len大小的数据 * @return int <= 0错误 >0实际传出的大小 */ int luat_mobile_get_apn(int sim_id, int cid, char* buff, size_t buf_len); /** * @brief 获取默认CID的apn name,并不一定支持 * * @param sim_id sim位置,对于双卡双待的设备,选0或者1,其他设备随意 * @param buff[OUT] apn name * @param buf_len 用户传入缓存的大小,如果底层数据量大于buf_len,只会传出buf_len大小的数据 * @return int <= 0错误 >0实际传出的大小 */ int luat_mobile_get_default_apn(int sim_id, char* buff, size_t buf_len); /** * @brief 进出飞行模式 * * @param index sim位置,对于双卡双待的设备,选0或者1,其他设备随意 * @param mode 飞行模式,1进入,0退出 * @return int =0成功,其他失败 */ int luat_mobile_set_flymode(int index, int mode); /** * @brief 飞行模式当前状态 * * @param index sim位置,对于双卡双待的设备,选0或者1,其他设备随意 * @return int <0 异常 =0飞行模式 =1正常工作 =4射频关闭 */ int luat_mobile_get_flymode(int index); #if (!defined __LUATOS__) || ((defined __LUATOS__) && (defined LUAT_USE_LWIP)) #include "lwip/opt.h" #include "lwip/netif.h" #include "lwip/inet.h" /** * @brief 获取已激活承载分配的本地ip地址 * * @param sim_id sim位置,对于双卡双待的设备,选0或者1,其他设备随意 * @param cid cid位置 1~6,没有使用专网APN的话,就是用1 * @param ip_v4, ipv4的IP地址 * @param ip_v6, ipv6的IP地址 * @return int =0成功,其他失败 */ int luat_mobile_get_local_ip(int sim_id, int cid, ip_addr_t *ip_v4, ip_addr_t *ip_v6); #endif /* -------------------------------------------------- cell info begin -------------------------------------------------- */ #define LUAT_MOBILE_CELL_MAX_NUM 9 typedef struct luat_mobile_gsm_service_cell_info { int cid; /**< Cell ID, (0 indicates information is not represent).*/ int mcc; /**< This field should be ignored when cid is not present*/ int mnc; /**< This field should be ignored when cid is not present*/ int lac; /**< Location area code.(This field should be ignord when cid is not present). */ int arfcn; /**< Absolute RF channel number. */ int bsic; /**< Base station identity code. (0 indicates information is not present). */ int rssi; /**< Receive signal strength, Value range: rxlev-111 for dbm format */ }luat_mobile_gsm_service_cell_info_t; typedef struct luat_mobile_gsm_cell_info { int cid; /**Cell ID, (0 indicates information is not represent).*/ int mcc; /**This field should be ignored when cid is not present*/ int mnc; /**This field should be ignored when cid is not present*/ int lac; /**Location area code.(This field should be ignord when cid is not present). */ int arfcn; /**Absolute RF channel number. */ int bsic; /**Base station identity code. (0 indicates information is not present). */ int rssi; /**< Receive signal strength, Value range: rxlev-111 for dbm format */ }luat_mobile_gsm_cell_info_t; typedef struct luat_mobile_lte_service_cell_info { uint32_t cid; /**