-
I think I narrowed down the errors I explained in the top two threads. I Think the rand() error is probably due to a conflict in naming functions? I'm assuming the espruino has a function called rand() and the Crypto library has a rand() function?
The undefined reference error in my second post is probably due to not including a header file listing the methods.
I'm not much of a programmer so I'm not really sure where to go from here to fix those issue.
-
jswrap_crypto_cbc.c:
[#include](https://forum.espruino.com/search/?q=%23include) <stdio.h> [#include](https://forum.espruino.com/search/?q=%23include) "crypto.h" //#include "jsinteractive.h" /*JSON{ "type" : "class", "class" : "Crypto" }*/ /*JSON{ "type" : "staticmethod", "class" : "Crypto", "name" : "cbc", "generate" : "jswrap_crypto_cbc" }*/ void jswrap_crypto_cbc() { uint8_t key[CRL_AES128_KEY]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; uint8_t iv[CRL_AES_BLOCK]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; uint8_t plaintext[1024]={'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}; uint8_t ciphertext[1024]; int i = 0; // outSize is for output size, retval is for return value int32_t outSize, retval; AESCBCctx_stt AESctx_st; // The AES context // Initialize Context Flag with default value AESctx_st.mFlags = E_SK_DEFAULT; // Set Iv size to 16 AESctx_st.mIvSize=16; // Set key size to 16 AESctx_st.mKeySize=CRL_AES128_KEY; // call init function retval = AES_CBC_Encrypt_Init(&AESctx_st, key, iv); if (retval != AES_SUCCESS) { /*jsiConsolePrint("AES Encrypt Init FAILD!\r\n");*/ } // Loop to perform four calls to AES_CBC_Encrypt_Append, each processing 256 bytes for (i = 0; i < 1024; i += 256) { //Encrypt i bytes of plaintext. Put the output data in ciphertext and number //of written bytes in outSize retval = AES_CBC_Encrypt_Append(&AESctx_st, plaintext, 256, ciphertext, &outSize); if (retval != AES_SUCCESS) { /*jsiConsolePrint("AES Encrypt Append FAILD!\r\n");*/ } } //Do the finalization call (in CBC it will not return any output) retval = AES_CBC_Encrypt_Finish(&AESctx_st, ciphertext+outSize, &outSize ); if (retval != AES_SUCCESS) { /*jsiConsolePrint("AES Encrypt Finish FAILD!\r\n");*/ } }
jswrap_crypto_cbc.h:
void jswrap_crypto_cbc();
I commented out #include "jsinteractive.h" and all the jsiConsolePrint and attempted to compile again and received this error:D espruino_1v80_pico_1r3.elf /tmp/cc6qhSAv.ltrans15.ltrans.o: In function `jswrap_crypto_cbc': <artificial>:(.text.jswrap_crypto_cbc+0xea): undefined reference to `AES_CBC_Encrypt_Init' <artificial>:(.text.jswrap_crypto_cbc+0x100): undefined reference to `AES_CBC_Encrypt_Append' <artificial>:(.text.jswrap_crypto_cbc+0x114): undefined reference to `AES_CBC_Encrypt_Finish' collect2: error: ld returned 1 exit status make: *** [espruino_1v80_pico_1r3.elf] Error 1 Build failed
-
I am using a stripped down version of the STM32 Cryptographic library package.
I am attempting to custom compile the pico firmware to include a very basic aes cbc cipher library. I will eventually include more, however, right now I am just trying to get the hang of custom compiling the firmware.
The error I am receiving is:
In file included from /home/espruino/Espruino/src/jsvar.h:17:0,
from /home/espruino/Espruino/src/jsparse.h:17, from /home/espruino/Espruino/src/jsinteractive.h:17, from libs/crypto/jswrap_crypto_cbc.c:3: /home/espruino/Espruino/src/jsutils.h:436:14: error: conflicting types
for 'rand' unsigned int rand();
make: *** [libs/crypto/jswrap_crypto_cbc.o] Error 1 Build failed
I executed
./create_pico_image_1v3.sh
to compile.
I have a feeling there are more errors, but the complete output status of the compiling has been chopped off in the terminal. Is there a log file where I can view the complete compiling log?crypto.tar.gz is the stripped down version and the original library can be found at: http://www.st.com/web/en/catalog/tools/PF259409
-
@Gordon thanks for the explanation :)
-
-
-
-
I executed: scripts/create_espruino_image_1v3.sh and I was able to successfully compile :-)
I read in: https://github.com/espruino/Espruino#building-for-stm32-boards-incl-espruino-board that the user can remove features such as graphics. Are there any other features that I can remove to further shrink the binary down? I plan to attempt to custom compile a binary with AES encryption features (no promises that I will succeed).
UPDATE
I realize that I should of executed create_pico_image_1v3.sh instead of espruino 00ps... -
I'm following this guide with a minor change: https://github.com/espruino/Espruino#building-under-windowsmacos-with-a-vm
I am using the 64 bit version instead of the 32 bit version
Error:
GEN espruino_1v80_espruino_1r3.lst GEN espruino_1v80_espruino_1r3.bin
bash scripts/check_size.sh espruino_1v80_espruino_1r3.bin FAIL - size
of 238620 is over 215040 bytes make: ***
[espruino_1v80_espruino_1r3.bin] Error 1 make: *** Waiting for
unfinished jobs.... -
As @allObjects says, I wonder whether sometimes it might actually be
cheaper/easier to use a cheap phone/tablet as the user interface - and
then you can use normal HTML/CSS/JS for the user interface.It seems like that is the better/fastest/intuitive choice.
-
I stumbled across a touch LCD on indiegogo that sorta resembles the touch screens from 4d systems: https://www.indiegogo.com/projects/nextion-a-cost-effective-high-performance-tft-hmi
looks pretty cool and only has a few more days left. Might be of use to people here. I think @allObjects was working on a touch screen project using an Espruino for the "brain" but the post has been buried and I can't seem to find the post....
-
Also, here is an informative post about AES encryption: http://stackoverflow.com/questions/1220751/how-to-choose-an-aes-encryption-mode-cbc-ecb-ctr-ocb-cfb
-
@the1laz
People should be taught to use encryption because IMHO, it's more secure than transmitting clear over the air. Someone could argue that sending trivial data such as temp and water level over the air shouldnt need encryption. But, what if you want to turn something on and off such as a light or pump by sending a command over the air?Encryption can be confusing and combursome for someone to implement or at least for me when I started reading about it. I think Encryption needs to be easy to use in order for more people to use it. Like handling keys and etc... automatically in the background.
Maybe if more people requested encryption support for the espruino, someone could donate their time to add encryption?
I currently offload encryption to the Intel Edison which also handles the network side. The only issue I have is how long the Edison takes to bootup. I like the instantaneous bootup and code execution feel that microcontrollers have. So, ya having encryption would be a major plus for the espruino :)
-
@Gordon With encryption, I think custom compiling an encryption library into the firmware like the one I mentioned in the "shiny ui" thread should run faster than using javascript. I've tried using other Aes javascript libraries in the past found them to be too memory intensive and I kept getting the out of memory error in the console.
With the amount of ram the Pico has, I'm pretty sure AES128 cbc and then sign the encrypted string using sha(which is already implemented) should work if custom compiled into the espruino firmware. However, I'm no expert. -
@Gordon sounds like a fantastic plan! In regards to TLS/SSL, that is also an awesome idea to incorporate into the pico. A few days ago I stumbled across the stm32-cryp-lib found at: http://www.st.com/web/en/catalog/tools/PF259409 However, I'm not sure if that library supports TLS/SSL. I've been wanting to try and custom compile my own Espruino firmware to use AES encryption, but creating a custom linux environment to compile the Espruino firmware is out of my scope of know how. Also even if I successfully created the environment I still wouldn't be able to incorporate the lib because my programming know how is also limited.
-
@Gordon The term suite is probably a poor choice of a word on my part. I was referring possibly broadening the example/tutorial page with other Interactive UI examples. Such as what people might want to use to show values of the popular sensors such as show the room temp on a Thermometer UI. By no means did I mean create a full fledged UI toolkit...
-
@Gordon Is your focus point for these "widgets" to load from an espruino? I think it would be a neat idea to create a widget suite : radial guage, temp guage, tank guage and ect.... small enough so an Espruino can serve the website. Although I'm not too sure if one espruino will be powerful enough run sensor code and widget code. So since the picos are small enough, the user can use two picos. Having one pico dedicated to serving the web page and the other Pico handle the sensor data.
I'm all for the idea to test what the Espruino's are capable of. Also, I like the simplistic approach of not having to sign up for an account on the other websites that offer IoT services.
-
-
Well, using 3.3 seems to be steady. My water temp, as it is much cooler now, is staying at a 95 - 96F range.
I
console.log(E.getAnalogVRef());
and the value fluctuates. Now I understand why I was getting those fluctuations as I mentioned earlier. I though getAnalogVRef() was a constant 3.3v, OOOOPS. -
As you're not expecting that to change much, you could just keep some
kind of running average of it:Right, I will expect the temperature of my aquaponics fish tank to be: 72-74 degrees F.
What I am afraid of is, turning the water heater on or off when its not supposed to due to the fluctuations and then in-turn causing the heater to break :-/
I'm getting values between 104F - 110F(Hot water demo)
The values that I am getting(using hot water as a demo):
Temp in F: 105.52142546252
Temp in C: 41.34653038471Temp in F: 106.42375469248
Temp in C: 41.30234757616
Temp in F: 106.34422563710Temp in C: 41.51487649546
Temp in F: 106.72677769184Temp in C: 41.55840707979
Temp in F: 106.80513274363Temp in C: 41.22329070578
Temp in F: 106.20192327040Temp in C: 40.82283922169
Temp in F: 105.48111059904Temp in C: 42.56068147354
Temp in F: 108.60922665237Temp in C: 41.90883827124
Temp in F: 107.43590888824Temp in C: 42.11013715285
Temp in F: 107.79824687513Temp in C: 41.61748517983
Temp in F: 106.91147332370Temp in C: 41.74432203951
Temp in F: 107.13977967112Temp in C: 41.35120766480
Temp in F: 106.43217379665Temp in C: 41.92938665155
Temp in F: 107.47289597280Temp in C: 41.80511869209
Temp in F: 107.24921364577Temp in C: 41.53246010569
Temp in F: 106.75842819024Temp in C: 43.58086790083
Temp in F: 110.44556222151Temp in C: 41.64385517750
Temp in F: 106.95893931950Temp in C: 41.74612988558
Temp in F: 107.14303379405Temp in C: 41.99619187463
Temp in F: 107.59314537434Temp in C: 41.66354537383
Temp in F: 106.99438167290Temp in C: 40.64783023314
Temp in F: 105.16609441966Temp in C: 41.62779064556
Temp in F: 106.93002316202Temp in C: 41.50174732836
Temp in F: 106.70314519106Temp in C: 40.55533498825
Temp in F: 104.99960297885Temp in C: 41.71990880225
Temp in F: 107.09583584405Temp in C: 43.50436386718
Temp in F: 110.30785496093Temp in C: 41.60630366626
Temp in F: 106.89134659928Temp in C: 41.74936786270
Temp in F: 107.14886215287Temp in C: 41.39160510339
Temp in F: 106.50488918610 -
-
-
-
I believe I have done everything I can in software to minimize the temp fluctuations. Does anyone have any ideas obout how to minimize analog noise? I did search Google and multiple people recommended to pull all the unused analog pins to gnd. Also people recommended to use a 0.1 bypass cap. However Im not sure where to place the cap..? Does anyone have recommondations?
Code:
var w = new Waveform(128/* your buffer size */,{doubleBuffer:false, bits:16}); var first = true; setInterval(function() { if (!first) { var myarr = w.buffer; myarr.sort(); // cut off first and last 2 elements var view = new Uint16Array(myarr.buffer, 2/*sizeof(uint16)*/*2, myarr.length-4); var vOut = E.getAnalogVRef() * E.sum(view)/(view.length*65536); // if you attached VOUT to Ao var vZero = 0.4; var tCoeff = 19.5 / 1000; var tempinc = (vOut - vZero) / tCoeff; var tempinf = tempinc * (9 / 5) + 32; console.log("Temp in C: " + tempinc); console.log("Temp in F: " + tempinf); //console.log(E.sum(view)/(view.length*65536)); } else first = false; // start it again w.startInput(A0,2000 /* Samples per second */); }, 200);
Let's say, for example, I have the following code:
And I want to output that array using:
'''jsiConsolePrint();'''
Does jsIConsolePrint() only allow a string input? Do I need to for each through the array then store each segment of the array to a string?
The reason why I ask is. I tried to use a for each to loop through the array and output each segment of the array to the WebIDE and I expected to see the ascii representation of the hex value. However, I received what looked like all %.
The ascii representation should be:
kÁ¾â.@é=~s®-W¬·o¬E¯Q0ÈF£\äåûÁ
Rïö$EßO+A{æl7
I even tried placing the hex representation of the alphabet into the array; however, I still received all % as the output.
Eventually, my real world code will receive an encrypted JSON string and I would like to output the unencrypted JSON string to the WebIDE console. I have AES128-CBC encryption and decryption working (so I think, I don't want to jinx myself). I'm just having trouble outputting the text to the console.