1/**************************************************************************************
2 * INCLUDE
3 **************************************************************************************/
4
5
6#include <MKRGSM.h>
7
8
9/**************************************************************************************
10 * CONSTANTS
11 **************************************************************************************/
12
13static char const BINARY[] =
14
15{
16  #include "Binary.h"
17};
18
19
20GSMFileUtils fileUtils;
21
22
23/**************************************************************************************
24 * SETUP/LOOP
25 **************************************************************************************/
26
27void setup() {
28  Serial.begin(9600);
29
30  unsigned long const start = millis();
31  for(unsigned long now = millis(); !Serial && ((now - start) < 5000); now = millis()) { };
32
33  Serial.print("Accessing SARA U-201 Filesystem... ");
34  if(!fileUtils.begin()) {
35    Serial.println("failed.");
36    return;
37
38  }
39  Serial.println("OK");
40  Serial.print("Writing \"UPDATE.BIN\" ... ");
41
42  uint32_t bytes_to_write = sizeof(BINARY);
43  auto bytes_written = fileUtils.downloadFile("UPDATE.BIN", BINARY, bytes_to_write);
44
45  if(bytes_written != bytes_to_write) {
46    Serial.println("downloadFile failed.");return;
47
48  } else {
49    Serial.print("OK (");
50    Serial.print(bytes_written);
51    Serial.println(" bytes written)");
52  }
53}
54
55void loop() {
56
57}
58