Skip to content

Commit

Permalink
0.2.7
Browse files Browse the repository at this point in the history
+ add CLTS=1 (clock sync) to GPRS-Libraries
  • Loading branch information
holzheu committed Oct 26, 2023
1 parent 54cc1bc commit 04f43fd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
#define SAMPLING_INT 60
#define SEND_COUNT 60 /*collect 60 measurements before send... */
#define MIN_VOLTAGE 3.8 /*minimum voltage for send operation */

#define NETWORK_TIME 1 /*use network time*/
#define BUFFER_RESET_ON_STARTUP 1 /*only set to 0 with NETWORK_TIME*/
// SIM800-Config string. -- new Library
// Gateway-url|login|password|Origin (== Board unique identifier)|apn of sim-card|apn-user|apn-pw|PIN
#define SIM800_CONFIG "http://132.180.112.128/gateway/frame/saveFlat|import@IT|import|MyGPRS-Board|iot.1nce.net||||"
Expand Down Expand Up @@ -56,7 +57,9 @@ void setup()
initLCB();
pinMode(POWER_PIN, OUTPUT);
myBuffer.init(flash); //This will restore old pointers
#if BUFFER_RESET_ON_STARTUP
myBuffer.skip(); //This will skip unsent frames
#endif
myBuffer.setRTC(myRTC, RTC_RELATIVE_SECONDS); //use the rtc clock but relative
client.setBuffer(myBuffer); //connect the buffer to the transport client
digitalWrite(POWER_PIN, HIGH); //power up GPRS-Modem
Expand All @@ -73,6 +76,18 @@ void setup()
delay(2000);
blinkLED(client.sendMessage("Board started") + 1); //send a message to the gateway.
//one time blinking indicates success - more denotes an error. For details look at the function definition
#if NETWORK_TIME
while (true) {
unsigned long time = client.now().get();
if (time > 3600L*24*365*10) {
myRTC.adjust(time);
break;
}
delay(2000);
blinkLED(2);
}
#endif

Serial.end(); //Stop Serial (avoids power leakage via TX Pin)
digitalWrite(POWER_PIN, LOW); //power down GPRS-Modem
delay(2000);
Expand Down Expand Up @@ -102,9 +117,16 @@ void loop() {
delayLCB(1000);
uint8_t tx_res = client.begin(38400);
blinkLED(tx_res + 1); //connect to network
while (! tx_res && myBuffer.available() && ! ISSET_ACTION(0)) {
while (! tx_res && myBuffer.available()) {
tx_res = client.sendMultiFromBuffer(3000); //send 3000 bytes from flash storage
blinkLED(tx_res + 1);
#if NETWORK_TIME
unsigned long time = client.now().get();
if (time > 3600L*24*365*10) {
myRTC.adjust(time);
}
#endif
if(ISSET_ACTION(0)) break;
}
if (! myBuffer.available()) measurements = 0; //all data sent from flash storage
Serial.end();
Expand Down
3 changes: 2 additions & 1 deletion libraries/BaySIM800/BaySIM800.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ uint8_t BaySIM800::init(void){
printlnP_OK("ATE0",500); //Command echo off
printlnP_OK("AT+CSCLK=0",500); //Auto-Sleepmode off
//Check PIN
printlnP_OK("AT+CLTS=1",200); //enable clock sync!
printlnP("AT+CPIN?");
while(wait_forPGM(PSTR("+CPIN: "),5000,7,_base64buffer)){
printlnP_OK("AT",200);
Expand Down Expand Up @@ -66,7 +67,6 @@ uint8_t BaySIM800::init(void){
delay(500);
}
if(i==127) return 6;

printlnP_OK("AT+HTTPTERM",200);
printlnP_OK("AT+SAPBR=0,1",200);
printlnP_OK("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"",200);
Expand Down Expand Up @@ -157,6 +157,7 @@ DateTime BaySIM800::now(void){
return dt;
}


uint8_t BaySIM800::postHeader(uint16_t size){
uint8_t res;
res = init();
Expand Down
2 changes: 2 additions & 0 deletions libraries/BayTCPSim900/BayTCPSim900.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ uint8_t BayGPRSInterface::init(uint8_t unlock_only){
wait_forOK(500);
printlnP("AT+CSCLK=0"); //Auto-Sleepmode
wait_forOK(500);
printlnP("AT+CLTS=1"); //enable clock sync!
wait_forOK(500);
//Check PIN
printlnP("AT+CPIN?");
while(wait_forPGM(PSTR("+CPIN: "),5000,7,_base64buffer)){
Expand Down

0 comments on commit 04f43fd

Please sign in to comment.