GSM constructor
描述
GSM 类别是 GSM 函式库的基础,在使用任何 GSM 函式库的功能前,都要用 GSM 类别初始化 Arduino GSM shield。
语法
GSM GSMAccess
GSM GSMAccess(debug)
参数
debug:debug 是 boolean 型态的参数,如果给予 true 将会把传送给 Arduino GSM shield 的 AT 指令输出至序列埠监控视窗,反之不会输出 AT 指令。如果没给参数,预设为 false。
范例
// 函式库
#include <GSM.h>
// PIN 码
#define PINNUMBER ""
// 初始化 GSM 函式库
GSM gsmAccess;
void setup()
{
// 初始化 Serial
Serial.begin(9600);
// 连线状态
boolean notConnected = true;
// 启动 Arduino GSM shield,如果你的 SIM 卡有 PIN 码,请当作 begin() 的参数
while(notConnected)
{
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
{
notConnected = false;
Serial.println("Connected to network");
}
else
{
Serial.println("Not connected");
delay(1000);
}
}
}
void loop()
{
// 不做任何事
}
See also
- begin()
- shutdown()
The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.
