说明
返回 MKRWAN 固件版本
用法
modem.version();
返回
包含固件版本的字符串
示例
/*
First Configuration
This sketch demonstrates the usage of MKR WAN 1300/1310 LoRa module.
This example code is in the public domain.
*/
#include <MKRWAN.h>
LoRaModem modem;
// Uncomment if using the Murata chip as a module
// LoRaModem modem(Serial1);
String appEui;
String appKey;
String devAddr;
String nwkSKey;
String appSKey;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
while (!Serial);
Serial.println("Welcome to MKR WAN 1300/1310 first configuration sketch");
Serial.println("Register to your favourite LoRa network and we are ready to go!");
// change this to your regional band (eg. US915, AS923, ...)
if (!modem.begin(EU868)) {
Serial.println("Failed to start module");
while (1) {}
};
Serial.print("Your module version is: ");
Serial.println(modem.version());
if (modem.version() != ARDUINO_FW_VERSION) {
Serial.println("Please make sure that the latest modem firmware is installed.");
Serial.println("To update the firmware upload the 'MKRWANFWUpdate_standalone.ino' sketch.");
}
Serial.print("Your device EUI is: ");
Serial.println(modem.deviceEUI());
int mode = 0;
while (mode != 1 && mode != 2) {
Serial.println("Are you connecting via OTAA (1) or ABP (2)?");
while (!Serial.available());
mode = Serial.readStringUntil('\n').toInt();
}
int connected;
if (mode == 1) {
Serial.println("Enter your APP EUI");
while (!Serial.available());
appEui = Serial.readStringUntil('\n');
Serial.println("Enter your APP KEY");
while (!Serial.available());
appKey = Serial.readStringUntil('\n');
appKey.trim();
appEui.trim();
connected = modem.joinOTAA(appEui, appKey);
} else if (mode == 2) {
Serial.println("Enter your Device Address");
while (!Serial.available());
devAddr = Serial.readStringUntil('\n');
Serial.println("Enter your NWS KEY");
while (!Serial.available());
nwkSKey = Serial.readStringUntil('\n');
Serial.println("Enter your APP SKEY");
while (!Serial.available());
appSKey = Serial.readStringUntil('\n');
devAddr.trim();
nwkSKey.trim();
appSKey.trim();
connected = modem.joinABP(devAddr, nwkSKey, appSKey);
}
if (!connected) {
Serial.println("Something went wrong; are you indoor? Move near a window and retry");
while (1) {}
}
delay(5000);
int err;
modem.setPort(3);
modem.beginPacket();
modem.print("HeLoRA world!");
err = modem.endPacket(true);
if (err > 0) {
Serial.println("Message sent correctly!");
} else {
Serial.println("Error sending message :(");
}
}
void loop() {
while (modem.available()) {
Serial.write(modem.read());
}
modem.poll();
}
相关用法
- Arduino MKRWAN - available()用法及代码示例
- Arduino MKRWAN - version()用法及代码示例
- Arduino MKRWAN - endPacket()用法及代码示例
- Arduino MKRWAN - print()用法及代码示例
- Arduino MKRWAN - begin()用法及代码示例
- Arduino MKRWAN - joinABP()用法及代码示例
- Arduino MKRWAN - restart()用法及代码示例
- Arduino MKRWAN - joinOTAA()用法及代码示例
- Arduino MKRWAN - read()用法及代码示例
- Arduino MKRWAN - beginPacket()用法及代码示例
- Arduino MKRGSM - gprs.attachGPRS()用法及代码示例
- Arduino MKRGSM - sms.read()用法及代码示例
- Arduino MKRNB - getCurrentCarrier()用法及代码示例
- Arduino MKRNB - getIMEI()用法及代码示例
- Arduino MKRGSM - sms.print()用法及代码示例
- Arduino MKRNB - endSMS()用法及代码示例
- Arduino MKRGSM - client.connected()用法及代码示例
- Arduino MKRGSM - voice.answerCall()用法及代码示例
- Arduino MKRGSM - voice.hangCall()用法及代码示例
- Arduino MKRGSM - sms.write()用法及代码示例
- Arduino MKRNB - connected()用法及代码示例
- Arduino MKRGSM - gsm.shutdown()用法及代码示例
- Arduino MKRGSM - modem.getIMEI()用法及代码示例
- Arduino MKRGSM - sms.available()用法及代码示例
- Arduino MKRNB - shutdown()用法及代码示例
注:本文由纯净天空筛选整理自arduino.cc大神的英文原创作品 MKRWAN - deviceEUI()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。