Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ftp #49

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Ftp #49

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ NB KEYWORD1
NB_SMS KEYWORD1
GPRS KEYWORD1
NBClient KEYWORD1
NBFTP KEYWORD1
NBModem KEYWORD1
NBScanner KEYWORD1
NBPIN KEYWORD1
Expand Down Expand Up @@ -46,6 +47,22 @@ hostByName KEYWORD2
getTime KEYWORD2
setTime KEYWORD2
getLocalTime KEYWORD2
configure KEYWORD2
configureIP KEYWORD2
configureHost KEYWORD2
configurePort KEYWORD2
configureUsername KEYWORD2
configurePassword KEYWORD2
configurePassive KEYWORD2
configureAccount KEYWORD2
configureAuth KEYWORD2
deleteFile KEYWORD2
renameFile KEYWORD2
getFile KEYWORD2
sendFile KEYWORD2
changeDir KEYWORD2
makeDir KEYWORD2
rmDir KEYWORD2

#######################################
# Constants
Expand Down
1 change: 1 addition & 0 deletions src/MKRNB.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "NB_SMS.h"
#include "GPRS.h"
#include "NBClient.h"
#include "NBFTP.h"
#include "NBModem.h"
#include "NBScanner.h"
#include "NBPIN.h"
Expand Down
9 changes: 9 additions & 0 deletions src/Modem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,15 @@ int ModemClass::ready()
return _ready;
}

int ModemClass::read()
{
if (_uart->available()) {
return _uart->read();
} else {
return -1;
}
}

void ModemClass::poll()
{
while (_uart->available()) {
Expand Down
2 changes: 2 additions & 0 deletions src/Modem.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class ModemClass {
int waitForPrompt(unsigned long timeout = 500);
int waitForResponse(unsigned long timeout = 200, String* responseDataStorage = NULL);
int ready();

int read();
void poll();
void setResponseDataStorage(String* responseDataStorage);

Expand Down
22 changes: 13 additions & 9 deletions src/NB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ int NB::isAccessAlive()

bool NB::shutdown()
{
if (_state == NB_READY) {
if (_state == NB_READY || _state == ERROR) {
MODEM.send("AT+CPWROFF");
// shouldn't this return false if nothing is returned?
MODEM.waitForResponse(40000);
}
MODEM.end();
Expand Down Expand Up @@ -441,6 +442,16 @@ unsigned long NB::getTime()

struct tm now;

time_t delta = ((response.charAt(26) - '0') * 10 + (response.charAt(27) - '0')) * (15 * 60);

if (response.charAt(25) == '-') {
delta = -delta;
} else if (response.charAt(25) == '+') {
delta = delta;
} else {
delta = 0;
}

int dashIndex = response.lastIndexOf('-');
if (dashIndex != -1) {
response.remove(dashIndex);
Expand All @@ -450,15 +461,8 @@ unsigned long NB::getTime()
// adjust for timezone offset which is +/- in 15 minute increments

time_t result = mktime(&now);
time_t delta = ((response.charAt(26) - '0') * 10 + (response.charAt(27) - '0')) * (15 * 60);

if (response.charAt(25) == '-') {
result += delta;
} else if (response.charAt(25) == '+') {
result -= delta;
}

return result;
return result + delta;
}

return 0;
Expand Down
Loading