'base64_encode' was not declared in this scope
Urs-Eppenberger opened this issue · 14 comments
First: many thanks for your base64 library. I need this together with AES encryption to secure the communication between my ESP8266 based sensor nodes and a node-red/MQTT home automation central.
Second: The error is most probably not in your code, but sitting in front of my laptop
I have a very small program which I can't get to compile:
#include <base64.h>
void setup() {
}
void loop() {
char b64data[200];
int b64len = base64_encode(b64data, "1234567890123456", 16);
}
The error reported by the Arduino IDE 1.6.10 is : 'base64_encode' was not declared in this scope
I'm not a newby with adding libraries. I've done this successfully for AES, md5 and other stuff.
I can't figure out what goes wrong here. What did I miss?
Hi, I didn't test the lib with the Arduino IDE only with the Sming framework and Netbeans.
But let me check, and I'll get back to you.
Ok, are you using the Arduino Framework for the ESP8266?
If yes, then I have the same error, because the framework has a base64.h header file that has no declaration for the base64_encode function.
Can you put this library files ( base64.h and base64.cpp) on the same directory as your main file and change the #include <base64.h> to #include "base64.h" ?
It should work.
Yes, I am using the Arduino IDE Framework for my coding.
Your hint is the solution!
I can either use the full path to your base64.h file using the notation with greater and small signs, or put the file in the same directory as the .ino program with the double quote notation.
Your support is outstandingly quick and solved the problem, many thanks.
Ok, are you using the Arduino Framework for the ESP8266?
If yes, then I have the same error, because the framework has a base64.h header file that has no declaration for the base64_encode function.
Can you put this library files ( base64.h and base64.cpp) on the same directory as your main file and change the #include <base64.h> to #include "base64.h" ?
It should work.
Pls, how can I achieve this I'm having same issue with my code
@fcgdam, appreciate your help! this worked for me too in Arduino SDK 1.8.9
I'm using Arduino pro mini, and I'm getting base64_encoder error after compiling my code
Pls anyone who can help to solve this error code as below?
C:\Users\user\Documents\Arduino\libraries\WaziDev\src\WaziDev.cpp:188:18: error: 'base64_enc_len' was not declared in this scope
int encLen = base64_enc_len(len);
^~~~~~~~~~~~~~
C:\Users\user\Documents\Arduino\libraries\WaziDev\src\WaziDev.cpp:190:5: error: 'base64_encode' was not declared in this scope
base64_encode(h, buf, len);
^~~~~~~~~~~~~
Without seeing your code we can only guess here. And writing guesses is not really productive.
Please post to code you have written.
How exactly did you include the base64.h library in your code?
I remember that I had problems with this too. I fixed it by putting the base54.h and base64.cpp files in the same folder as my code, then it worked.
Without seeing your code we can only guess here. And writing guesses is not really productive. Please post to code you have written. How exactly did you include the base64.h library in your code?
I remember that I had problems with this too. I fixed it by putting the base54.h and base64.cpp files in the same folder as my code, then it worked.
Thanks for the response, I'll post the code soon
'
This is the code as below:
#include <WaziDev.h>
#include <xlpp.h>
#include <Base64.h>
// NwkSKey (Network Session Key) and Appkey (AppKey) are used for securing LoRaWAN transmissions.
// You need to copy them from/to your LoRaWAN server or gateway.
// You need to configure also the devAddr. DevAddr need to be different for each devices!!
// Copy'n'paste the DevAddr (Device Address): 26011D00
unsigned char devAddr[4] = {0x26, 0x01, 0x1D, 0x00};
// Copy'n'paste the key to your Wazigate: 23158D3BBC31E6AF670D195B5AED5525
unsigned char appSkey[16] = {0x23, 0x15, 0x8D, 0x3B, 0xBC, 0x31, 0xE6, 0xAF, 0x67, 0x0D, 0x19, 0x5B, 0x5A, 0xED, 0x55, 0x25};
// Copy'n'paste the key to your Wazigate: 23158D3BBC31E6AF670D195B5AED5525
unsigned char nwkSkey[16] = {0x23, 0x15, 0x8D, 0x3B, 0xBC, 0x31, 0xE6, 0xAF, 0x67, 0x0D, 0x19, 0x5B, 0x5A, 0xED, 0x55, 0x25};
WaziDev wazidev;
void setup()
{
Serial.begin(38400);
wazidev.setupLoRaWAN(devAddr, appSkey, nwkSkey);
}
XLPP xlpp(120);
void loop(void)
{
// 1
// Create xlpp payload.
xlpp.reset();
xlpp.addTemperature(1, 45.7); // °C
// 2.
// Send paload with LoRaWAN.
serialPrintf("LoRaWAN send ... ");
uint8_t e = wazidev.sendLoRaWAN(xlpp.buf, xlpp.len);
if (e != 0)
{
serialPrintf("Err %d\n", e);
delay(60000);
return;
}
serialPrintf("OK\n");
// 3.
// Receive LoRaWAN message (waiting for 6 seconds only).
serialPrintf("LoRa receive ... ");
uint8_t offs = 0;
long startSend = millis();
e = wazidev.receiveLoRaWAN(xlpp.buf, &xlpp.offset, &xlpp.len, 6000);
long endSend = millis();
if (e != 0)
{
if (e == ERR_LORA_TIMEOUT){
serialPrintf("nothing received\n");
}
else
{
serialPrintf("Err %d\n", e);
}
delay(60000);
return;
}
serialPrintf("OK\n");
serialPrintf("Time On Air: %d ms\n", endSend-startSend);
serialPrintf("LoRa SNR: %d\n", wazidev.loRaSNR);
serialPrintf("LoRa RSSI: %d\n", wazidev.loRaRSSI);
serialPrintf("LoRaWAN frame size: %d\n", xlpp.offset+xlpp.len);
serialPrintf("LoRaWAN payload len: %d\n", xlpp.len);
serialPrintf("Payload: ");
char payload[100];
base64_decode(payload, xlpp.getBuffer(), xlpp.len);
serialPrintf(payload);
serialPrintf("\n");
delay(60000);
}
Ok, are you using the Arduino Framework for the ESP8266?
If yes, then I have the same error, because the framework has a base64.h header file that has no declaration for the base64_encode function.
Can you put this library files ( base64.h and base64.cpp) on the same directory as your main file and change the #include <base64.h> to #include "base64.h" ?
It should work.
thanks for aswer bro ! it worked for me.
no file base64.cpp inside library folder
Please do not respond to a closed ticket.
To avoid conflicts with files from the arduino framework, the file name was changed to base64_utils.h as it can be seen on the repository.