This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SPI.h> | |
#include <Dns.h> | |
#include <Ethernet.h> | |
uint8_t mac[6]; | |
void setup() { | |
Serial.begin(115200); | |
Serial.println(F("System initialization start...")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <WiFi.h> | |
#define WIFI_SSID "" | |
#define WIFI_PASS "" | |
#define DNS_TEST_DOMAIN "google.com" | |
void setup() { | |
Serial.begin(115200); | |
Serial.printf("\n\nStart initialization...\n"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void socket_test(void) { | |
int8_t ret = socket(MQTT_SOCKET, Sn_MR_TCP, 3, 0); | |
if (ret != MQTT_SOCKET) { | |
LOG_E("Fail to create socket: %d\n", ret); | |
return; | |
} | |
LOG_I("Socket has been created\n"); | |
uint16_t port = 1883; | |
uint8_t mqtt_server_ip[4] = {192, 168, 0, 156}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "base64_app.h" | |
#include "mbedtls/gcm.h" | |
#define AES_GCM_APP_AES_TAG_SIZE_BYTES 16 | |
const char *key_p = "u56TiiWSiQ76L/t6X5C98TbATFDeUvTh5PfJsZv7H84="; | |
const char *iv_p = "Zidvdg8Z0bvmzr6K/hd7UQ=="; | |
const char *ciphertext_p = "70iQkg0mqML48Y1A0Mh5TROe+qD4jX7f5jjSwo0p/MVLuG4O"; | |
const char *plaintext_test_p = "Hello world from JS!"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "base64_app.h" | |
#include "mbedtls/gcm.h" | |
#include "mbedtls/error.h" | |
#define AES_GCM_APP_AES_TAG_SIZE_BYTES 16 | |
mbedtls_gcm_context aes; | |
const char *key_base64_p = "1BpsjPJ1Hiob0BZ1F491UpvPKiyxjRlUIibijcgEHPg="; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mbedtls/pk.h" | |
#include "mbedtls/rsa.h" | |
#include "mbedtls/error.h" | |
#include "mbedtls/base64.h" | |
#include "mbedtls/entropy.h" | |
#include "mbedtls/ctr_drbg.h" | |
#define PERS "rsa_encrypt" | |
const char* esp_pub_key_pem_test = "-----BEGIN PUBLIC KEY-----\n\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mbedtls/pk.h" | |
#include "mbedtls/rsa.h" | |
#include "mbedtls/error.h" | |
#include "mbedtls/base64.h" | |
#include "mbedtls/entropy.h" | |
#include "mbedtls/ctr_drbg.h" | |
#define PERS "rsa_encrypt" | |
mbedtls_pk_context public_key; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mbedtls/pk.h" | |
#include "mbedtls/error.h" | |
mbedtls_pk_context pk; | |
const char* esp_pub_key_pem_test = "-----BEGIN PUBLIC KEY-----\n\ | |
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDXn7jOg8QBSKJNmN4FqWtXa/+9\n\ | |
BbOpHdtN7k9ij95xQmLPV/DptPPKgM6mhK4k7va3ftD+Gv7LcmPELCPMqIvq2aLf\n\ | |
tgAb80HyHorfk6zQfNcyyJ0fblpyVschCMtO3qD4wahLlUcECf7uyVRFBHPxVrwi\n\ | |
UmK6TCiIjnSF2QahywIDAQAB\n\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mbedtls/base64.h" | |
#include "mbedtls/error.h" | |
size_t get_decoded_size(const char *base64_str_p) { | |
if (base64_str_p == NULL) { | |
return 0; | |
} | |
size_t pad_char_count = 0; | |
size_t base64_str_len = strlen(base64_str_p); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mbedtls/base64.h" | |
#include "mbedtls/error.h" | |
size_t get_encoded_size(size_t plain_data_size) { | |
return (4 * ceil((double)plain_data_size / 3)) + 1; | |
} | |
void setup() { | |
const char *test_data_p = "Hello world"; | |