Arduino库教程-GSM-Band Management
Band Management
这个例子是提供给管理GSM shield的工具的一部分,展示了如何使用GSM库来管理调制解调器连接的GSM频带。
更多通常GSM频带的信息查看 http://www.worldtimezone.com/gsm.html。典型初始配置如下:
Europe, Africa, Middle East: E-GSM(900)+DCS(1800)
USA, Canada, South America: GSM(850)+PCS(1900)
Mexico: PCS(1900)
Brazil: GSM(850)+E-GSM(900)+DCS(1800)+PCS(1900)
硬件要求
- Arduino or Genuino Board
- Arduino + Telefonica GSM/GPRS Shield
- SIM card
电路
这是在一块Arduino或者Genuino开发板上的Arduino GSM Shield图
样例代码
- 这个程序,用于Arduino GSM shield,检查调制解调器的当前配置的频带,允许你改变它。
它。
/*
Band Management
This sketch, for the Arduino GSM shield, checks the band
currently configured in the modem and allows you to change
it.
Please check http://www.worldtimezone.com/gsm.html
Usual configurations:
Europe, Africa, Middle East: E-GSM(900)+DCS(1800)
USA, Canada, South America: GSM(850)+PCS(1900)
Mexico: PCS(1900)
Brazil: GSM(850)+E-GSM(900)+DCS(1800)+PCS(1900)
Circuit:
* GSM shield
created 12 June 2012
by Javier Zorzano, Scott Fitzgerald
This example is in the public domain.
*/
// libraries
#include <GSM.h>
// initialize the library instance
GSMBand band;
void setup() {
// initialize serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// Beginning the band manager restarts the modem
Serial.println("Restarting modem...");
band.begin();
Serial.println("Modem restarted.");
};
void loop() {
// Get current band
String bandName = band.getBand(); // Get and print band name
Serial.print("Current band:");
Serial.println(bandName);
Serial.println("Want to change the band you’re on?");
String newBandName;
newBandName = askUser();
// Tell the user what we are about to do…
Serial.print("\nConfiguring band ");
Serial.println(newBandName);
// Change the band
boolean operationSuccess;
operationSuccess = band.setBand(newBandName);
// Tell the user if the operation was OK
if (operationSuccess) {
Serial.println("Success");
} else {
Serial.println("Error while changing band");
}
if (operationSuccess) {
while (true);
}
}
// This function offers the user different options
// through the Serial interface
// The user selects one
String askUser() {
String newBand;
Serial.println("Select band:");
// Print the different options
Serial.println("1 : E-GSM(900)");
Serial.println("2 : DCS(1800)");
Serial.println("3 : PCS(1900)");
Serial.println("4 : E-GSM(900)+DCS(1800) ex: Europe");
Serial.println("5 : GSM(850)+PCS(1900) Ex: USA, South Am.");
Serial.println("6 : GSM(850)+E-GSM(900)+DCS(1800)+PCS(1900)");
// Empty the incoming buffer
while (Serial.available()) {
Serial.read();
}
// Wait for an answer, just look at the first character
while (!Serial.available());
char c = Serial.read();
if (c == '1') {
newBand = GSM_MODE_EGSM;
} else if (c == '2') {
newBand = GSM_MODE_DCS;
} else if (c == '3') {
newBand = GSM_MODE_PCS;
} else if (c == '4') {
newBand = GSM_MODE_EGSM_DCS;
} else if (c == '5') {
newBand = GSM_MODE_GSM850_PCS;
} else if (c == '6') {
newBand = GSM_MODE_GSM850_EGSM_DCS_PCS;
} else {
newBand = "GSM_MODE_UNDEFINED";
}
return newBand;
}
[Get Code]
更多
Arduino GSM Shield – 完整的产品描述。
Getting started with the GSM Shield – 在几分钟内启动所有东西
GSM library – GSM 库的参考网页
GSMToolsTestGPRS - 试图用提供的APN和证书来通过GPRS访问互联网 。
GSMToolsGsmScanNetworks - 扫描可用网络和打印关于IMEI和SIM卡号码的信息。
GSMToolsPinManagement - 如何更改或删除引脚数。
GSMToolsTestModem - 测试看看GSM shield的调制解调器是否正确工作。
GSMToolsTestWebServer - 一个简单的Web服务器,没有任何答复,只打印客户端的请求和服务器IP地址。
GSMExamplesMakeVoiceCall - 如何用麦克风和扬声器进行语音通话。
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号