Skip to content

Commit

Permalink
Merge pull request #1 from AIS-DeviceInnovation/v1.1.0
Browse files Browse the repository at this point in the history
V1.1.0
  • Loading branch information
AIS-DeviceInnovation authored Sep 24, 2020
2 parents 4d50b32 + 7bf7d1b commit a5d27db
Show file tree
Hide file tree
Showing 9 changed files with 160 additions and 39 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"type": "git",
"url": "https://github.com/AIS-DeviceInnovation/Magellan_BC95.git"
},
"version": "1.0.1",
"version": "1.1.0",
"platforms": "*"
}
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name=Magellan_BC95
version=1.0.1
version=1.1.0
author=AIS IoT Alliance Program
maintainer= AIS IoT Alliance Program <aiap@ais.co.th>
sentence= AIS Magellan Library; easy way to integrate IoT Device to Magellan using Arduino Platform.
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

15 changes: 13 additions & 2 deletions src/AIS_BC95_API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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();
// }

6 changes: 4 additions & 2 deletions src/AIS_BC95_API.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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);
Expand Down
114 changes: 103 additions & 11 deletions src/AT_BC95.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 **/
/****************************************/
Expand Down Expand Up @@ -707,4 +737,66 @@ void AT_BC95::_serial_flush(){
}
}
_Serial->flush();
}
}

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;
}
25 changes: 19 additions & 6 deletions src/AT_BC95.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Arduino.h>
Expand All @@ -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);

Expand All @@ -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);
Expand Down Expand Up @@ -113,4 +126,4 @@ class AT_BC95{

protected:
Stream *_Serial;
};
};
16 changes: 12 additions & 4 deletions src/Magellan_BC95.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
*/
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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:
Expand All @@ -1163,4 +1171,4 @@ void Magellan_BC95::printErrCode(String errcode){
// default:
// break;
// }
}
}
15 changes: 5 additions & 10 deletions src/Magellan_BC95.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
*/
Expand Down Expand Up @@ -102,13 +102,6 @@ typedef struct option {
unsigned int optionnum;
} option;

// struct radio{
// String pci="";
// String rsrp="";
// String rsrq="";
// String snr="";
// };

class Magellan_BC95
{

Expand All @@ -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);
Expand Down Expand Up @@ -205,4 +200,4 @@ class Magellan_BC95
Stream *_Serial;
};

#endif
#endif

0 comments on commit a5d27db

Please sign in to comment.