Conflicting <Hash.h> issue

Hi guys.

I am trying to compile WebSockets library and Crypto library together with the websocket example code () and I am getting an error like this

.pio\libdeps\d1_mini\WebSockets_ID549\src\WebSockets.cpp:536:77: error: ‘sha1’ was not declared in this scope

If i remove Crypto library, it can compile fine. Does anyone know how to fix this? please advice

platformio.ini

[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino

lib_deps =
# Using library Id
WebSockets
Crypto

code

#include <Arduino.h>
#include <Hash.h>
#include <Crypto.h>
#include <Curve25519.h>
#include <string.h>
#include <base64.hpp>
#include <assert.h>
#include <Ed25519.h>
#include <SHA256.h>
#include <RNG.h>
#include <AES.h>
#include <CTR.h>

#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <WebSocketsClient.h>
 
ESP8266WiFiMulti WiFiMulti;
WebSocketsClient webSocket;
 
void webSocketEvent(WStype_t type, uint8_t * payload, size_t length) {

	switch(type) {
		case WStype_DISCONNECTED:
			Serial.printf("[WSc] Disconnected!\n");
			break;
		case WStype_CONNECTED: {
			Serial.printf("[WSc] Connected to url: %s\n", payload);

			// send message to server when Connected
			webSocket.sendTXT("Connected");
		}
			break;
		case WStype_TEXT:
			Serial.printf("[WSc] get text: %s\n", payload);

			// send message to server
			// webSocket.sendTXT("message here");
			break;
		case WStype_BIN:
			Serial.printf("[WSc] get binary length: %u\n", length);
			hexdump(payload, length);

			// send data to server
			// webSocket.sendBIN(payload, length);
			break;
        case WStype_PING:
            // pong will be send automatically
            Serial.printf("[WSc] get ping\n");
            break;
        case WStype_PONG:
            // answer to a ping we send
            Serial.printf("[WSc] get pong\n");
            break;
    }

}

void setup() {
  Serial.begin(9600);
  Serial.println("\n\n\nFile: " __FILE__ " Compiled " __DATE__ " " __TIME__ "\n\n");

	//Serial.setDebugOutput(true);
	Serial.setDebugOutput(true);

	Serial.println();
	Serial.println();
	Serial.println();

	for(uint8_t t = 4; t > 0; t--) {
		Serial.printf("[SETUP] BOOT WAIT %d...\n", t);
		Serial.flush();
		delay(1000);
	}

	WiFiMulti.addAP("SSID", "passpasspass");

	//WiFi.disconnect();
	while(WiFiMulti.run() != WL_CONNECTED) {
		delay(100);
	}

	// server address, port and URL
	webSocket.begin("192.168.0.123", 81, "/");

	// event handler
	webSocket.onEvent(webSocketEvent);

	// try ever 5000 again if connection has failed
	webSocket.setReconnectInterval(5000);
  
  // start heartbeat (optional)
  // ping server every 15000 ms
  // expect pong from server within 3000 ms
  // consider connection disconnected if pong is not received 2 times
  webSocket.enableHeartbeat(15000, 3000, 2);

}

void loop() {
	webSocket.loop();
}

Classic name conflict. You should make a fork of the Crypto library and rename its references to Hash.h and the file itself. I wouldn’t know of any other magic fix for this.

1 Like