Skip to content

Commit

Permalink
Merge pull request #2 from AIS-DeviceInnovation/supportBC95-G
Browse files Browse the repository at this point in the history
Support Quectel BC95-G
  • Loading branch information
AIS-DeviceInnovation authored Dec 8, 2022
2 parents 8c9af51 + a64f0db commit b23fda4
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 22 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
![Library Version](https://img.shields.io/badge/Version-1.0.2-green)
![Library Version](https://img.shields.io/badge/Version-2.0.0-green)

# AIS Library

## AIS Magellan SDK for BC95 module Lite version
## AIS Magellan SDK for BC95 and BC95-G module Lite version
AIS Magellan Library, a software development kit used on arduino platform, have been developed for
Magellan IoT Platform. Support Arduino UNO.

Expand Down Expand Up @@ -49,4 +49,4 @@ please use 0 or 1 to send status\
payload={"Lamp":0}
payload={"Lamp":1}
```
**Note** please see more in the example code
**Note** In this case, the device has already preload code then you just plug and play the development kit. If you have any questions, please see more details at https://www.facebook.com/AISDEVIO
4 changes: 2 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Magellan_BC95_lite",
"frameworks": "Arduino",
"keywords": "AIS, NB-IoT, BC95, Magellan, Quectel",
"keywords": "AIS, NB-IoT, BC95, BC95-G, BC95-B8, Magellan, Quectel",
"description": "Arduino Library for AIS Magellan",
"url": "https://github.com/AIS-DeviceInnovation/Magellan_BC95_lite",
"authors":
Expand All @@ -14,6 +14,6 @@
"type": "git",
"url": "https://github.com/AIS-DeviceInnovation/Magellan_BC95_lite.git"
},
"version": "1.0.2",
"version": "2.0.0",
"platforms": "*"
}
7 changes: 3 additions & 4 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name=Magellan_BC95_lite
version=1.0.2
version=2.0.0
author=AIS IoT Alliance Program
maintainer= AIS IoT Alliance Program <[email protected]>
sentence= AIS Magellan Library; easy way to integrate IoT Device to Magellan using Arduino Platform.
paragraph= Fully compatible with DEVIO NB-SHIELD I.
paragraph= Fully compatible with DEVIO NB-SHIELD I Plus.
category=Cellular Communication
url= https://github.com/AIS-DeviceInnovation/Magellan_BC95_lite
architectures=*

architectures=*
69 changes: 56 additions & 13 deletions src/Magellan_BC95_lite.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_lite v1.0.2 NB-IoT Magellan Platform .
Magellan_BC95_lite v2.0.0 NB-IoT Magellan Platform .
Quectel BC95
NB-IoT with AT command
Expand All @@ -42,10 +42,11 @@ and supported only Magellan IoT Platform
Author: Device Innovation team
Create Date: 3 February 2020.
Modified: 06 June 2020.
Modified: 21 June 2021.
(*v1.0.1 customize dynamic memory and add auto reset function)
(*v1.0.2 bug fix logic response code only 40300 and limit maximum payload 100 character)
(*v2.0.0 support Quectel BC95-G)
Released for private usage.
*/

Expand Down Expand Up @@ -126,7 +127,7 @@ bool Magellan_BC95_lite::begin()
#endif

Serial.println();
Serial.println(F(" AIS NB-IoT Magellan_BC95_lite V1.0.2"));
Serial.println(F(" AIS NB-IoT Magellan_BC95_lite V2.0.0"));

/*---------------------------------------
Initial BC95 Module
Expand Down Expand Up @@ -157,7 +158,7 @@ bool Magellan_BC95_lite::begin()

void Magellan_BC95_lite::reboot_module()
{
Serial.println(F(">>Rebooting "));
Serial.print(F(">>Rebooting "));
_Serial->println(F("AT+NRB"));
delay(100);

Expand Down Expand Up @@ -258,6 +259,18 @@ void Magellan_BC95_lite::setup_module()
}
}

//Check module
_Serial->println(F("AT+CGMM"));
while(1){
if(_Serial->available()){
data_input=_Serial->readStringUntil('\n');
if(data_input.indexOf(F("OK"))!=-1) break;
else{
if(data_input.indexOf(F("BC95GJB-02-STD"))!=-1) bc95=false;
else if(data_input.indexOf(F("BC95HB-02-STD_900"))!=-1) bc95=true;
}
}
}

_Serial->println(F("AT+CGATT=1"));
delay(500);
Expand Down Expand Up @@ -308,8 +321,13 @@ void Magellan_BC95_lite::setup_module()
Create network socket
-------------------------------------
*/
data_input="";
_Serial->println(F("AT+NSOCR=DGRAM,17,5684,1"));
data_input="";
if(bc95){
_Serial->println(F("AT+NSOCR=DGRAM,17,5684,1"));
}
else{
_Serial->println(F("AT+NSOCR=DGRAM,17,0"));
}
delay(500);
_serial_flush();

Expand Down Expand Up @@ -625,8 +643,13 @@ void Magellan_BC95_lite::Msgsend(char *payload_c,unsigned int payload_len,bool r
if(printstate) Serial.print(Msg_ID);
if(printstate) Serial.print(F(" "));
if(printstate) Serial.println(payload_c);

_Serial->print(F("AT+NSOST=0,"));

if(bc95){
_Serial->print(F("AT+NSOST=0,"));
}
else{
_Serial->print(F("AT+NSOST=1,"));
}
_Serial->print(serverIP);
_Serial->print(F(",5683,"));

Expand Down Expand Up @@ -864,7 +887,12 @@ void Magellan_BC95_lite::print_rsp_Type(String Msgstr,unsigned int msgID)
en_get=true;

if(debug) Serial.println(F("Send ack"));
_Serial->print(F("AT+NSOST=0,"));
if(bc95){
_Serial->print(F("AT+NSOST=0,"));
}
else{
_Serial->print(F("AT+NSOST=1,"));
}
_Serial->print(serverIP);
_Serial->print(F(",5683,"));
_Serial->print(F("4"));
Expand Down Expand Up @@ -988,7 +1016,12 @@ void Magellan_BC95_lite:: waitResponse()
unsigned long current=millis();
if(en_chk_buff && (current-previous>=500) && !(_Serial->available()))
{
_Serial->println(F("AT+NSORF=0,512"));
if(bc95) {
_Serial->println(F("AT+NSORF=0,512"));
}
else{
_Serial->println(F("AT+NSORF=1,512"));
}
cnt_cmdgetrsp++;
previous=current;
}
Expand Down Expand Up @@ -1017,7 +1050,12 @@ void Magellan_BC95_lite:: waitResponse()
if(debug) Serial.print(F("send_NSOMI "));
if(data_input.indexOf(F("+NSONMI:"))!=-1)
{
_Serial->println(F("AT+NSORF=0,512"));
if(bc95) {
_Serial->println(F("AT+NSORF=0,512"));
}
else{
_Serial->println(F("AT+NSORF=1,512"));
}
data_input=F("");
send_NSOMI=true;
if(printstate) Serial.println();
Expand All @@ -1030,7 +1068,7 @@ void Magellan_BC95_lite:: waitResponse()

end=false;

if(data_input.indexOf(F("0,119.31.104.1"))!=-1)
if(data_input.indexOf(F("0,119.31.104.1"))!=-1 || data_input.indexOf(F("1,119.31.104.1"))!=-1)
{
int index1 = data_input.indexOf(F(","));
if(index1!=-1)
Expand All @@ -1052,7 +1090,12 @@ void Magellan_BC95_lite:: waitResponse()
index2 = data_input.indexOf(F(","),index1+1);
if(data_input.substring(index1+1,index2)!="0"){
if(debug) Serial.println(F("found buffer"));
_Serial->println(F("AT+NSORF=0,512"));
if(bc95) {
_Serial->println(F("AT+NSORF=0,512"));
}
else{
_Serial->println(F("AT+NSORF=1,512"));
}
cnt_rcv_resp++;
}
else{
Expand Down
1 change: 1 addition & 0 deletions src/Magellan_BC95_lite.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class Magellan_BC95_lite
bool more_flag=false;
bool hw_connected=false;
bool token_error_report=true;
bool bc95;
//################### Parameter ####################
//unsigned int resp_cnt=0;
unsigned int resp_msgID=0;
Expand Down

0 comments on commit b23fda4

Please sign in to comment.