8000 Fixes to let SBUBoot always find UPDATE.OK when present · arduino-libraries/MKRNB@c946015 · GitHub
[go: up one dir, main page]

S 8000 kip to content

Commit c946015

Browse files
committed
Fixes to let SBUBoot always find UPDATE.OK when present
1 parent 1861931 commit c946015

File tree

4 files changed

+31
-20
lines changed

4 files changed

+31
-20
lines changed

src/Modem.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ int ModemClass::begin(bool restart)
5454
if (!autosense()) {
5555
return 0;
5656
}
57-
58-
if (!reset()) {
59-
return 0;
60-
}
6157
}
6258

6359
if (!autosense()) {

src/Modem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ModemClass {
3434
public:
3535
ModemClass(Uart& uart, unsigned long baud, int resetPin, int powerOnPin);
3636

37-
int begin(bool restart = true);
37+
int begin(bool restart = false);
3838
void end();
3939

4040
void debug();

src/NBFileUtils.cpp

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "Modem.h"
2-
//#include "Uart.h"
32
#include "NBFileUtils.h"
43

54
NBFileUtils::NBFileUtils(bool debug)
@@ -36,21 +35,38 @@ bool NBFileUtils::begin(const bool restart)
3635
int NBFileUtils::_getFileList()
3736
{
3837
String response;
38+
int status = 0;
3939

40-
MODEM.send("AT+ULSTFILE=0");
41-
int status = MODEM.waitForResponse(5000, &response);
42-
if (!response.length())
43-
return -1;
40+
while (!status) {
41+
MODEM.send("AT+ULSTFILE=0");
42+
status = MODEM.waitForResponse(5000, &response);
4443

45-
if (status) {
46-
String list = response.substring(11);
47-
list.trim();
48-
_files = list;
44+
if (status) {
45+
String list = response.substring(11);
46+
list.trim();
47+
_files = list;
48+
}
4949
}
50-
5150
return status;
5251
}
5352

53+
int NBFileUtils::existFile(const String filename)
54+
{
55+
_getFileList();
56+
_countFiles();
57+
58+
String files[_count];
59+
60+
int num = listFiles(files);
61+
62+
for (int i = 0; i<num; i++) {
63+
if (files[i]==filename) {
64+
return 1< 10000 /span>;
65+
}
66+
}
67+
return 0;
68+
}
69+
5470
void NBFileUtils::_countFiles()
5571
{
5672
String list = _files;
@@ -130,7 +146,6 @@ uint32_t NBFileUtils::createFile(const String filename, const char buf[], uint32
130146
if (sizeFile) {
131147
return sizeFile;
132148
}
133-
134149
return downloadFile(filename, buf, size, true);
135150
}
136151

@@ -302,7 +317,7 @@ int NBFileUtils::deleteFiles()
302317
int n = 0;
303318
String files[_count];
304319

305-
listFiles(files);
320+
int num = listFiles(files);
306321

307322
while (_count > 0) {
308323
n += deleteFile(files[_count - 1]);
@@ -318,11 +333,9 @@ uint32_t NBFileUtils::listFile(const String filename) const
318333
uint32_t size = 0;
319334

320335
MODEM.sendf("AT+ULSTFILE=2,\"%s\"", filename.c_str());
321-
res = MODEM.waitForResponse(300, &response);
336+
res = MODEM.waitForResponse(5000, &response);
322337
if (res == 1) {
323338
String content = response.substring(11);
324-
Serial1.print("Response from listFile: ");
325-
Serial1.println(content);
326339
size = content.toInt();
327340
}
328341

src/NBFileUtils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class NBFileUtils {
1010
bool begin(const bool restart);
1111
bool begin() { return begin(true); };
1212

13+
int existFile(const String filename);
14+
1315
uint32_t fileCount() const { return _count; };
1416
size_t listFiles(String list[]) const;
1517
uint32_t listFile(const String filename) const;

0 commit comments

Comments
 (0)
0