I am working with an Arduino Mega and a SIM7000E Arduino NB-IoT/LTE/GPRS/GPS Expansion Shield. I tried to run the example provided by DFRobot in their tuto but a narrowing error appears in the lib. On the web they propose me to change code to avoid this problem but since it is a library I should not mess with it. Has anybody an idea ?
I am working on VSCode with the platformIO integrated IDE. My compiler is gcc and I have downloaded the two used library from DFRobot_SIM7000 and DFRobot_SIM
Example code:
`#include <Wire.h>
#include <DFRobot_SIM7000.h>
#define PIN_TX 7
#define PIN_RX 8
SoftwareSerial mySerial(PIN_RX,PIN_TX);
DFRobot_SIM7000 sim7000;
static char buff[350];
void setup(){
int signalStrength,dataNum;
Serial.begin(115200);
sim7000.begin(mySerial);
sim7000.turnOFF();
delay(5000);
Serial.println("Turn ON SIM7000......");
if(sim7000.turnON()){ //Turn ON SIM7000
Serial.println("Turn ON !");
}
Serial.println("Set baud rate......");
if(sim7000.setBaudRate(19200)){ //Set baud rate from 115200 to 19200
Serial.println("Set baud rate:19200");
}else{
Serial.println("Faile to set baud rate");
while(1);
}
Serial.println("Check SIM card......");
if(sim7000.checkSIMStatus()){ //Check SIM card
Serial.println("SIM card READY");
}else{
Serial.println("SIM card ERROR");
while(1);
}
delay(500);
Serial.println("Set net mod......");
if(sim7000.setNetMode(NB)){ //Set net mod NB-IOT
Serial.println("Set NB-IOT mode");
}else{
Serial.println("Fail to set mode");
}
Serial.println("Get signal quality......");
delay(500);
signalStrength=sim7000.checkSignalQuality(); //Check signal quality from (0-30)
Serial.print("signalStrength =");
Serial.println(signalStrength);
delay(500);
Serial.println("Attaching service......");
if(sim7000.attacthService()){ //Open the connection
Serial.println("Attach service");
}else{
Serial.println("Fail to Attach service");
while(1);
}
delay(200);
Serial.println("Connecting......");
if(sim7000.openNetwork(TCP,"www.taobao.com",80)){ //Start Up TCP or UDP Connection
Serial.println("Connect OK");
}else{
Serial.println("Fail to connect");
while(1);
}
sim7000.send("HEAD/HTTP/1.1\r\nHost:www.taobao.com\r\nConnection:keep-alive\r\n\r\n"); //Send Data Through TCP or UDP Connection
dataNum=sim7000.recv(buff,350,0); //Receive data
Serial.print("dataNum=");
Serial.println(dataNum);
Serial.println(buff);
delay(500);
if(sim7000.closeNetwork()){ //End the connection
Serial.println("Close connection");
}else{
Serial.println("Fail to close connection");
}
delay(2000);
sim7000.turnOFF(); //Turn OFF SIM7000
}
void loop() {
delay(1000);
}`
Error output:
lib\DFRobot_SIM7000\DFRobot_SIM7000.cpp: In member function 'bool DFRobot_SIM7000::mqttConnect(char*, char*, char*)':
lib\DFRobot_SIM7000\DFRobot_SIM7000.cpp:312:77: error: narrowing conversion of '194' from 'int' to 'char' inside { } [-Wnarrowing]
char MQTThead[10]={0x00,0x04,0x4d,0x51,0x54,0x54,0x04,0xc2,0x0b,0xb8};
lib\DFRobot_SIM7000\DFRobot_SIM7000.cpp:312:77: error: narrowing conversion of '184' from 'int' to 'char' inside { } [-Wnarrowing]
lib\DFRobot_SIM7000\DFRobot_SIM7000.cpp: In member function 'bool DFRobot_SIM7000::mqttDisconnect()':
lib\DFRobot_SIM7000\DFRobot_SIM7000.cpp:427:40: error: narrowing conversion of '224' from 'int' to 'char' inside { } [-Wnarrowing]