1 Star 0 Fork 0

DFRobot / DFRobot_SIM

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

DFROBOT_SIM Arduino库

这是一个AT通信模块的基类库,DFRobot的很多通信设备都依赖于它。

产品链接(链接到中文商城)

SKU: 

目录

概述

这个库将一些通信的AT指令封装成函数接口,方便使用的基类库。

库安装

使用此库前,请首先下载库文件,将其粘贴到\Arduino\libraries目录中,然后打开examples文件夹并在该文件夹中运行演示。

方法

class DFRobot_SIMcore{
 /**
   * @fn DFRobot_SIMcore
   * @brief DFRobot_SIMcore 抽象类的构造函数。构建串行端口。
   * @param s 抽象类的类指针对象,这里可以填入串口对象的指针。
   */
  DFRobot_SIMcore(Stream *s);
  ~DFRobot_SIMcore(){};

  /**
   * @fn begin
   * @brief Init specified module
   * @return bool类型,表示初始化状态
   * @retval true Success 
   * @retval false Failed
   */
  bool begin(void);

  /**
   * @fn checkSendCmd
   * @brief 发送数据,比较返回的数据是否准确
   * @param cmd 需要发送的命令
   * @param resp 比较返回的数据
   * @param timeout 超时时间(单位:毫秒)
   * @return bool类型,表示返回比较数据状态
   * @retval true 相同 
   * @retval false 不同
   */
  bool checkSendCmd(const char* cmd = NULL, const char* resp = NULL, uint32_t timeout = 1000);

  /**
   * @fn checkReadable
   * @brief 判断串口中有多少数据
   * @return 返回串口中数据个数
   */
  int checkReadable(void);

  /**
   * @fn sendCmd
   * @brief 发送命令
   * @param cmd 发送的命令
   */
  void sendCmd(const char* cmd);

  /**
   * @fn sendBuff
   * @brief 发送数据
   * @param buff 需要发送的数据
   * @param num 发送数据的长度
   */
  void sendBuff(const char* buff, size_t num);

  /**
   * @fn sendString
   * @brief 通过串口发送字符串
   * @param buff 需要发送字符串的buffer
   */
  void sendString(const char* buff);

  /**
   * @fn cleanBuffer
   * @brief 清空buffer中的数据
   * @param buffer 需要清空的buffer
   * @param count 需要清空数据长度
   */
  void cleanBuffer(char *buffer, int count);

  /**
   * @fn readBuffer
   * @brief 解析串口返回数据
   * @param buffer 接受数据的buffer
   * @param count  接收数据长度
   * @param timeout 超时时间(单位:毫秒)
   * @return 接收数据长度
   */
  uint16_t readBuffer(char *buffer = NULL, uint16_t count = 1, uint32_t timeout =1000);
 
  /**
   * @fn turnOFF
   * @brief 关闭SIM7000X模块
   * @return bool类型,表示关闭状态
   * @retval true Success 
   * @retval false Failed
   */
  bool turnOFF(void);

  /**
   * @fn setCommandCounter
   * @brief 设置命令计数器
   * @param c 命令值
   */
  void setCommandCounter(uint8_t c);

  /**
   * @fn getCommandCounter
   * @brief 获取命令计数器
   * @return 命令计数值 
   */
  uint8_t	getCommandCounter();

  /**
   * @fn get_String
   * @brief 打印串口返回的字符串
   */
  void get_String(void);

  /**
   * @fn closeCommand
   * @brief 关闭控制命令
   */
  void closeCommand(void);
};
class DFRobot_SIMclient:DFRobot_SIMcore{
 /**
   * @fn checkSignalQuality
   * @brief 获取信号强度 
   * @return 返回信号强度
   */
  int checkSignalQuality(void);

  /**
   * @fn initNet
   * @brief 检测网络是否正常
   * @return bool类型,表示获取状态
   * @retval true Success 
   * @retval false Failed
   */
  bool initNet(void);

  /**
   * @fn connect
   * @brief 连接服务器
   * @param server 连接服务器地址
   * @param ptl 通信协议选择
   * @param port 端口号
   * @return bool类型,表示连接服务器状态
   * @retval true Success 
   * @retval false Failed
   */
  bool connect(char *server,eProtocol ptl,int port);

  /**
   * @fn send
   * @brief 发送数据到连接的服务器
   * @param data 发送的数据
   * @return bool类型,表示发送数据状态
   * @retval true Success 
   * @retval false Failed
   */
  bool send(char *data);

  /**
   * @fn send
   * @brief 发送数据到连接的服务器
   * @param buffer 发送的数据
   * @param len 发送数据长度
   * @return bool类型,表示发送数据状态
   * @retval true Success 
   * @retval false Failed
   */
  bool send(char *buffer,size_t len);

  /**
   * @fn close
   * @brief 断开连接的服务器
   * @return bool类型,表示断开服务器状态
   * @retval true Success 
   * @retval false Failed
   */
  bool close(void);
};
class DFRobot_SIMphonecall:DFRobot_SIMcore{
 /**
   * @fn voiceCall
   * @brief 呼叫指定电话号码
   * @param number 需要呼叫的电话号码
   * @return bool类型,表示呼叫状态状态
   * @retval true Success 
   * @retval false Failed
   */
  bool voiceCall(const char* number);

  /**
   * @fn hangCall
   * @brief 挂断电话
   */
  void hangCall(void);
};
class DFRobot_SIMsms:DFRobot_SIMcore{
 /**
  * @fn beginSMS
  * @brief 初始化发送短信
  * @param to 要发送短信的地址
  * @return bool类型,表示初始化SMS状态
   * @retval true Success 
   * @retval false Failed
  */
  bool beginSMS(const char* to);

 /**
  * @fn editSMS
  * @brief 发送短信
  * @param c 发送短信内容
  */
  void editSMS(const char* c);

 /**
  * @fn sendSMS
  * @brief 发送短信
  * @return bool类型,表示发送短信状态
   * @retval true Success 
   * @retval false Failed
  */
  bool sendSMS(void);
};

历史

  • 2017/8/30 - 1.0.0 版本
  • 2021/09/16 - 1.0.1 版本

创作者

Copyright 2010 DFRobot Co.Ltd 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.

简介

暂无描述 展开 收起
C++ 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C++
1
https://gitee.com/dfrobot/DFRobot_SIM.git
git@gitee.com:dfrobot/DFRobot_SIM.git
dfrobot
DFRobot_SIM
DFRobot_SIM
master

搜索帮助