|
cryptnox-sdk-esp32 1.0.0
ESP32 SDK for Cryptnox Hardware Wallet
|
#include "eth_rpc.h"#include <string.h>#include <strings.h>#include <stdlib.h>#include <stdio.h>#include <inttypes.h>#include "freertos/FreeRTOS.h"#include "freertos/event_groups.h"#include "esp_wifi.h"#include "esp_event.h"#include "esp_netif.h"#include "esp_log.h"#include "esp_http_client.h"#include "esp_crt_bundle.h"Go to the source code of this file.
Macros | |
| #define | WIFI_CONNECTED_BIT BIT0 |
| #define | WIFI_FAIL_BIT BIT1 |
| #define | WIFI_MAX_RETRY 5 |
| #define | WIFI_TIMEOUT_MS 30000 |
| #define | RESP_BUF_SIZE 1024U |
| #define | HEX_PER_BYTE 2U |
Functions | |
| static void | wifi_event_handler (void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data) |
| static bool | do_post (const char *body, char *resp_buf, size_t resp_buf_size) |
| static char | hex_nibble (uint8_t n) |
| static void | bytes_to_hex (const uint8_t *data, size_t len, char *out) |
| void | eth_rpc_init (const char *rpc_url, const char *from_addr) |
| void | eth_rpc_set_auth (const char *project_id, const char *api_secret) |
| bool | eth_rpc_wifi_connect (const char *ssid, const char *password) |
| bool | eth_rpc_get_nonce (uint64_t *nonce_out) |
| uint8_t | eth_rpc_ecrecover_parity (const uint8_t hash[32], const uint8_t r[32], const uint8_t s[32]) |
| bool | eth_rpc_send_raw_tx (const uint8_t *tx, size_t tx_len, char *tx_hash_out, size_t tx_hash_max) |
Variables | |
| static const char *const | TAG = "eth_rpc" |
| static const char * | s_rpc_url = NULL |
| static const char * | s_from_addr = NULL |
| static const char * | s_project_id = NULL |
| static const char * | s_api_secret = NULL |
| static EventGroupHandle_t | s_wifi_event_group |
| static int | s_retry_num = 0 |
| #define HEX_PER_BYTE 2U |
Definition at line 34 of file eth_rpc.cpp.
Referenced by bytes_to_hex(), eth_rpc_ecrecover_parity(), and eth_rpc_send_raw_tx().
| #define RESP_BUF_SIZE 1024U |
Definition at line 31 of file eth_rpc.cpp.
Referenced by eth_rpc_ecrecover_parity(), eth_rpc_get_nonce(), and eth_rpc_send_raw_tx().
| #define WIFI_CONNECTED_BIT BIT0 |
Definition at line 25 of file eth_rpc.cpp.
| #define WIFI_FAIL_BIT BIT1 |
Definition at line 26 of file eth_rpc.cpp.
| #define WIFI_MAX_RETRY 5 |
Definition at line 27 of file eth_rpc.cpp.
Referenced by wifi_event_handler(), and wifi_event_handler().
| #define WIFI_TIMEOUT_MS 30000 |
Definition at line 28 of file eth_rpc.cpp.
Referenced by eth_rpc_wifi_connect(), and wifi_start().
|
static |
Definition at line 156 of file eth_rpc.cpp.
References hex_nibble(), and HEX_PER_BYTE.
Referenced by eth_rpc_ecrecover_parity(), and eth_rpc_send_raw_tx().
|
static |
Definition at line 85 of file eth_rpc.cpp.
References s_api_secret, s_project_id, s_rpc_url, and TAG.
Referenced by eth_rpc_ecrecover_parity(), eth_rpc_get_nonce(), and eth_rpc_send_raw_tx().
| uint8_t eth_rpc_ecrecover_parity | ( | const uint8_t | hash[32], |
| const uint8_t | r[32], | ||
| const uint8_t | s[32] ) |
Definition at line 257 of file eth_rpc.cpp.
References bytes_to_hex(), do_post(), hex_nibble(), HEX_PER_BYTE, RESP_BUF_SIZE, s_from_addr, and TAG.
Referenced by signing_loop().
| bool eth_rpc_get_nonce | ( | uint64_t * | nonce_out | ) |
Definition at line 231 of file eth_rpc.cpp.
References do_post(), RESP_BUF_SIZE, s_from_addr, and TAG.
Referenced by signing_loop().
| void eth_rpc_init | ( | const char * | rpc_url, |
| const char * | from_addr ) |
Definition at line 169 of file eth_rpc.cpp.
References s_from_addr, and s_rpc_url.
Referenced by app_main().
| bool eth_rpc_send_raw_tx | ( | const uint8_t * | tx, |
| size_t | tx_len, | ||
| char * | tx_hash_out, | ||
| size_t | tx_hash_max ) |
Definition at line 332 of file eth_rpc.cpp.
References bytes_to_hex(), do_post(), HEX_PER_BYTE, RESP_BUF_SIZE, and TAG.
Referenced by signing_loop().
| void eth_rpc_set_auth | ( | const char * | project_id, |
| const char * | api_secret ) |
Definition at line 175 of file eth_rpc.cpp.
References s_api_secret, and s_project_id.
Referenced by app_main().
| bool eth_rpc_wifi_connect | ( | const char * | ssid, |
| const char * | password ) |
Definition at line 181 of file eth_rpc.cpp.
References s_retry_num, s_wifi_event_group, TAG, WIFI_CONNECTED_BIT, wifi_event_handler(), WIFI_FAIL_BIT, and WIFI_TIMEOUT_MS.
Referenced by app_main().
|
static |
Definition at line 151 of file eth_rpc.cpp.
Referenced by bytes_to_hex(), and eth_rpc_ecrecover_parity().
|
static |
Definition at line 52 of file eth_rpc.cpp.
References s_retry_num, s_wifi_event_group, TAG, WIFI_CONNECTED_BIT, WIFI_FAIL_BIT, and WIFI_MAX_RETRY.
|
static |
Definition at line 43 of file eth_rpc.cpp.
Referenced by do_post(), and eth_rpc_set_auth().
|
static |
Definition at line 41 of file eth_rpc.cpp.
Referenced by eth_rpc_ecrecover_parity(), eth_rpc_get_nonce(), and eth_rpc_init().
|
static |
Definition at line 42 of file eth_rpc.cpp.
Referenced by do_post(), and eth_rpc_set_auth().
|
static |
Definition at line 46 of file eth_rpc.cpp.
|
static |
Definition at line 40 of file eth_rpc.cpp.
Referenced by do_post(), and eth_rpc_init().
|
static |
Definition at line 45 of file eth_rpc.cpp.
|
static |
Definition at line 23 of file eth_rpc.cpp.