8000 cc3200: Set WLAN date/time via the rtc.datetime method(). · micropython/micropython@4f8eeae · GitHub
[go: up one dir, main page]

Skip to content

Commit 4f8eeae

Browse files
author
Daniel Campora
committed
cc3200: Set WLAN date/time via the rtc.datetime method().
WLAN needs time info when validating certificates.
1 parent d680e28 commit 4f8eeae

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

cc3200/mods/pybrtc.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* THE SOFTWARE.
2626
*/
2727

28-
#include <stdio.h>
28+
#include <std.h>
2929

3030
#include "py/mpconfig.h"
3131
#include MICROPY_HAL_H
@@ -40,6 +40,7 @@
4040
#include "pybsleep.h"
4141
#include "mpcallback.h"
4242
#include "timeutils.h"
43+
#include "simplelink.h"
4344

4445
/// \moduleref pyb
4546
/// \class RTC - real time clock
@@ -177,7 +178,7 @@ mp_obj_t pyb_rtc_datetime(mp_uint_t n_args, const mp_obj_t *args) {
177178
tm.tm_year = mp_obj_get_int(items[0]);
178179
tm.tm_mon = mp_obj_get_int(items[1]);
179180
tm.tm_mday = mp_obj_get_int(items[2]);
180-
// Skip the weekday
181+
// skip the weekday
181182
tm.tm_hour = mp_obj_get_int(items[4]);
182183
tm.tm_min = mp_obj_get_int(items[5]);
183184
tm.tm_sec = mp_obj_get_int(items[6]);
@@ -187,6 +188,15 @@ mp_obj_t pyb_rtc_datetime(mp_uint_t n_args, const mp_obj_t *args) {
187188
mseconds = RTC_U16MS_CYCLES(mseconds);
188189
MAP_PRCMRTCSet(seconds, mseconds);
189190

191+
// set simplelink's time and date, this is needed to verify certificates
192+
SlDateTime_t sl_datetime = {0};
193+
sl_datetime.sl_tm_day = tm.tm_mday;
194+
sl_datetime.sl_tm_mon = tm.tm_mon;
195+
sl_datetime.sl_tm_year = tm.tm_year;
196+
sl_datetime.sl_tm_hour = tm.tm_hour;
197+
sl_datetime.sl_tm_min = tm.tm_min;
198+
sl_datetime.sl_tm_sec = tm.tm_sec;
199+
sl_DevSet(SL_DEVICE_GENERAL_CONFIGURATION, SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME, sizeof(SlDateTime_t), (_u8 *)(&sl_datetime));
190200
return mp_const_none;
191201
}
192202
}

0 commit comments

Comments
 (0)
0