ExploreEmbedded / Hornbill-Examples

89 stars 171 forks source link

putting certificates in seperate file in arduino IDE #9

Closed shirish47 closed 6 years ago

shirish47 commented 6 years ago

Hi so I want to use this library but I want to store cert in a seperate AWS_cert.h file that I can add in code in Arduino IDE. and so I don't need to go to library folder and edit it every time I want to add another cert.

Can you suggest some way? though I tried it to comment aws_iot_cert.c in AWS_IOT.cpp and add aws_cert.h with code of aws_iot_cert.c but during compilation I get error

var/folders/w2/jb9h2v3j5s5bs70q009xq2x00000gn/T/arduino_build_683901/libraries/AWS_IOT/AWS_IOT.cpp.o:(.literal._ZN7AWS_IOT7connectEPcS0_+0x10): undefined reference to `aws_root_ca_pem'
/var/folders/w2/jb9h2v3j5s5bs70q009xq2x00000gn/T/arduino_build_683901/libraries/AWS_IOT/AWS_IOT.cpp.o:(.literal._ZN7AWS_IOT7connectEPcS0_+0x14): undefined reference to `certificate_pem_crt'
Multiple libraries were found for "WiFi.h"
/var/folders/w2/jb9h2v3j5s5bs70q009xq2x00000gn/T/arduino_build_683901/libraries/AWS_IOT/AWS_IOT.cpp.o:(.literal._ZN7AWS_IOT7connectEPcS0_+0x18): undefined reference to `private_pem_key'
 Used: /Users/shirishbytelens/Documents/Arduino/hardware/espressif/esp32/libraries/WiFi
collect2: error: ld returned 1 exit status
 Not used: /private/var/folders/w2/jb9h2v3j5s5bs70q009xq2x00000gn/T/AppTranslocation/52665A05-AAB2-4BD4-96BE-401CDCEB2D12/d/Arduino 2.app/Contents/Java/libraries/WiFi
Using library AWS_IOT at version 1.0 in folder: /Users/shirishbytelens/Documents/Arduino/libraries/AWS_IOT 
Using library WiFi at version 1.0 in folder: /Users/shirishbytelens/Documents/Arduino/hardware/espressif/esp32/libraries/WiFi 
exit status 1
Error compiling for board ESP32 Dev Module.

so its not linking to the library.

shirish47 commented 6 years ago

Ok I did it. I defined #include "AWS_cert.h" and put extern const char aws_root_ca_pem[] and other two with the certificate data and it worked for me.