From 7aad8bb8eb5fd5af3c06563062064a5c4ad76ed1 Mon Sep 17 00:00:00 2001 From: ta-takahashi Date: Thu, 21 Sep 2023 09:18:22 +0900 Subject: [PATCH 1/5] =?UTF-8?q?SIPF=E3=83=A9=E3=82=A4=E3=83=96=E3=83=A9?= =?UTF-8?q?=E3=83=AA=E3=81=AE=E3=82=B3=E3=83=BC=E3=83=89=E3=81=AB=E3=80=81?= =?UTF-8?q?Arudino=E6=A8=99=E6=BA=96=E3=81=AE=E8=87=AA=E5=8B=95=E6=95=B4?= =?UTF-8?q?=E5=BD=A2=E3=82=92=E9=81=A9=E7=94=A8=E3=80=82(=E6=95=B4?= =?UTF-8?q?=E5=BD=A2=E3=81=AE=E3=81=BF=E3=81=A7=E6=A9=9F=E8=83=BD=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=E3=81=AA=E3=81=A9=E3=81=AE=E4=BF=AE=E6=AD=A3=E3=81=AA?= =?UTF-8?q?=E3=81=97)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/SipfClient.cpp | 31 ++--- src/SipfClient.h | 98 ++++++++------- src/SipfClientFile.cpp | 33 ++---- src/SipfObj.cpp | 243 ++++++++++++++++++-------------------- src/sipf-arduino-client.h | 2 +- 5 files changed, 184 insertions(+), 223 deletions(-) diff --git a/src/SipfClient.cpp b/src/SipfClient.cpp index a6d7daa..a5cc8c1 100644 --- a/src/SipfClient.cpp +++ b/src/SipfClient.cpp @@ -23,42 +23,33 @@ #include "SipfClient.h" -void SipfClient::begin(LTEClient *_client, int _port) -{ +void SipfClient::begin(LTEClient *_client, int _port) { client = _client; port = _port; } -void SipfClient::begin(LTETLSClient *_client, int _port) -{ +void SipfClient::begin(LTETLSClient *_client, int _port) { tlsclient = _client; port = _port; } -void SipfClient::end() -{ +void SipfClient::end() { } -void SipfClient::_setup_http_client(const String &aServerName, uint16_t aServerPort) -{ - if (http_client != NULL) - { +void SipfClient::_setup_http_client(const String &aServerName, uint16_t aServerPort) { + if (http_client != NULL) { delete http_client; http_client = NULL; } - if (client != NULL) - { + if (client != NULL) { http_client = new HttpClient(*client, aServerName, aServerPort); - } - else - { + } else { http_client = new HttpClient(*tlsclient, aServerName, aServerPort); } } -bool SipfClient::authenticate() -{ +bool SipfClient::authenticate() { _setup_http_client(auth_server, port); http_client->post(auth_path); @@ -69,13 +60,11 @@ bool SipfClient::authenticate() Serial.print("Status code: "); Serial.println(statusCode); - if (statusCode < 200 || 299 < statusCode) - { + if (statusCode < 200 || 299 < statusCode) { return false; } - if (response == "") - { + if (response == "") { return false; } diff --git a/src/SipfClient.h b/src/SipfClient.h index 56ff62a..6097efc 100644 --- a/src/SipfClient.h +++ b/src/SipfClient.h @@ -33,21 +33,21 @@ #include // APN name -#define APP_LTE_APN "sakura" // replace your APN +#define APP_LTE_APN "sakura" // replace your APN /* APN authentication settings * Ignore these parameters when setting LTE_NET_AUTHTYPE_NONE. */ -#define APP_LTE_USER_NAME "" // replace with your username -#define APP_LTE_PASSWORD "" // replace with your password +#define APP_LTE_USER_NAME "" // replace with your username +#define APP_LTE_PASSWORD "" // replace with your password // APN IP type -#define APP_LTE_IP_TYPE (LTE_NET_IPTYPE_V4V6) // IP : IPv4v6 +#define APP_LTE_IP_TYPE (LTE_NET_IPTYPE_V4V6) // IP : IPv4v6 // #define APP_LTE_IP_TYPE (LTE_NET_IPTYPE_V4) // IP : IPv4 // #define APP_LTE_IP_TYPE (LTE_NET_IPTYPE_V6) // IP : IPv6 // APN authentication type -#define APP_LTE_AUTH_TYPE (LTE_NET_AUTHTYPE_CHAP) // Authentication : CHAP +#define APP_LTE_AUTH_TYPE (LTE_NET_AUTHTYPE_CHAP) // Authentication : CHAP // #define APP_LTE_AUTH_TYPE (LTE_NET_AUTHTYPE_PAP) // Authentication : PAP // #define APP_LTE_AUTH_TYPE (LTE_NET_AUTHTYPE_NONE) // Authentication : NONE @@ -57,7 +57,7 @@ * The RAT set on the modem can be checked with LTEModemVerification::getRAT(). */ -#define APP_LTE_RAT (LTE_NET_RAT_CATM) // RAT : LTE-M (LTE Cat-M1) +#define APP_LTE_RAT (LTE_NET_RAT_CATM) // RAT : LTE-M (LTE Cat-M1) // #define APP_LTE_RAT (LTE_NET_RAT_NBIOT) // RAT : NB-IoT #define OBJ_MAX_CNT (255) @@ -90,47 +90,46 @@ #define OBJ_SIZE_FLOAT32 0x04 #define OBJ_SIZE_FLOAT64 0x08 -typedef enum -{ - OBJECTS_UP = 0x00, - OBJECTS_UP_RETRY = 0x01, - OBJID_NOTIFICATION = 0x02, +typedef enum { + OBJECTS_UP = 0x00, + OBJECTS_UP_RETRY = 0x01, + OBJID_NOTIFICATION = 0x02, - OBJECTS_DOWN_REQUEST = 0x11, - OBJECTS_DOWN = 0x12, - /* + OBJECTS_DOWN_REQUEST = 0x11, + OBJECTS_DOWN = 0x12, + /* OBJID_REACH_INQUIRY = 0xff, OBJID_REACH_RESULT = 0xff, OBJID_REACH_NOTIFICATION = 0xff, */ - OBJ_COMMAND_ERR = 0xff, + OBJ_COMMAND_ERR = 0xff, } SipfObjectCommandType; typedef struct { - SipfObjectCommandType command_type; - uint64_t command_time; - uint8_t option_flag; - uint16_t command_payload_size; + SipfObjectCommandType command_type; + uint64_t command_time; + uint8_t option_flag; + uint16_t command_payload_size; } SipfObjectCommandHeader; typedef struct { - uint8_t obj_type; - uint8_t obj_tagid; - uint8_t value_len; - uint8_t *value; + uint8_t obj_type; + uint8_t obj_tagid; + uint8_t value_len; + uint8_t *value; } SipfObjectObject; typedef struct { - uint8_t obj_qty; - SipfObjectObject obj; + uint8_t obj_qty; + SipfObjectObject obj; } SipfObjectUp; typedef struct { - uint8_t value[16]; + uint8_t value[16]; } SipfObjectOtid; const String auth_server = "auth.sipf.iot.sakura.ad.jp"; @@ -144,41 +143,40 @@ const String file_path = "/v1/files/"; const String file_comple = "/complete/"; -class SipfClient -{ +class SipfClient { public: - void begin(LTEClient *, int); - void begin(LTETLSClient *, int); - void end(); + void begin(LTEClient *, int); + void begin(LTETLSClient *, int); + void end(); - bool authenticate(); + bool authenticate(); - // File - bool uploadFile(String, uint8_t[], size_t); - String requestFileUploadURL(String); - bool finalizeFileUpload(String); - bool uploadFileContent(uint8_t[], size_t, String); + // File + bool uploadFile(String, uint8_t[], size_t); + String requestFileUploadURL(String); + bool finalizeFileUpload(String); + bool uploadFileContent(uint8_t[], size_t, String); - // Object - uint64_t uploadObjects(uint64_t, SipfObjectObject *, uint8_t); + // Object + uint64_t uploadObjects(uint64_t, SipfObjectObject *, uint8_t); private: - String user = ""; - String pass = ""; + String user = ""; + String pass = ""; - int port = 80; // port 80 is the default for HTTP + int port = 80; // port 80 is the default for HTTP - LTEClient *client = NULL; - LTETLSClient *tlsclient = NULL; + LTEClient *client = NULL; + LTETLSClient *tlsclient = NULL; - HttpClient *http_client = NULL; + HttpClient *http_client = NULL; - uint8_t objectBuffer[OBJ_HEADER_SIZE + MAX_PAYLOAD_SIZE]; + uint8_t objectBuffer[OBJ_HEADER_SIZE + MAX_PAYLOAD_SIZE]; - void _setup_http_client(const String &, uint16_t); - int _build_objects_up(uint8_t *, uint64_t, SipfObjectObject *, uint8_t); - int _build_objects_up_payload(uint8_t *, uint16_t, SipfObjectObject *, uint8_t); + void _setup_http_client(const String &, uint16_t); + int _build_objects_up(uint8_t *, uint64_t, SipfObjectObject *, uint8_t); + int _build_objects_up_payload(uint8_t *, uint16_t, SipfObjectObject *, uint8_t); }; -#endif // SIPF_CLIENT_H +#endif // SIPF_CLIENT_H diff --git a/src/SipfClientFile.cpp b/src/SipfClientFile.cpp index 1fb6fd5..8ef16a5 100644 --- a/src/SipfClientFile.cpp +++ b/src/SipfClientFile.cpp @@ -1,33 +1,28 @@ #include "SipfClient.h" -bool SipfClient::uploadFile(String filename, uint8_t buf[], size_t size) -{ +bool SipfClient::uploadFile(String filename, uint8_t buf[], size_t size) { // 1. Get uplaod URL String uploadURL = requestFileUploadURL(filename); - if (uploadURL == "") - { + if (uploadURL == "") { return false; } // 2. Uplaod content bool ret = uploadFileContent(buf, size, uploadURL); - if (!ret) - { + if (!ret) { return false; } // 3. Complete upload ret = finalizeFileUpload(filename); - if (!ret) - { + if (!ret) { return false; } return true; } -String SipfClient::requestFileUploadURL(String filename) -{ +String SipfClient::requestFileUploadURL(String filename) { puts("request upload a file"); String url_name = String(file_path) + filename + String("/"); @@ -50,8 +45,7 @@ String SipfClient::requestFileUploadURL(String filename) http_client->stop(); - if (statusCode != 200) - { + if (statusCode != 200) { puts("error responce."); return ""; } @@ -60,8 +54,7 @@ String SipfClient::requestFileUploadURL(String filename) return response; } -bool SipfClient::finalizeFileUpload(String filename) -{ +bool SipfClient::finalizeFileUpload(String filename) { puts("request complete upload"); String url_name = String(file_path) + filename + String("/complete/"); @@ -84,8 +77,7 @@ bool SipfClient::finalizeFileUpload(String filename) http_client->stop(); - if (statusCode != 200) - { + if (statusCode != 200) { puts("error responce."); return false; } @@ -93,8 +85,7 @@ bool SipfClient::finalizeFileUpload(String filename) return true; } -bool SipfClient::uploadFileContent(uint8_t buf[], size_t size, String url) -{ +bool SipfClient::uploadFileContent(uint8_t buf[], size_t size, String url) { int host_index = url.indexOf("://"); String host = url.substring(host_index + 3); @@ -116,11 +107,9 @@ bool SipfClient::uploadFileContent(uint8_t buf[], size_t size, String url) uint8_t *sp = buf; size_t sent = 0; - while (sent < size) - { + while (sent < size) { size_t sending = size - sent; - if (sending > 1024) - { + if (sending > 1024) { sending = 1024; } http_client->write(sp, sending); diff --git a/src/SipfObj.cpp b/src/SipfObj.cpp index bbabede..89358cc 100644 --- a/src/SipfObj.cpp +++ b/src/SipfObj.cpp @@ -1,146 +1,131 @@ #include "SipfClient.h" -uint64_t SipfClient::uploadObjects(uint64_t utime, SipfObjectObject *objs, uint8_t obj_qty) -{ - _setup_http_client(data_server, 80); - - puts("upload objects."); - String contentType = "Content-type: application/octet-stream"; - - int packet_size = _build_objects_up(objectBuffer, utime, objs, obj_qty); - - if (packet_size <= OBJ_HEADER_SIZE) - { - puts("Error"); - return 0; - } - - http_client->beginRequest(); - http_client->post(data_path); - http_client->sendBasicAuth(user, pass); - http_client->sendHeader("Content-type: application/octet-stream"); - http_client->sendHeader("Content-Length", packet_size); - http_client->write(objectBuffer, packet_size); - http_client->endRequest(); - - int statusCode = http_client->responseStatusCode(); - Serial.print("Status code: "); - Serial.println(statusCode); - if (statusCode < 200 || 299 < statusCode) - { - return 0; - } - - packet_size = http_client->read(objectBuffer, http_client->contentLength()); - printf("packet_size=%d\n", packet_size); - for (uint8_t i = 0; i < packet_size; i++) - { - printf("0x%02x ", objectBuffer[i]); - } - printf("\n"); - - // COMMAND_TYPE - if (objectBuffer[0] != OBJID_NOTIFICATION) - { - puts("error type!"); - return 0; - } - - int payload_length = objectBuffer[10] << 8 | objectBuffer[11]; - - if (payload_length != 18) - { - puts("error size!"); - return 0; - } - - uint64_t otid = 0; - memcpy(&otid, &objectBuffer[2], sizeof(int64_t)); - - http_client->stop(); - - return otid; +uint64_t SipfClient::uploadObjects(uint64_t utime, SipfObjectObject *objs, uint8_t obj_qty) { + _setup_http_client(data_server, 80); + + puts("upload objects."); + String contentType = "Content-type: application/octet-stream"; + + int packet_size = _build_objects_up(objectBuffer, utime, objs, obj_qty); + + if (packet_size <= OBJ_HEADER_SIZE) { + puts("Error"); + return 0; + } + + http_client->beginRequest(); + http_client->post(data_path); + http_client->sendBasicAuth(user, pass); + http_client->sendHeader("Content-type: application/octet-stream"); + http_client->sendHeader("Content-Length", packet_size); + http_client->write(objectBuffer, packet_size); + http_client->endRequest(); + + int statusCode = http_client->responseStatusCode(); + Serial.print("Status code: "); + Serial.println(statusCode); + if (statusCode < 200 || 299 < statusCode) { + return 0; + } + + packet_size = http_client->read(objectBuffer, http_client->contentLength()); + printf("packet_size=%d\n", packet_size); + for (uint8_t i = 0; i < packet_size; i++) { + printf("0x%02x ", objectBuffer[i]); + } + printf("\n"); + + // COMMAND_TYPE + if (objectBuffer[0] != OBJID_NOTIFICATION) { + puts("error type!"); + return 0; + } + + int payload_length = objectBuffer[10] << 8 | objectBuffer[11]; + + if (payload_length != 18) { + puts("error size!"); + return 0; + } + + uint64_t otid = 0; + memcpy(&otid, &objectBuffer[2], sizeof(int64_t)); + + http_client->stop(); + + return otid; } -int SipfClient::_build_objects_up(uint8_t *ptr, uint64_t utime, SipfObjectObject *objs, uint8_t obj_qty) -{ - int payload_size = _build_objects_up_payload((ptr + OBJ_HEADER_SIZE), MAX_PAYLOAD_SIZE, objs, obj_qty); +int SipfClient::_build_objects_up(uint8_t *ptr, uint64_t utime, SipfObjectObject *objs, uint8_t obj_qty) { + int payload_size = _build_objects_up_payload((ptr + OBJ_HEADER_SIZE), MAX_PAYLOAD_SIZE, objs, obj_qty); - printf("payload_size=%d\n", payload_size); + printf("payload_size=%d\n", payload_size); - // COMMAND_TYPE - ptr[0] = (uint8_t)OBJECTS_UP; + // COMMAND_TYPE + ptr[0] = (uint8_t)OBJECTS_UP; - // COMMAND_TIME - ptr[1] = 0xff & (utime >> (8 * 7)); - ptr[2] = 0xff & (utime >> (8 * 6)); - ptr[3] = 0xff & (utime >> (8 * 5)); - ptr[4] = 0xff & (utime >> (8 * 4)); - ptr[5] = 0xff & (utime >> (8 * 3)); - ptr[6] = 0xff & (utime >> (8 * 2)); - ptr[7] = 0xff & (utime >> (8 * 1)); - ptr[8] = 0xff & (utime >> (8 * 0)); + // COMMAND_TIME + ptr[1] = 0xff & (utime >> (8 * 7)); + ptr[2] = 0xff & (utime >> (8 * 6)); + ptr[3] = 0xff & (utime >> (8 * 5)); + ptr[4] = 0xff & (utime >> (8 * 4)); + ptr[5] = 0xff & (utime >> (8 * 3)); + ptr[6] = 0xff & (utime >> (8 * 2)); + ptr[7] = 0xff & (utime >> (8 * 1)); + ptr[8] = 0xff & (utime >> (8 * 0)); - // OPTION_FLAG - ptr[9] = 0x00; + // OPTION_FLAG + ptr[9] = 0x00; - // PAYLOAD_SIZE (BigEndian) - ptr[10] = (uint8_t)(payload_size >> 8); - ptr[11] = (uint8_t)(payload_size & 0xff); + // PAYLOAD_SIZE (BigEndian) + ptr[10] = (uint8_t)(payload_size >> 8); + ptr[11] = (uint8_t)(payload_size & 0xff); - if (payload_size > 1) - { - return payload_size + OBJ_HEADER_SIZE; - } - return -1; + if (payload_size > 1) { + return payload_size + OBJ_HEADER_SIZE; + } + return -1; } -int SipfClient::_build_objects_up_payload(uint8_t *raw_buff, uint16_t sz_raw_buff, SipfObjectObject *objs, uint8_t obj_qty) -{ - static uint8_t work[220]; - if (raw_buff == NULL) - { - return -1; +int SipfClient::_build_objects_up_payload(uint8_t *raw_buff, uint16_t sz_raw_buff, SipfObjectObject *objs, uint8_t obj_qty) { + static uint8_t work[220]; + if (raw_buff == NULL) { + return -1; + } + + memset(raw_buff, 0, sz_raw_buff); + int idx_raw_buff = 0; + for (int i = 0; i < obj_qty; i++) { + // LOG_DBG("objs[%d]", i); + if (objs[i].value_len > 220) { + return -1; } - - memset(raw_buff, 0, sz_raw_buff); - int idx_raw_buff = 0; - for (int i = 0; i < obj_qty; i++) - { - // LOG_DBG("objs[%d]", i); - if (objs[i].value_len > 220) - { - return -1; + raw_buff[idx_raw_buff++] = objs[i].obj_type; + raw_buff[idx_raw_buff++] = objs[i].obj_tagid; + raw_buff[idx_raw_buff++] = objs[i].value_len; + + switch (objs[i].obj_type) { + case OBJ_TYPE_UINT8: + case OBJ_TYPE_INT8: + case OBJ_TYPE_BIN: + case OBJ_TYPE_STR_UTF8: + // バイトスワップ必要なし + memcpy(&raw_buff[idx_raw_buff], objs[i].value, objs[i].value_len); + idx_raw_buff += objs[i].value_len; + break; + default: + // バイトスワップする(リトリエンディアン->ビッグエンディアン) + if (objs[i].value_len % 2) { + // データ長が偶数じゃない + return -1; } - raw_buff[idx_raw_buff++] = objs[i].obj_type; - raw_buff[idx_raw_buff++] = objs[i].obj_tagid; - raw_buff[idx_raw_buff++] = objs[i].value_len; - - switch (objs[i].obj_type) - { - case OBJ_TYPE_UINT8: - case OBJ_TYPE_INT8: - case OBJ_TYPE_BIN: - case OBJ_TYPE_STR_UTF8: - // バイトスワップ必要なし - memcpy(&raw_buff[idx_raw_buff], objs[i].value, objs[i].value_len); - idx_raw_buff += objs[i].value_len; - break; - default: - // バイトスワップする(リトリエンディアン->ビッグエンディアン) - if (objs[i].value_len % 2) - { - // データ長が偶数じゃない - return -1; - } - for (int j = 0; j < objs[i].value_len; j++) - { - work[j] = objs[i].value[objs[i].value_len - j - 1]; - } - memcpy(&raw_buff[idx_raw_buff], work, objs[i].value_len); - idx_raw_buff += objs[i].value_len; - break; + for (int j = 0; j < objs[i].value_len; j++) { + work[j] = objs[i].value[objs[i].value_len - j - 1]; } + memcpy(&raw_buff[idx_raw_buff], work, objs[i].value_len); + idx_raw_buff += objs[i].value_len; + break; } - return idx_raw_buff; // バッファに書いたデータ長を返す + } + return idx_raw_buff; // バッファに書いたデータ長を返す } diff --git a/src/sipf-arduino-client.h b/src/sipf-arduino-client.h index 4935020..6328520 100644 --- a/src/sipf-arduino-client.h +++ b/src/sipf-arduino-client.h @@ -3,4 +3,4 @@ #include "SipfClient.h" -#endif //SIPF_ARDUINO_CLIENT_H +#endif //SIPF_ARDUINO_CLIENT_H From 0fe16f893c0ed763090abed7d09c93968b82d9a1 Mon Sep 17 00:00:00 2001 From: ta-takahashi Date: Thu, 21 Sep 2023 11:23:08 +0900 Subject: [PATCH 2/5] =?UTF-8?q?SIPF=E3=83=A9=E3=82=A4=E3=83=96=E3=83=A9?= =?UTF-8?q?=E3=83=AA=E3=81=AB=E3=80=81=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E3=83=80=E3=82=A6=E3=83=B3=E3=83=AD=E3=83=BC=E3=83=89=E6=A9=9F?= =?UTF-8?q?=E8=83=BD=E3=80=81=E3=82=AA=E3=83=96=E3=82=B8=E3=82=A7=E3=82=AF?= =?UTF-8?q?=E3=83=88=E3=83=80=E3=82=A6=E3=83=B3=E3=83=AD=E3=83=BC=E3=83=89?= =?UTF-8?q?=E6=A9=9F=E8=83=BD=E3=82=92=E8=BF=BD=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/SipfClient.h | 20 ++++++++ src/SipfClientFile.cpp | 109 ++++++++++++++++++++++++++++++++++++++++ src/SipfObj.cpp | 110 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 239 insertions(+) diff --git a/src/SipfClient.h b/src/SipfClient.h index 6097efc..58f0dd1 100644 --- a/src/SipfClient.h +++ b/src/SipfClient.h @@ -1,3 +1,4 @@ +#include "stdint.h" /* * SipfClient.h * Author T.Hayakawa @@ -65,6 +66,8 @@ #define OBJ_HEADER_SIZE 12 #define MAX_PAYLOAD_SIZE 1024 +#define OBJ_DOWN_PAYLOAD_SIZE_MIN 35 + #define OBJ_TYPE_UINT8 0x00 #define OBJ_TYPE_INT8 0x01 #define OBJ_TYPE_UINT16 0x02 @@ -132,6 +135,16 @@ typedef struct uint8_t value[16]; } SipfObjectOtid; +typedef struct +{ + uint8_t down_request_result; + SipfObjectOtid otid; + uint64_t timestamp_src; + uint64_t timestamp_platfrom_from_src; + uint8_t remains; + uint8_t *objects_data; +} SipfObjectDown; + const String auth_server = "auth.sipf.iot.sakura.ad.jp"; const String auth_path = "/v0/session_key"; @@ -158,8 +171,14 @@ class SipfClient { bool finalizeFileUpload(String); bool uploadFileContent(uint8_t[], size_t, String); + uint64_t downloadFile(String, uint8_t[], size_t); + String requestFileDownloadURL(String); + uint64_t downloadFileContent(uint8_t[], size_t, String); + + // Object uint64_t uploadObjects(uint64_t, SipfObjectObject *, uint8_t); + uint64_t downloadObjects(uint64_t, SipfObjectDown *); private: String user = ""; @@ -177,6 +196,7 @@ class SipfClient { void _setup_http_client(const String &, uint16_t); int _build_objects_up(uint8_t *, uint64_t, SipfObjectObject *, uint8_t); int _build_objects_up_payload(uint8_t *, uint16_t, SipfObjectObject *, uint8_t); + int _build_objects_down_request(uint8_t *ptr, uint64_t utime); }; #endif // SIPF_CLIENT_H diff --git a/src/SipfClientFile.cpp b/src/SipfClientFile.cpp index 8ef16a5..7324119 100644 --- a/src/SipfClientFile.cpp +++ b/src/SipfClientFile.cpp @@ -1,3 +1,4 @@ +#include "Arduino.h" #include "SipfClient.h" bool SipfClient::uploadFile(String filename, uint8_t buf[], size_t size) { @@ -130,3 +131,111 @@ bool SipfClient::uploadFileContent(uint8_t buf[], size_t size, String url) { return true; } + +// +// ファイル受信 +// +uint64_t SipfClient::downloadFile(String filename, uint8_t buf[], size_t bufSize) { + + // 1. Get download URL + String downloadURL = requestFileDownloadURL(filename); + Serial.println(downloadURL); + if (downloadURL == "") { + return 0; + } + + // 2. Download contet + uint64_t downLoadfileSize = downloadFileContent(buf, bufSize, downloadURL); + + return downLoadfileSize; +} + +uint64_t SipfClient::downloadFileContent(uint8_t buf[], size_t bufSize, String url) { + + int host_index = url.indexOf("://"); + String host = url.substring(host_index + 3); + int path_index = host.indexOf("/"); + String path = host.substring(path_index); + host = host.substring(0, path_index); + + bool readComplete = false; + uint64_t lastReadTime = 0; + int readByte = 0; + + _setup_http_client(host, 80); + + int err = http_client->get(path); + if (err != 0) { + printf("%s http_client->get error, %d\n", __func__, err); + goto QUIT; + } + if (http_client->responseStatusCode() != 200) { + printf("%s http_client->responseStatusCode error, statuCode %d\n", __func__, http_client->responseStatusCode()); + goto QUIT; + } + if (bufSize < http_client->contentLength()) { + printf("%s error, buffer size is too small\n", __func__); + goto QUIT; + } + + lastReadTime = millis(); + while (true) { + if (!http_client->connected()) { + printf("%s error, !http_client->connected\n", __func__); + break; + } + if (!http_client->available()) { + if ((millis() - lastReadTime) > (30 * 1000)) { + printf("%s error, !http_client->available, wait timeout\n", __func__); + break; + } + delay(1000); // wait for retry + continue; + } + readByte += http_client->read(&buf[readByte], (bufSize - readByte)); + if (http_client->endOfBodyReached()) { + readComplete = true; + break; + } + if ((bufSize - readByte) <= 0) { + printf("%s error, buffer size is too small\n", __func__); + break; + } + lastReadTime = millis(); + } + +QUIT: + http_client->stop(); + if (!readComplete) { + return 0; + } + return readByte; +} + +String SipfClient::requestFileDownloadURL(String filename) { + String url_name = String(file_path) + filename + String("/"); + + String downloadUrl = ""; + int err = 0; + int statusCode = 0; + + _setup_http_client(file_server, 80); + + http_client->beginRequest(); + http_client->get(url_name); + http_client->sendBasicAuth(user, pass); + http_client->endRequest(); + + statusCode = http_client->responseStatusCode(); + if (statusCode != 200) { + printf("%s http_client->responseStatusCode error, statuCode %d\n", __func__, statusCode); + goto QUIT; + } + + downloadUrl = http_client->responseBody(); + downloadUrl.trim(); + +QUIT: + http_client->stop(); + return downloadUrl; +} diff --git a/src/SipfObj.cpp b/src/SipfObj.cpp index 89358cc..4b55d95 100644 --- a/src/SipfObj.cpp +++ b/src/SipfObj.cpp @@ -129,3 +129,113 @@ int SipfClient::_build_objects_up_payload(uint8_t *raw_buff, uint16_t sz_raw_buf } return idx_raw_buff; // バッファに書いたデータ長を返す } + +// +// 64bitデータのバイトスワップ +// +static uint64_t bswap64(uint64_t value) { + return ((value >> 56) & 0x00000000000000FF) | ((value >> 40) & 0x000000000000FF00) | ((value >> 24) & 0x0000000000FF0000) | ((value >> 8) & 0x00000000FF000000) | ((value << 8) & 0x000000FF00000000) | ((value << 24) & 0x0000FF0000000000) | ((value << 40) & 0x00FF000000000000) | ((value << 56) & 0xFF00000000000000); +} + +// +// COMMAND_TYPE_OBJECTS_DOWN_REQUESTを送信し、COMMAND_TYPE_OBJECTS_DOWNを受信する。戻り値は、受信したオブジェクト群のデータのbyte数を返す。 +// +uint64_t SipfClient::downloadObjects(uint64_t utime, SipfObjectDown *objDown) { + _setup_http_client(data_server, 80); + + // 要求(COMMAND_TYPE_DOWN_REQUEST)を送信 + int packet_size = _build_objects_down_request(objectBuffer, utime); + + http_client->beginRequest(); + http_client->post(data_path); + http_client->sendBasicAuth(user, pass); + http_client->sendHeader("Content-type: application/octet-stream"); + http_client->sendHeader("Content-Length", packet_size); + http_client->write(objectBuffer, packet_size); + http_client->endRequest(); + + int statusCode = http_client->responseStatusCode(); + if (statusCode < 200 || 299 < statusCode) { + printf("error, responseStatusCode (%d)", statusCode); + return 0; + } + + // 応答(COMMAND_TYPE_OBJECTS_DOWN)の解析 + packet_size = http_client->read(objectBuffer, http_client->contentLength()); + /* + printf("packet_size=%d\n", packet_size); + for (uint8_t i = 0; i < packet_size; i++) + { + printf("0x%02x ", objectBuffer[i]); + } + printf("\n"); +*/ + if (objectBuffer[0] != OBJECTS_DOWN) { + printf("error, COMMAND_TYPE (0x%02X)", objectBuffer[0]); + return 0; + } + + int payload_length = (objectBuffer[10] << 8 | objectBuffer[11]); + if (payload_length < OBJ_DOWN_PAYLOAD_SIZE_MIN) { + printf("error, payload_length (%d)\n", payload_length); + return 0; + } + + int i = OBJ_HEADER_SIZE; + + objDown->down_request_result = objectBuffer[i]; + i += sizeof(objDown->down_request_result); + + memcpy(&objDown->otid, &objectBuffer[i], sizeof(objDown->otid)); + i += sizeof(objDown->otid); + + memcpy(&objDown->timestamp_src, &objectBuffer[i], sizeof(objDown->timestamp_src)); + objDown->timestamp_src = bswap64(objDown->timestamp_src); + i += sizeof(objDown->timestamp_src); + + memcpy(&objDown->timestamp_platfrom_from_src, &objectBuffer[i], sizeof(objDown->timestamp_platfrom_from_src)); + objDown->timestamp_platfrom_from_src = bswap64(objDown->timestamp_platfrom_from_src); + i += sizeof(objDown->timestamp_platfrom_from_src); + + objDown->remains = objectBuffer[i]; + i += sizeof(objDown->remains); + + i += 1; // RESERVED 1byte + + int objDataLength = packet_size - (OBJ_HEADER_SIZE + OBJ_DOWN_PAYLOAD_SIZE_MIN); + objDown->objects_data = &objectBuffer[i]; + + http_client->stop(); + + return objDataLength; +} + +// +// COMMAND_TYPE_OBJECTS_DOWN_REQUESTのデータを組立 +// +int SipfClient::_build_objects_down_request(uint8_t *ptr, uint64_t utime) { + // COMMAND_TYPE + ptr[0] = (uint8_t)OBJECTS_DOWN_REQUEST; + + // COMMAND_TIME + ptr[1] = 0xff & (utime >> (8 * 7)); + ptr[2] = 0xff & (utime >> (8 * 6)); + ptr[3] = 0xff & (utime >> (8 * 5)); + ptr[4] = 0xff & (utime >> (8 * 4)); + ptr[5] = 0xff & (utime >> (8 * 3)); + ptr[6] = 0xff & (utime >> (8 * 2)); + ptr[7] = 0xff & (utime >> (8 * 1)); + ptr[8] = 0xff & (utime >> (8 * 0)); + + // OPTION_FLAG + ptr[9] = 0x00; + + // PAYLOAD_LENGTH + ptr[10] = 0x00; + ptr[11] = 0x01; + + // PAYLOAD + ptr[12] = 0x00; // RESERVED 1byte + + return (OBJ_HEADER_SIZE + 1); +} From 09545cf0ca8a15579fe4dc95b4f95d863384da42 Mon Sep 17 00:00:00 2001 From: ta-takahashi Date: Thu, 21 Sep 2023 11:23:47 +0900 Subject: [PATCH 3/5] =?UTF-8?q?=E3=82=B5=E3=83=BC=E3=83=9E=E3=83=AB?= =?UTF-8?q?=E3=83=97=E3=83=AA=E3=83=B3=E3=82=BF=E3=83=BC=E3=81=AE=E4=BD=9C?= =?UTF-8?q?=E4=BE=8B=E3=81=AE=E3=82=B9=E3=82=B1=E3=83=83=E3=83=81=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../thermal_printer/sakura_logo.h | 322 ++++++++++++++++++ .../thermal_printer/thermal_printer.ino | 200 +++++++++++ 2 files changed, 522 insertions(+) create mode 100644 examples/mono_platform_sample/thermal_printer/sakura_logo.h create mode 100644 examples/mono_platform_sample/thermal_printer/thermal_printer.ino diff --git a/examples/mono_platform_sample/thermal_printer/sakura_logo.h b/examples/mono_platform_sample/thermal_printer/sakura_logo.h new file mode 100644 index 0000000..22bcec2 --- /dev/null +++ b/examples/mono_platform_sample/thermal_printer/sakura_logo.h @@ -0,0 +1,322 @@ +//------------------------------------------------------------------------------ +// File generated by LCD Assistant +// http://en.radzio.dxp.pl/bitmap_converter/ +//------------------------------------------------------------------------------ + +#define SAKURA_LOGO_WIDTH 384 +#define SAKURA_LOGO_HEIGHT 104 + +static const uint8_t PROGMEM sakura_logo_data[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x1F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xE0, 0x00, 0x3F, 0xE0, 0x00, 0x3C, 0x00, 0x0F, 0x00, + 0x06, 0x07, 0x80, 0x03, 0x80, 0xFF, 0xF8, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0xFF, 0xF8, 0x00, 0x3E, 0x00, 0x0F, 0x00, + 0x0C, 0x07, 0x80, 0x03, 0x80, 0xFF, 0xFF, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, + 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0x80, 0x01, 0xE0, 0x18, 0x00, 0x7E, 0x00, 0x0F, 0x00, + 0x18, 0x07, 0x80, 0x03, 0x80, 0xF0, 0x0F, 0x80, 0x01, 0xF8, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, + 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0x80, 0x03, 0xC0, 0x00, 0x00, 0x7F, 0x00, 0x0F, 0x00, + 0x30, 0x07, 0x80, 0x03, 0x80, 0xF0, 0x07, 0xC0, 0x01, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0x00, 0x03, 0x80, 0x00, 0x00, 0x6F, 0x00, 0x0F, 0x00, + 0x60, 0x07, 0x80, 0x03, 0x80, 0xF0, 0x03, 0xC0, 0x01, 0xBC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFE, 0x00, 0x07, 0x80, 0x00, 0x00, 0xE7, 0x00, 0x0F, 0x00, + 0xC0, 0x07, 0x80, 0x03, 0x80, 0xF0, 0x01, 0xE0, 0x03, 0x9E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFC, 0x00, 0x07, 0xC0, 0x00, 0x00, 0xC7, 0x80, 0x0F, 0x01, + 0x80, 0x07, 0x80, 0x03, 0x80, 0xF0, 0x01, 0xE0, 0x03, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, + 0x1E, 0x00, 0x07, 0xC0, 0x00, 0x02, 0x00, 0x0E, 0x00, 0x07, 0xC0, 0x07, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xF8, 0x00, 0x03, 0xC0, 0x00, 0x01, 0xC7, 0x80, 0x0F, 0x03, + 0x80, 0x07, 0x80, 0x03, 0x80, 0xF0, 0x01, 0xE0, 0x07, 0x1E, 0x00, 0x00, 0x0E, 0x07, 0x8F, 0xE0, + 0x7F, 0xF0, 0x1E, 0xF8, 0x07, 0x0E, 0x1E, 0x7F, 0x80, 0x1E, 0xF0, 0x1F, 0xFC, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xF8, 0x00, 0x03, 0xE0, 0x00, 0x01, 0x83, 0x80, 0x0F, 0x07, + 0x00, 0x07, 0x80, 0x03, 0x80, 0xF0, 0x01, 0xE0, 0x07, 0x0E, 0x00, 0x00, 0x0E, 0x07, 0xA1, 0xF0, + 0x1E, 0x00, 0x38, 0x1C, 0x07, 0x3E, 0x1E, 0x87, 0xC0, 0x70, 0x38, 0x07, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xF0, 0x00, 0x01, 0xF8, 0x00, 0x01, 0x83, 0xC0, 0x0F, 0x06, + 0x00, 0x07, 0x80, 0x03, 0x80, 0xF0, 0x03, 0xC0, 0x06, 0x0F, 0x00, 0x00, 0x0E, 0x07, 0xC0, 0xF0, + 0x1E, 0x00, 0x70, 0x1C, 0x07, 0x60, 0x1F, 0x03, 0xC0, 0x70, 0x1C, 0x07, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0xFE, 0x00, 0x03, 0x83, 0xC0, 0x0F, 0x0C, + 0x00, 0x07, 0x80, 0x03, 0x80, 0xF0, 0x03, 0xC0, 0x0E, 0x07, 0x00, 0x00, 0x0E, 0x07, 0x80, 0x70, + 0x1E, 0x00, 0x70, 0x0E, 0x07, 0x80, 0x1E, 0x01, 0xC0, 0xE0, 0x1C, 0x07, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0x80, 0x00, 0x00, 0x3F, 0x80, 0x03, 0x01, 0xE0, 0x0F, 0x1E, + 0x00, 0x07, 0x80, 0x03, 0x80, 0xF0, 0x0F, 0x80, 0x0C, 0x07, 0x80, 0x00, 0x0E, 0x07, 0x80, 0x70, + 0x1E, 0x00, 0xF0, 0x0E, 0x07, 0x00, 0x1E, 0x01, 0xC0, 0xE0, 0x1C, 0x07, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFE, 0x00, 0x00, 0x00, 0x0F, 0xE0, 0x07, 0x01, 0xE0, 0x0F, 0x3F, + 0x00, 0x07, 0x80, 0x03, 0x80, 0xFF, 0xFE, 0x00, 0x0C, 0x07, 0x80, 0x00, 0x0E, 0x07, 0x80, 0x70, + 0x1E, 0x00, 0xE0, 0x0E, 0x07, 0x00, 0x1E, 0x01, 0xC1, 0xE0, 0x1E, 0x07, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x03, 0xF8, 0x00, 0x00, 0x00, 0x03, 0xF0, 0x07, 0x00, 0xE0, 0x0F, 0x7F, + 0x00, 0x07, 0x80, 0x03, 0x80, 0xFF, 0xF8, 0x00, 0x1C, 0x03, 0xC0, 0x00, 0x0E, 0x07, 0x80, 0x70, + 0x1E, 0x00, 0xE0, 0x0E, 0x07, 0x00, 0x1E, 0x01, 0xC1, 0xE0, 0x1E, 0x07, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x06, 0x00, 0xF0, 0x0F, 0xC7, + 0x80, 0x07, 0x80, 0x03, 0x80, 0xF0, 0x78, 0x00, 0x18, 0x03, 0xC0, 0x00, 0x0E, 0x07, 0x80, 0x70, + 0x1E, 0x00, 0xFF, 0xFF, 0x07, 0x00, 0x1E, 0x01, 0xC1, 0xFF, 0xFE, 0x07, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x0F, 0xFF, 0xF0, 0x0F, 0x87, + 0xC0, 0x07, 0x80, 0x03, 0x80, 0xF0, 0x3C, 0x00, 0x3F, 0xFF, 0xC0, 0x00, 0x0E, 0x07, 0x80, 0x70, + 0x1E, 0x00, 0xF0, 0x00, 0x07, 0x00, 0x1E, 0x01, 0xC1, 0xE0, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x0F, 0xFF, 0xF8, 0x0F, 0x83, + 0xC0, 0x07, 0x80, 0x03, 0x80, 0xF0, 0x1E, 0x00, 0x3F, 0xFF, 0xE0, 0x00, 0x0E, 0x07, 0x80, 0x70, + 0x1E, 0x00, 0xE0, 0x00, 0x07, 0x00, 0x1E, 0x01, 0xC1, 0xE0, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x1C, 0x00, 0x78, 0x0F, 0x01, + 0xE0, 0x03, 0x80, 0x03, 0x80, 0xF0, 0x1E, 0x00, 0x30, 0x01, 0xE0, 0x00, 0x0E, 0x07, 0x80, 0x70, + 0x1E, 0x00, 0xE0, 0x00, 0x07, 0x00, 0x1E, 0x01, 0xC1, 0xE0, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x1C, 0x00, 0x38, 0x0F, 0x00, + 0xF0, 0x03, 0x80, 0x03, 0x00, 0xF0, 0x0F, 0x00, 0x70, 0x00, 0xE0, 0x00, 0x0E, 0x07, 0x80, 0x70, + 0x1E, 0x00, 0xF0, 0x00, 0x07, 0x00, 0x1E, 0x01, 0xC0, 0xE0, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x3C, 0x18, 0x00, 0x3C, 0x0F, 0x00, + 0xF8, 0x03, 0xC0, 0x07, 0x00, 0xF0, 0x0F, 0x00, 0x60, 0x00, 0xF0, 0x00, 0x0E, 0x07, 0x80, 0x70, + 0x1E, 0x00, 0x70, 0x00, 0x07, 0x00, 0x1E, 0x01, 0xC0, 0xE0, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x78, 0x38, 0x00, 0x3C, 0x0F, 0x00, + 0x78, 0x01, 0xE0, 0x06, 0x00, 0xF0, 0x07, 0x80, 0xE0, 0x00, 0x70, 0x00, 0x0E, 0x07, 0x80, 0x70, + 0x1E, 0x00, 0x70, 0x00, 0x07, 0x00, 0x1E, 0x01, 0xC0, 0x70, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0xF0, 0x30, 0x00, 0x1C, 0x0F, 0x00, + 0x3C, 0x00, 0xF0, 0x1C, 0x00, 0xF0, 0x03, 0x80, 0xE0, 0x00, 0x78, 0x00, 0x0E, 0x07, 0x80, 0x70, + 0x0E, 0x00, 0x38, 0x02, 0x07, 0x00, 0x1E, 0x01, 0xC0, 0x70, 0x04, 0x03, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xE0, 0x30, 0x00, 0x1E, 0x0F, 0x00, + 0x1E, 0x00, 0x7F, 0xF8, 0x00, 0xF0, 0x03, 0xC0, 0xC0, 0x00, 0x78, 0x00, 0x0E, 0x07, 0x80, 0x70, + 0x0F, 0x90, 0x1E, 0x1E, 0x07, 0x00, 0x1E, 0x01, 0xC0, 0x3C, 0x3C, 0x03, 0xE4, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x80, 0x70, 0x00, 0x0E, 0x0F, 0x00, + 0x1F, 0x00, 0x0F, 0xE0, 0x00, 0xF0, 0x01, 0xE1, 0xC0, 0x00, 0x38, 0x00, 0x0E, 0x07, 0x80, 0x70, + 0x03, 0xE0, 0x07, 0xF0, 0x07, 0x00, 0x1E, 0x01, 0xC0, 0x07, 0xE0, 0x00, 0xF8, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; diff --git a/examples/mono_platform_sample/thermal_printer/thermal_printer.ino b/examples/mono_platform_sample/thermal_printer/thermal_printer.ino new file mode 100644 index 0000000..5da175e --- /dev/null +++ b/examples/mono_platform_sample/thermal_printer/thermal_printer.ino @@ -0,0 +1,200 @@ +/* + * Copyright (C) 2023 SAKURA internet Inc. + */ +#include +#include +#include "SipfClient.h" +#include +#include +#include +#include "sakura_logo.h" + +LTE lteAccess; +LTEClient lteClient; +LTEScanner lteScanner; +SipfClient sipfClient; + +SoftwareSerial PrinterSerial(PIN_D30, PIN_D31); +Adafruit_Thermal Printer(&PrinterSerial); + +JPEGDEC jpeg; + +static uint8_t imageBuffer[(1024 * 64)]; // 画像ファイルデータのバッファ +static uint8_t demodeBuffer[(1024 * 32)]; // 画像ファイルデータのディザリングに使用するバッファ + +/******************************************************************************* + * + * setup + * + *******************************************************************************/ +void setup() { + // initialize LED + pinMode(LED0, OUTPUT); + pinMode(LED1, OUTPUT); + pinMode(LED2, OUTPUT); + pinMode(LED3, OUTPUT); + + // initialize serial communications and wait for port to open: + Serial.begin(115200); + while (!Serial) { + ; // wait for serial port to connect. Needed for native USB port only + } + + // サーマルプリンター初期化 + PrinterSerial.begin(19200); + Printer.begin(); + + // ロゴを印刷 + Printer.printBitmap(SAKURA_LOGO_WIDTH, SAKURA_LOGO_HEIGHT, sakura_logo_data); + Printer.feed(4); + + // LTE通信初期化 + setupLte(); + + // SIPF通信初期化 + sipfClient.begin(<eClient, 80); + if (!sipfClient.authenticate()) { + printf("%s error, sipfClient.authenticate\n", __func__); + } +} + +// +// LTE通信初期化 +// +void setupLte(void) { + while (true) { + // Power on the modem and Enable the radio function. + printf("lteAccess.begin\n", __func__); + if (lteAccess.begin() != LTE_SEARCHING) { + printf("%s error, Could not transition to LTE_SEARCHING.\n", __func__); + while (true) { + sleep(1); + } + } + + // The connection process to the APN will start. + // If the synchronous parameter is false, the return value will be returned when the connection process is started. + if (lteAccess.attach(APP_LTE_RAT, + APP_LTE_APN, + APP_LTE_USER_NAME, + APP_LTE_PASSWORD, + APP_LTE_AUTH_TYPE, + APP_LTE_IP_TYPE) + == LTE_READY) { + printf("%s Attach succeeded.\n", __func__); + break; + } + + // If the following logs occur frequently, one of the following might be a cause: + // - APN settings are incorrect + // - SIM is not inserted correctly + // - If you have specified LTE_NET_RAT_NBIOT for APP_LTE_RAT, your LTE board may not support it. + // - Rejected from LTE network + printf("%s lteAccess An error has occurred. Shutdown and retry the network attach process after 1 second.\n", __func__); + lteAccess.shutdown(); + sleep(1); + } +} + +/******************************************************************************* + * + * loop + * + *******************************************************************************/ +void loop() { + static int lastFileSize = 0; + + // 画像ファイルをダウンロード + digitalWrite(LED2, HIGH); + printf("downloadFile\n"); + int fileSize = sipfClient.downloadFile("image.jpg", imageBuffer, sizeof(imageBuffer)); + printf(" fileSize %d byte (%.2f KB)\n", fileSize, ((float)fileSize / 1024)); + digitalWrite(LED2, LOW); + + // 画像ファイルのサイズが前回と異なる場合は、印刷 + if (fileSize != lastFileSize) { + printf("printJpeg\n"); + Printer.printf("-- %s --\n", getTimeStr()); + printJpeg(imageBuffer, fileSize); + Printer.feed(4); + printf(" OK\n"); + + lastFileSize = fileSize; + } + + // メッセージ(オブジェクト)をダウンロード + uint64_t objDataLength = 0; + SipfObjectDown objDown; + + memset(&objDown, 0, sizeof(objDown)); + printf("downloadObjects\n"); + objDataLength = sipfClient.downloadObjects(0, &objDown); + + printf(" objDataLength %llu\n", objDataLength); + for (int i = 0; i < objDataLength; i++) { // オブジェクトのデータをダンプ + printf(" %03d 0x%02X\n", i, objDown.objects_data[i]); + } + if (objDataLength >= 3) { + if (objDown.objects_data[0] == OBJ_TYPE_STR_UTF8) { // オブジェクトのタイプが可変長UTF-8文字列の場合は、印刷 + Printer.printf("%s\n", &objDown.objects_data[3]); + } + } + + sleep(60); +} + +// +// 現在時刻の文字列を取得 +// +char *getTimeStr(void) { + static char timestr[20]; + + time_t unixTime = lteAccess.getTime(); + struct tm *timeinfo; + + timeinfo = localtime(&unixTime); + strftime(timestr, sizeof(timestr), "%Y/%m/%d %H:%M:%S", timeinfo); + return timestr; +} + +// +// JPEGデータを印刷 ... ライブラリ(JPEGDEC)を利用してディザリングし、そのコールバック関数内で印刷を実行 +// +void printJpeg(uint8_t *jpeg_data, int jpeg_data_len) { + int ret; + + jpeg.openRAM(jpeg_data, jpeg_data_len, JPEGDraw); + + printf("jpeg %d * %d\n", jpeg.getWidth(), jpeg.getHeight()); + + jpeg.setPixelType(ONE_BIT_DITHERED); + + printf("jpeg.decodeDither...\n"); + ret = jpeg.decodeDither(demodeBuffer, 0); + printf(" ret %d\n", ret); + + jpeg.close(); +} + +// +// ディザリング(decodeDither関数)実行時のコールバック関数 +// +int JPEGDraw(JPEGDRAW *pDraw) { + digitalWrite(LED3, HIGH); + + printf("JPEGDraw Callback "); + printf("x %3d, ", pDraw->x); + printf("y %3d, ", pDraw->y); + printf("iWidth %03d, ", pDraw->iWidth); + printf("iHeight %03d, ", pDraw->iHeight); + printf("iBpp %d\n", pDraw->iBpp); + + for (int i = 0; i < (pDraw->iWidth * pDraw->iHeight); i++) { + demodeBuffer[i] = ~demodeBuffer[i]; // 白黒反転 + } + Printer.printBitmap(pDraw->iWidth, pDraw->iHeight, demodeBuffer); // 印刷 + + digitalWrite(LED3, LOW); + + return 1; +} From d6cb4033f847df9e41d8e9b0aaeb2020b47d9f6e Mon Sep 17 00:00:00 2001 From: ta-takahashi Date: Thu, 21 Sep 2023 13:06:29 +0900 Subject: [PATCH 4/5] =?UTF-8?q?=E3=83=A9=E3=82=A4=E3=83=96=E3=83=A9?= =?UTF-8?q?=E3=83=AA=E3=81=AE=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E3=82=92=200.1.0=20=E3=81=8B=E3=82=89=200.2.0=20=E3=81=AB?= =?UTF-8?q?=E5=A4=89=E6=9B=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 0516b27..81b9561 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=sipf-arduino-client -version=0.1.0 +version=0.2.0 author=SAKURA internet Inc. maintainer=SAKURA internet Inc. sentence=SIPF Library for Arduino From b753671e9963b1c32733ebd801693df78599d5d2 Mon Sep 17 00:00:00 2001 From: ta-takahashi Date: Thu, 21 Sep 2023 13:13:46 +0900 Subject: [PATCH 5/5] =?UTF-8?q?README.md=E3=81=AESupported=E3=81=AE?= =?UTF-8?q?=E9=A0=85=E7=9B=AE=E3=82=92=E8=BF=BD=E5=8A=A0=E3=80=82=20?= =?UTF-8?q?=E4=B8=80=E9=80=9A=E3=82=8A=E3=81=AE=E6=A9=9F=E8=83=BD=E3=82=92?= =?UTF-8?q?=E5=AE=9F=E8=A3=85=E3=81=97=E3=81=9F=E3=81=AE=E3=81=A7Not=20imp?= =?UTF-8?q?lemented=E3=81=AE=E9=A0=85=E7=9B=AE=E3=82=92=E5=89=8A=E9=99=A4?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/README.md b/README.md index c7530e8..898aaeb 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ Tested with SPRESENSE + SPRESENSE LTE拡張ボード . - ## Features *NOTE: The TLS connection has not been tested.* @@ -14,14 +13,10 @@ Tested with SPRESENSE + SPRESENSE LTE拡張ボード . ### Supported * オブジェクト送信 -* ファイル送信 - -### Not implemented - * オブジェクト受信 +* ファイル送信 * ファイル受信 - ## Requirement * ArduinoHttpClient library