Skip to content

Commit

Permalink
Merge pull request #6 from yamukha/main
Browse files Browse the repository at this point in the history
tuned for ESP32 platform
  • Loading branch information
akru authored Mar 3, 2024
2 parents 3ea2876 + 04c609b commit b00d4c6
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ There are in .github/workflows/ files:\
esp-extrinsics.yml -> act -j esp8622 -> to build by arduino-cli binary for target device and run library unit tests

# Deploy
1. Set up in Private.h file proper values of keys and addresses for subscription owner and device.\
1. Set up in Private.h file proper values of keys (Note: ED25519 scheme!) and addresses for subscription owner and device.\
Note: to explore/create existing key/address can be used sub.py script from this repository or subkey utility from substrate\
i.e. to get keys for known account mnemonic phrase:\
subkey inspect "some ... mnemonics" --network robonomics --scheme ed25519\
Expand All @@ -29,4 +29,4 @@ After ESP8266 reset you have 3 seconds window to send URL as string, i.e.: http
- 3rd byte: 1st character of URL

# Submit of extrinsic be checked in polkadot web UI -> Network -> Explorer
https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fkusama.rpc.robonomics.network%2F#/explorer
https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fkusama.rpc.robonomics.network%2F#/explorer
3 changes: 2 additions & 1 deletion libraries/Crypto/src/AES.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

// Determine which AES implementation to export to applications.
#if defined(ESP32)
#define CRYPTO_AES_ESP32 1
// fix to allow build for ESP32
// #define CRYPTO_AES_ESP32 1
#else
#define CRYPTO_AES_DEFAULT 1
#endif
Expand Down
9 changes: 8 additions & 1 deletion libraries/RpcRobonomics/Defines.h
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#pragma once

#define USE_ARDUINO

#ifdef USE_ARDUINO
// ESP32 or ES8266 in other case
// #define ESP32_MODEL
#endif

#define KEYS_SIZE 32
#define SIGNATURE_SIZE 64
#define URLRPC "http://kusama.rpc.robonomics.network/rpc/"
//#define URLRPC "http://192.168.0.100:9933"
//#define DEBUG_PRINT
//#define DEBUG_PRINT
13 changes: 9 additions & 4 deletions libraries/RpcRobonomics/RpcRobonomics.h
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
#pragma once

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

#include <Defines.h>
#include <Extrinsic.h>
#include <Call.h>
#include <JsonUtils.h>
#include <Defines.h>

#ifdef ESP32_MODEL
#include <WiFi.h>
#include <HTTPClient.h>
#else
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#endif

typedef struct {
std::string body; // responce body
Expand Down
4 changes: 4 additions & 0 deletions libraries/RpcRobonomics/esp32.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
7c7
< // #define ESP32_MODEL
---
> #define ESP32_MODEL
14 changes: 10 additions & 4 deletions rpcjsonc/rpcjsonc.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@
#include <string>

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <EEPROM.h>

#include <Defines.h>
#include <RpcRobonomics.h>

#ifdef ESP32_MODEL
#include <WiFi.h>
#include <HTTPClient.h>
#else
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#endif

// WiFi credentials and private keys are hidden in Private.h file
// pub keys are derived on ctor of RobonomicsRpc
// need to have derived or generated PUB_OWNER_KEY, SS58_ADR, SS58_DEVICE_ADR
Expand Down Expand Up @@ -147,7 +153,7 @@ void loop () {
#else
Serial.println("RPC RWS task run");
RobonomicsRpc rpcProvider(client, robonomics_url, PRIV_DEVICE_KEY, SS58_DEVICE_ADR, id_counter);
RpcResult r = rpcProvider.RwsDatalogRecord(PUB_OWNER_KEY, std::to_string(id_counter));
RpcResult r = rpcProvider.RwsDatalogRecord(PUB_OWNER_KEY, PUB_OWNER_KEY);
#endif
coins_count += 10000;
id_counter = id_counter + 2;
Expand Down

0 comments on commit b00d4c6

Please sign in to comment.