Pre-Requisites
- You have followed the instructions here.
- You are comfortable using the Arduino IDE and making changes to the Sketch.
Fingerprint Check
In the comments on the post You Went to Oracle Open World 19 and got a Code Card, now what? we talked about how to update the fingerprint of the security certificate for the REST API when it changes.
I’m not a big fan of doing things multiple times and since I’m not planning on doing anything of a sensitive nature with my CodeCard I decided I would just disable the fingerprint check altogether.
How to tell if the fingerprint check is causing your badge to stop working.
If you push one of the buttons and it hangs on the “Please wait…” screen forever, check the Serial Monitor for a message similar to this.
1 2 3 4 5 6 7 8 9 10 |
>>> Request: host: apex.oracle.com port: 443 url: https://apex.oracle.com/pls/apex/appslab/functions/master fingerprint: 8B 8A B0 33 DE B9 77 A7 4D D1 7D 48 EB DD FF 15 4D 51 E0 A6 method: GET Connection insecure! Halting execution. >>> Shuting down... |
Warning, If you’re planning to use your CodeCard for anything you’d consider sensitive, do not make this change!
Upgrade the driver
- Clone or download the CodeCard repository
- In the Arduino IDE, open the file codecard/arduino/codecard/codecard.ino
- Open the Board Manager. Tools/Board/Boards Manager
- Search for esp
- Select version 2.5.2
- Click Install
- Close the Boards Manager
Code Changes
- Click on the httpClient.h tab
- Replace line 74 with
BearSSL::WiFiClientSecure client;
73747576String secureRequest(String host, int port, String url, String btnLabel, int btnFunction) {BearSSL::WiFiClientSecure client;String methodKey = "method" + btnLabel + String(btnFunction);
- On line 102 add
client.setInsecure();
100101102103104105}client.setInsecure();client.setTimeout(10000);if (!client.connect(host, port)) {
- Comment out the fingerprint check starting on line 112
112113114115116// if (!client.verify(fingerprint.c_str(), host.c_str())) {// Serial.println(F(" Connection insecure! Halting execution."));// Serial.println(F(">>>"));// return "";// }
- Uncomment line 152 and remove line 153
149150151152153154void httpsImage(String host, int port, String url, int16_t x, int16_t y, String fingerprint, bool with_color) {// WiFiClientSecure secureClient;BearSSL::WiFiClientSecure secureClient;bool connection_ok = false;
- On line 176 add
secureClient.setInsecure();
174175176177178179//secureClient.setFingerprint(fp);secureClient.setInsecure();secureClient.setTimeout(10000);if (!secureClient.connect(host, port)) {
- Comment out the fingerprint check starting on line 185
185186187188189// if (!secureClient.verify(fingerprint.c_str(), host.c_str())) {// Serial.println(F(" Connection insecure! Halting execution."));// Serial.println(F(">>>"));// return;// }
Increase arrayToStore variable size
If you’re planning to change the REST calls to use a different and longer URI you will want to increase the size of the arrayToStore variables. Currently they are set to 100, I changed mine to 200, but you can use whatever you’d like.
- Click on the memory.h tab
- On lines 18 and 46, change the arrayToStore variable to the new size
171819String getFromMemory(int addr) {char arrayToStore[200];if (EEPROM.read(addr*maxValue) == 255){454647void saveToMemory(int addr, String val) {char arrayToStore[200];val.toCharArray(arrayToStore, val.length()+1) ; - Click on the wifi.h tab
- On line 7, change the arrayToStore variable to the new size
678bool wifiConnect() {char arrayToStore[200];String ssid = EEPROM.get(0*maxValue, arrayToStore);
Troubleshooting
Sketch uses too much program storage space
I have seen this error off and on when I compile the sketch. If you get this error, the easiest way to reduce the size of the sketch is to remove some of the larger icons in icons.h.
- Click on icons.h
- Find a 128x128px image that you don’t plan to use and either comment it or remove it.
- Click on templates.h
- Find the drawIcon128(int x, int y, String icon, long color) method and comment or remove the reference to the image you removed.
- You may have to remove more than one image.
“Connection failed” or you receive an empty response “{}”
This one can be tricky. The way I’ve solved this is to erase the ESP8266 flash memory.
Usually this works:
- Connect with the Serial Monitor
- Press and release the A and B buttons
- Wait for the Serial Monitor to display all of the data
- Enter “reset” and send
- Enter “ls” and update any settings as needed
If that doesn’t work you may need to search for another way to reset the memory. Please leave a comment if you have a better way.