Skip to content

Commit a2813da

Browse files
committed
Merge remote-tracking branch 'origin/wifi_leven_dev' into wifi_leven_dev
Former-commit-id: a01f733
2 parents 8c0115e + 24fd0f4 commit a2813da

File tree

4 files changed

+147
-29
lines changed

4 files changed

+147
-29
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include "WiFiFileSystem.h"
2+
3+
/* -------------------------------------------------------------------------- */
4+
WiFiFileSystem::WiFiFileSystem() {
5+
/* -------------------------------------------------------------------------- */
6+
}
7+
void WiFiFileSystem::mount(bool format_on_fault) {
8+
modem.begin();
9+
string res = "";
10+
modem.write(string(PROMPT(_MOUNTFS)), res, "%s%d\r\n" , CMD_WRITE(_MOUNTFS), format_on_fault);
11+
if (format_on_fault) {
12+
modem.write(string(PROMPT(_MOUNTFS)), res, "%s%d\r\n" , CMD_WRITE(_MOUNTFS), format_on_fault);
13+
}
14+
}
15+
void WiFiFileSystem::writefile(const char* name, const char* data) {
16+
string res = "";
17+
if(modem.write(string(PROMPT(_FILESYSTEM)), res, "%s%d,%d,%s,%s\r\n" , CMD_WRITE(_FILESYSTEM), 0, WIFI_FILE_WRITE, name, data)) {
18+
}
19+
}
20+
21+
/* -------------------------------------------------------------------------- */
22+
void WiFiFileSystem::readfile(const char* name) {
23+
/* -------------------------------------------------------------------------- */
24+
string res = "";
25+
int i = 0;
26+
while(1) {
27+
modem.avoid_trim_results();
28+
modem.read_using_size();
29+
if(modem.write(string(PROMPT(_FILESYSTEM)), res, "%s%d,%d,%s,%d,%d\r\n" , CMD_WRITE(_FILESYSTEM), 0, WIFI_FILE_READ, name, i, 1023)) {
30+
Serial.print(res.c_str()); //WIP i'll fix this in next commit for now just print the filecontent
31+
i += res.size();
32+
} else {
33+
break;
34+
}
35+
}
36+
}

libraries/WiFiS3/src/WiFiFileSystem.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
This file is part of the WiFiS3 library.
3+
Copyright (c) 2023 Arduino SA. All rights reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#ifndef WIFI_FILE_SYSTEM_H
21+
#define WIFI_FILE_SYSTEM_H
22+
23+
#include "Arduino.h"
24+
#include "WiFiCommands.h"
25+
#include "Modem.h"
26+
27+
class WiFiFileSystem {
28+
29+
public:
30+
WiFiFileSystem();
31+
void mount(bool format_on_fault = false);
32+
void writefile(const char* name, const char* data);
33+
void readfile(const char* name);
34+
35+
};
36+
37+
#endif /* WIFI_FILE_SYSTEM_H */
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#include "WiFiSSLClient.h"
2+
3+
/* -------------------------------------------------------------------------- */
4+
WiFiSSLClient::WiFiSSLClient() {
5+
/* -------------------------------------------------------------------------- */
6+
7+
}
8+
9+
/* -------------------------------------------------------------------------- */
10+
int WiFiSSLClient::connect(IPAddress ip, uint16_t port) {
11+
/* -------------------------------------------------------------------------- */
12+
getSocket();
13+
string res = "";
14+
if(modem.write(string(PROMPT(_SSLCLIENTCONNECT)),res, "%s%d,%s,%d\r\n" , CMD_WRITE(_SSLCLIENTCONNECT), _sock, ip.toString(), port)) {
15+
return 1;
16+
}
17+
return 0;
18+
}
19+
20+
/* -------------------------------------------------------------------------- */
21+
int WiFiSSLClient::connect(const char* host, uint16_t port) {
22+
/* -------------------------------------------------------------------------- */
23+
getSocket();
24+
string res = "";
25+
if(modem.write(DO_NOT_CHECK_CMD,res, "%s%d,%s,%d\r\n" , CMD_WRITE(_SSLCLIENTCONNECT), _sock, host, port)) {
26+
return 1;
27+
}
28+
return 0;
29+
}
30+
31+
/* -------------------------------------------------------------------------- */
32+
void WiFiSSLClient::setCACert(const char* root_ca) {
33+
/* -------------------------------------------------------------------------- */
34+
getSocket();
35+
string res = "";
36+
modem.write(string(PROMPT(_SETCAROOT)),res, "%s%d,%s\r\n" , CMD_WRITE(_SETCAROOT), _sock,root_ca);
37+
}
38+
39+
/* -------------------------------------------------------------------------- */
40+
void WiFiSSLClient::setInsecure() {
41+
/* -------------------------------------------------------------------------- */
42+
getSocket();
43+
string res = "";
44+
modem.write(DO_NOT_CHECK_CMD,res, "%s%d\r\n" , CMD_WRITE(_SSLSETINSERCURE), _sock);
45+
// if(modem.write(string(PROMPT(_SSLSETINSERCURE)),res, "%s%d\r\n" , CMD_WRITE(_SSLSETINSERCURE), _sock)) {
46+
// return true;
47+
// }
48+
49+
}

libraries/WiFiS3/src/WiFiSSLClient.h

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,41 @@
11
/*
2-
This file is part of the WiFiNINA library.
3-
Copyright (c) 2018 Arduino SA. All rights reserved.
4-
5-
This library is free software; you can redistribute it and/or
6-
modify it under the terms of the GNU Lesser General Public
7-
License as published by the Free Software Foundation; either
8-
version 2.1 of the License, or (at your option) any later version.
9-
10-
This library is distributed in the hope that it will be useful,
11-
but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13-
Lesser General Public License for more details.
14-
15-
You should have received a copy of the GNU Lesser General Public
16-
License along with this library; if not, write to the Free Software
17-
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2+
This file is part of the WiFiS3 library.
3+
Copyright (c) 2023 Arduino SA. All rights reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
*/
1919

2020
#ifndef WIFISSLCLIENT_H
2121
#define WIFISSLCLIENT_H
2222

23+
#include "WiFiCommands.h"
2324
#include "WiFiClient.h"
25+
#include "Modem.h"
26+
#include "WiFiFileSystem.h"
27+
2428

2529
class WiFiSSLClient : public WiFiClient {
2630

2731
public:
28-
WiFiSSLClient();
29-
WiFiSSLClient(uint8_t sock);
30-
31-
virtual int connect(IPAddress ip, uint16_t port);
32-
virtual int connect(const char* host, uint16_t port);
33-
};
32+
WiFiSSLClient();
3433

35-
class WiFiBearSSLClient : public WiFiClient {
36-
37-
public:
38-
WiFiBearSSLClient();
39-
WiFiBearSSLClient(uint8_t sock);
34+
virtual int connect(IPAddress ip, uint16_t port);
35+
virtual int connect(const char* host, uint16_t port);
36+
void setCACert(const char* root_ca);
37+
void setInsecure();
4038

41-
virtual int connect(IPAddress ip, uint16_t port);
42-
virtual int connect(const char* host, uint16_t port);
4339
};
4440

4541
#endif /* WIFISSLCLIENT_H */

0 commit comments

Comments
 (0)