diff --git a/README.md b/README.md index fb34bcc..dd57938 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -![Library Version](https://img.shields.io/badge/Version-1.0.1-green) +![Library Version](https://img.shields.io/badge/Version-1.1.0-green) # AIS Library diff --git a/library.json b/library.json index 17a58f3..1d0ca20 100644 --- a/library.json +++ b/library.json @@ -14,6 +14,6 @@ "type": "git", "url": "https://github.com/AIS-DeviceInnovation/Magellan_BC95.git" }, - "version": "1.0.1", + "version": "1.1.0", "platforms": "*" } diff --git a/library.properties b/library.properties index 944a3ce..3230c0a 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Magellan_BC95 -version=1.0.1 +version=1.1.0 author=AIS IoT Alliance Program maintainer= AIS IoT Alliance Program sentence= AIS Magellan Library; easy way to integrate IoT Device to Magellan using Arduino Platform. @@ -7,5 +7,5 @@ paragraph= Fully compatible with DEVIO NB-SHIELD I. category=Cellular Communication url= https://github.com/AIS-DeviceInnovation/Magellan_BC95 architectures=* -includes=AT_BC95.h,board.h +includes=AT_BC95.h,AltSoftSerial.h diff --git a/src/AIS_BC95_API.cpp b/src/AIS_BC95_API.cpp index 6687ff4..2a0e91e 100644 --- a/src/AIS_BC95_API.cpp +++ b/src/AIS_BC95_API.cpp @@ -27,13 +27,13 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -AIS_BC95_API v1.0.1 NB-IoT. +AIS_BC95_API v1.1.0 NB-IoT. support Quectel BC95 NB-IoT with AT command Author: Device Innovation team Create Date: 3 February 2020. -Modified: 5 June 2020. +Modified: 22 July 2020. Released for private usage. */ @@ -139,4 +139,15 @@ String AIS_BC95_API::getIMEI(){ return at_bc95.getIMEI(); } +radio AIS_BC95_API::getRadioStat(){ + return at_bc95.getRadioStat(); +} + +dateTime AIS_BC95_API::getClock(unsigned int timezone){ + return at_bc95.getClock(timezone); +} + +// bool AIS_BC95_API::checkPSMmode(){ +// return at_bc95.checkPSMmode(); +// } diff --git a/src/AIS_BC95_API.h b/src/AIS_BC95_API.h index 3cf2906..b84fe34 100644 --- a/src/AIS_BC95_API.h +++ b/src/AIS_BC95_API.h @@ -33,7 +33,7 @@ NB-IoT with AT command Author: Device Innovation team Create Date: 3 February 2020. -Modified: 12 May 2020. +Modified: 22 July 2020. Released for private usage. */ @@ -58,8 +58,10 @@ class AIS_BC95_API{ String getIMSI(); String getIMEI(); String getICCID(); + radio getRadioStat(); + dateTime getClock(unsigned int timezone=7); void pingIP(String IP); - bool checkPSMmode(); + // bool checkPSMmode(); void sendMsgHEX(String address,String desport,String payload); void sendMsgSTR(String address,String desport,String payload); diff --git a/src/AT_BC95.cpp b/src/AT_BC95.cpp index 73ba0df..699f07d 100644 --- a/src/AT_BC95.cpp +++ b/src/AT_BC95.cpp @@ -33,7 +33,7 @@ NB-IoT with AT command Author: Device Innovation team Create Date: 2 January 2020. -Modified: 27 May 2020. +Modified: 23 July 2020. */ #include "AT_BC95.h" #include "board.h" @@ -531,24 +531,54 @@ String AT_BC95::getNetworkStatus(){ return(out); } -bool AT_BC95::checkPSMmode(){ - bool status = false; - _Serial->println(F("AT+CPSMS?")); +// Get radio stat. +radio AT_BC95::getRadioStat(){ + radio value; + _Serial->println(F("AT+NUESTATS")); while(1){ if(_Serial->available()){ - data_input=_Serial->readStringUntil('\n'); - if(data_input.indexOf(F("+CPSMS:"))!=-1){ - if(data_input.indexOf(F("1"))!=-1) status = true; - else status = false; - } + data_input = _Serial->readStringUntil('\n'); if(data_input.indexOf(F("OK"))!=-1){ break; } + else{ + if(data_input.indexOf(F("PCI"))!=-1){ + int start_index = data_input.indexOf(F(":")); + int stop_index = data_input.indexOf(F("\n")); + value.pci = data_input.substring(start_index+1,stop_index); + } + if(data_input.indexOf(F("RSRQ"))!=-1){ + int start_index = data_input.indexOf(F(":")); + int stop_index = data_input.indexOf(F("\n")); + value.rsrq = data_input.substring(start_index+1,stop_index); + value.rsrq = String(value.rsrq.toInt()/10); + } + } } } - return status; + value.pci.trim(); + value.rsrq.trim(); + return value; } +// bool AT_BC95::checkPSMmode(){ +// bool status = false; +// _Serial->println(F("AT+CPSMS?")); +// while(1){ +// if(_Serial->available()){ +// data_input=_Serial->readStringUntil('\n'); +// if(data_input.indexOf(F("+CPSMS:"))!=-1){ +// if(data_input.indexOf(F("1"))!=-1) status = true; +// else status = false; +// } +// if(data_input.indexOf(F("OK"))!=-1){ +// break; +// } +// } +// } +// return status; +// } + /****************************************/ /** Send UDP Message **/ /****************************************/ @@ -707,4 +737,66 @@ void AT_BC95::_serial_flush(){ } } _Serial->flush(); -} \ No newline at end of file +} + +dateTime AT_BC95::getClock(unsigned int timezone){ + dateTime dateTime; + _Serial->println(F("AT+CCLK?")); + while(1){ + if(_Serial->available()){ + data_input=_Serial->readStringUntil('\n'); + if(data_input.indexOf(F("+CCLK:"))!=-1){ + byte index = data_input.indexOf(F(":")); + byte index2 = data_input.indexOf(F(","),index+1); + byte index3 = data_input.indexOf(F("+"),index2+1); + dateTime.date = data_input.substring(index+1,index2); //YY/MM/DD + dateTime.time = data_input.substring(index2+1,index3); //GMT time without adding timezone + } + if(data_input.indexOf(F("OK"))!=-1){ + break; + } + } + } + if(dateTime.time!="" && dateTime.date!=""){ + byte index = dateTime.date.indexOf(F("/")); + byte index2 = dateTime.date.indexOf(F("/"),index+1); + unsigned int yy = ("20"+dateTime.date.substring(0,index)).toInt(); + unsigned int mm = dateTime.date.substring(index+1,index2).toInt(); + unsigned int dd = dateTime.date.substring(index2+1,dateTime.date.length()).toInt(); + + index = dateTime.time.indexOf(F(":")); + unsigned int hr = dateTime.time.substring(0,index).toInt()+timezone; + + if(hr>=24){ + hr-=24; + //date+1 + dd+=1; + if(mm==2){ + if((yy % 4 == 0 && yy % 100 != 0 || yy % 400 == 0)){ + if (dd>29) { + dd==1; + mm+=1; + } + } + else if(dd>28){ + dd==1; + mm+=1; + } + } + else if((mm==1||mm==3||mm==5||mm==7||mm==8||mm==10||mm==12)&&dd>31){ + dd==1; + mm+=1; + } + else if(dd>30){ + dd==1; + mm+=1; + } + } + dateTime.time = String(hr)+dateTime.time.substring(index,dateTime.time.length()); + dateTime.date = String(dd)+"/"+String(mm)+"/"+String(yy); + + dateTime.time.trim(); + dateTime.date.trim(); + } + return dateTime; +} diff --git a/src/AT_BC95.h b/src/AT_BC95.h index f6054cb..fbc829e 100644 --- a/src/AT_BC95.h +++ b/src/AT_BC95.h @@ -33,7 +33,7 @@ NB-IoT with AT command Author: Device Innovation team Create Date: 2 January 2020. -Modified: 12 May 2020. +Modified: 22 July 2020. */ #include @@ -52,6 +52,16 @@ struct signal{ String ber; }; +struct radio{ + String pci=""; + String rsrq=""; +}; + +struct dateTime{ + String date=""; + String time=""; +}; + typedef void (*MQTTClientCallback)(String &topic, String &payload); typedef void (*reponseCallback)(String &datax); @@ -63,23 +73,26 @@ class AT_BC95{ const unsigned int msgLenMul=1; //=========Initialization Module======= void setupModule(String port="",String address=""); - void check_module_ready(); + void check_module_ready(); void reboot_module(); pingRESP pingIP(String IP); bool closeUDPSocket(); bool checkNetworkConnection(); bool attachNetwork(); - void powerSavingMode(unsigned int psm); + //==========Get Parameter Value========= String getFirmwareVersion(); String getIMEI(); String getICCID(); String getIMSI(); String getDeviceIP(); - String getSignal(); + String getSignal(); String getAPN(); String getNetworkStatus(); - bool checkPSMmode(); + radio getRadioStat(); + dateTime getClock(unsigned int timezone); + + // bool checkPSMmode(); //==========Data send/rec.=============== void waitResponse(String &retdata,String server); void _Serial_print(String address,String port,unsigned int len); @@ -113,4 +126,4 @@ class AT_BC95{ protected: Stream *_Serial; -}; \ No newline at end of file +}; diff --git a/src/Magellan_BC95.cpp b/src/Magellan_BC95.cpp index 142f302..8c81d4f 100644 --- a/src/Magellan_BC95.cpp +++ b/src/Magellan_BC95.cpp @@ -27,7 +27,7 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -Magellan_BC95 v1.0.1 NB-IoT Magellan Platform . +Magellan_BC95 v1.1.0 NB-IoT Magellan Platform . Quectel BC95 NB-IoT with AT command @@ -42,7 +42,7 @@ and supported only Magellan IoT Platform Author: Device Innovation team Create Date: 3 February 2020. -Modified: 2 June 2020. +Modified: 22 July 2020. Released for private usage. */ @@ -312,7 +312,7 @@ bool Magellan_BC95::begin(){ token_error_report=true; token_error_config=true; Serial.println(); - Serial.println(F(" AIS NB-IoT Magellan_BC95 V1.0.1")); + Serial.println(F(" AIS NB-IoT Magellan_BC95 V1.1.0")); atbc95.setupModule(serverIP,port); @@ -1146,6 +1146,14 @@ pingRESP Magellan_BC95::pingIP(String IP){ return atbc95.pingIP(IP); } +radio Magellan_BC95::getRadioStat(){ + return atbc95.getRadioStat(); +} + +dateTime Magellan_BC95::getClock(unsigned int timezone){ + return atbc95.getClock(timezone); +} + void Magellan_BC95::printErrCode(String errcode){ // switch(errcode.toInt()){ // case 40010: @@ -1163,4 +1171,4 @@ void Magellan_BC95::printErrCode(String errcode){ // default: // break; // } -} \ No newline at end of file +} diff --git a/src/Magellan_BC95.h b/src/Magellan_BC95.h index 0c0f8dc..a1ff12e 100644 --- a/src/Magellan_BC95.h +++ b/src/Magellan_BC95.h @@ -27,7 +27,7 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -Magellan_BC95 v1.0.1 NB-IoT Magellan Platform . +Magellan_BC95 v1.1.0 NB-IoT Magellan Platform . support Quectel BC95 NB-IoT with AT command @@ -42,7 +42,7 @@ and supported only Magellan IoT Platform Author: Device Innovation team Create Date: 3 February 2020. -Modified: 26 March 2020. +Modified: 22 July 2020. Released for private usage. */ @@ -102,13 +102,6 @@ typedef struct option { unsigned int optionnum; } option; -// struct radio{ -// String pci=""; -// String rsrp=""; -// String rsrq=""; -// String snr=""; -// }; - class Magellan_BC95 { @@ -122,6 +115,8 @@ class Magellan_BC95 bool begin(); String getSignal(); pingRESP pingIP(String IP); + radio getRadioStat(); + dateTime getClock(unsigned int timezone=7); String thingsRegister(); String report(String payload,unsigned int qos=0); @@ -205,4 +200,4 @@ class Magellan_BC95 Stream *_Serial; }; -#endif \ No newline at end of file +#endif