diff --git a/README.adoc b/README.adoc index 2f6bc23..116c4aa 100644 --- a/README.adoc +++ b/README.adoc @@ -1,16 +1,15 @@ -// Define the repository information in these attributes -:repository-owner: arduino-libraries -:repository-name: MKRNB +:repository-owner: marcus-peterson +:repository-name: MKRNB_v2 -= {repository-name} Library for Arduino = += MKRNB_v2 Library for Arduino = -image:https://github.com/{repository-owner}/{repository-name}/workflows/Compile%20Examples/badge.svg["Compile Examples Status", link="https://github.com/{repository-owner}/{repository-name}/actions?workflow=Compile+Examples"] -image:https://github.com/{repository-owner}/{repository-name}/workflows/Spell%20Check/badge.svg["Spell Check Status", link="https://github.com/{repository-owner}/{repository-name}/actions?workflow=Spell+Check"] +image:https://github.com/marcus-peterson/MKRNB_v2/workflows/Compile%20Examples/badge.svg["Compile Examples Status", link="https://github.com/marcus-peterson/MKRNB_v2/actions?workflow=Compile+Examples"] +image:https://github.com/marcus-peterson/MKRNB_v2/workflows/Spell%20Check/badge.svg["Spell Check Status", link="https://github.com/marcus-peterson/MKRNB_v2/actions?workflow=Spell+Check"] -This library enables an Arduino MKR NB 1500 board to connect to the internet over a NarrowBand IoT or LTE Cat M1 network. +This library enables an Arduino MKR NB 1500 board to connect to the internet over a NarrowBand IoT or LTE Cat M1 network. It is an extension of the original MKRNB library, designed to provide enhanced control and capabilities for commercial applications. -For more information about this library please visit us at -https://www.arduino.cc/en/Reference/{repository-name} +For more information about the source of this library please visit the official Arduino MKRNB documentation +https://www.arduino.cc/en/Reference/MKRNB == License == diff --git a/src/GPRS.cpp b/src/GPRS.cpp index 94223eb..1c2d07a 100644 --- a/src/GPRS.cpp +++ b/src/GPRS.cpp @@ -162,6 +162,37 @@ int GPRS::ready() return ready; } +//Check to see if the sim card that is inside the MKRNB is attached or detached to a LTE-M provideer +NB_NetworkStatus_t GPRS::checkAttachmentStatus() +{ + MODEM.setResponseDataStorage(&_response); + MODEM.send("AT+CGATT?"); + _state = GPRS_STATE_WAIT_CHECK_ATTACHED_RESPONSE; + + int ready = 0; + + while (ready == 0) { + ready = MODEM.ready(); + + if (ready > 1) { + _state = GPRS_STATE_IDLE; + _status = NB_ERROR; + break; + } + + delay(500); + } + + if (_response.indexOf("1,1") >= 0) { + _state = GPRS_STATE_IDLE; + return GPRS_READY; + } else { + _state = GPRS_STATE_IDLE; + return IDLE; + } +} + + IPAddress GPRS::getIPAddress() { String response; diff --git a/src/GPRS.h b/src/GPRS.h index a8e3bfa..30fac47 100644 --- a/src/GPRS.h +++ b/src/GPRS.h @@ -63,6 +63,8 @@ class GPRS { */ NB_NetworkStatus_t detachGPRS(bool synchronous = true); + NB_NetworkStatus_t checkAttachmentStatus(); + /** Get actual assigned IP address in IPAddress format @return IP address in IPAddress format */