-
Digging into the docs I found I can change the Peer Manager config io_caps to BLE_GAP_IO_CAPS_KEYBOARD_ONLY and I get a pin to display on the camera when binding.
Then when binding I'm receiving a BLE_GAP_EVT_AUTH_KEY_REQUEST and replying with sd_ble_gap_auth_key_reply to supply the passkey, but so far no love.
This API is new to me so I'll keep digging.
-
-
-
I'm using an official Espruino MDBT42Q breakout board to try to connect to a BLE enabled video camera. When pairing with a phone a pin is displayed on the screen to bond with the camera.
When I try to connect from the Espruino (running 2v00.120) I get disconnect with code 19 (0x13 BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION) when I execute gatt.startBonding().
I completely understand if this just is not implemented. Just wanted to check if I was missing something.
-
Great! I was assuming the jsvUnlock method is similar to Objective-C retain/release mechanism so I wanted to make sure all the espruino js methods were being used correctly.
Glad you mentioned the buffer thing, that was my next move. Setup a test and it seems to be working really well. I didn't realize the idle method was a good place to do some processing, I was thinking it was to allow sleep or something along those lines. Good to know!
Now I can do some cleanup and more testing. Looking forward to picking up some official hardware like the Puck so that I can get it working on there also.
Thanks for your help and awesome product Gordon!
-
I hope this it the correct place to post this..
I'm trying to create a CAN Bus lib and I'm running Espruino on a Nucleo STM32F4 board. I'm not great with C but I can usually make my way around, but I've been just looking at other libs to try to figure this out.
I'm running out of memory (I think) and the runtime crashes. I wrote a nodejs app to blast data (a frame every 2ms) to the Nucleo. When I use jsiConsolePrintf to dump the CAN frame out to the console it works without issue, so this tells me the Interrupt code is fine. But I want to dispatch an event into the JS runtime so that the frame data can be used there. When I do this the chip crashes after just a few minutes.
Here is how I am dispatching the event:
/** * @brief Read CAN FIFO and dispatch JS event with the CAN Message data * @param None * @retval None */ void CANx_ReadAndDispatch(CAN_TypeDef *CANx, uint8_t FIFONumber){ CanRxMsg RxMessage; CAN_Receive(CANx, FIFONumber, &RxMessage); // Dispatch event JsVar *messageObj = messageObjectFromRxStruct(&RxMessage); if(messageObj){ jsiQueueObjectCallbacks(jsVarCan1, JS_EVENT_PREFIX"message", &messageObj, 1); jsvUnLock(messageObj); } } /* * Build a JS Object from the CAN RX data */ JsVar *messageObjectFromRxStruct(CanRxMsg *rx){ uint32_t *id; // uint8_t size = rx->DLC+2; uint8_t size = 11; char dest[size]; if(rx->IDE == CAN_ID_EXT) id = &rx->ExtId; else id = &rx->StdId; // memset(dest, '\0', size); dest[0] = (*id >> 8); dest[1] = (*id); dest[10] = rx->DLC; strncpy(dest+2, rx->Data, 8); // Mem check if (jsuGetFreeStack() < 88) { jsExceptionHere(JSET_ERROR, "CAN:: Not enough free stack to receive this mesage. stackfree:%d", jsuGetFreeStack()); return 0; } JsVar *buffer = jsvNewArrayBufferWithData(11, dest); return buffer; }
-
-
-
-
-
-
I managed to get it going! Another stm32 newbie mistake, but it's been fun learning. Also, the build system is pretty impressive. Good work @Gordon!
I had to simply add a word entry for USART3 interrupt to the startup_stm32f401xx.s file the build was using. It was probably simply crashing when calling the interrupt. When trying to bring in the whole newer startup_stm32f413xx.c from the newer lib I have a problem linking. I'm going to continue cleaning things up and trying to make a proper startup for this board so I can do a PR.
Going to try to see what I can get going on the USB side of things as this board has a built in micro USB connector.
Could I increase the amount of jsvars in the board.py file? This chip has 320k of ram, quite a bit more than the f401.
Thanks for all of your guidance @Gordon! I look forward to contributing back to the repo.
-
Looks like the the MCU is crashing when I write to Serial3 or when it receives any data. I can call Serial3.setup fine. Being new to STM32 I'm not sure where to start looking. Maybe st-util and gdb but I'm pretty green with gdb.
This board has a micro USB connector, maybe I'll switch gears and see if I can get anything going on that for the time being.
-
That was my thought as well. For now I tried to just copy the USART3 definitions i need to test and i'll go back and clean it up once it works.
I still dont have a grasp on how the CSV file defines the pins. Can I find any docs on that?
I'm changing the variables in the BOARD.py file like so:
'default_console' : "EV_SERIAL3", 'default_console_tx' : "D8", 'default_console_rx' : "D9",
But once I do that the python scripts don't properly generate the platform_config.h and a make gives me this:
Cleaning targets Generating platform configs Generating pin info make: *** [/Users/dkuschel/Desktop/Espruino/gen/platform_config.h] Error 1
Any thoughts on what I'm doing wrong?
Edit:
After working on this a little more I got the new stm32f413xx.h in the code base and building correctly. I made a new CSV file from the datasheets for the 144 pinout.Now if I keep A2 and A3 physically jumped to D8 and D9 with an airwire I can get a terminal through the ST Link and I can toggle D8 and D9 manually with set() and reset() so that tells me the pin configuration is correct. Of course this interrupts the terminal from functioning. But if I set the default_console to EV_SERIAL3 as outlined above I can't get a terminal going.
-
Well it's neat that they are undertaking that!
So I have some good news. Sometimes it's the simple answer... I've got it running with the regular f411re bin.
Looking at the schematics of the Nucleo 144 board it shows the serial RX/TX connected to PA2/3 (USART2) and the two pin header on the ST-Link (CN5). But they are actually connected to USART3! Great! So simply jumping the PBA2/3 to the RX/TX on the ST-Link is working and I can get a serial terminal.
I'm trying to switch to USART3 in the Board file but looks like USART3 is not defined in the libs. No worries for what I'm trying to design, but it would be nice to setup a proper board file for this new Nucleo so I can submit a PR to your Espruino repo.
-
-
Yep, indeed it is. Channel 1 is the TX from the ST-Link to the F413 which is working as expected. But Channel 0 is the TX from the F413 and it is oddly moving with the other line.
I thought it was a bad ground but i checked the ground to the logic analizer was good so my only other thought is the pin is maybe not configured so it's floating.
-
I set the clock to what should be 100mhz i believe. And I added the pin number from the datasheet to the stm32f401.csv file. No love.
The TX from the MCU seems to be sitting around +/-1vdc so I'm thinking it's not properly configured. Looking at the nucleo 144 board schematics RX/TX to the STLink are indeed the same PA2 and PA3.
This is my first real dive into the world of stm32. While I've used pic and atmegas this stuff is new to me. Any other thoughts on stuff I could look into?
Check out the image from my logic analyzer attached.
-
Hey Gordon!
I worked on this over the weekend and found out exactly what you're talking about. I was trying to get the new (1.8.0) peripheral library to work in the existing Espruino codebase and it was a disaster. Seems it has changed a lot. 1.8.0 directly supports the F413.
I think I did try the F411 image but the board was unresponsive over serial through the onboard ST-Link setup. I was thinking maybe it was just the USART setup, I'll have to continue matching up all the pinouts.
I really hope to get this working so I can add a CAN Bus plugin to Espruino. The idea is to create a board with three CAN channels and this new chip is the only F4 with three CAN controllers. It looks like it just came out about a month ago so resources are pretty sparse at the moment.
-
I'm going through the Espruino code I cloned from Github and was hoping it would be pretty simple to modify the pin assignments to get Espruino going on this dev board.
I've changed as much as I know in a duplicated py file and modified the makefile to use it. I don't have a hold on the format of the pins CSV file and I'm not sure what the STLIB entry in the Makefile points to.
I'm I missing anything else that might need to happen to get this running?
Thanks!
-
-
@MaBe Will do! Thanks!
@Wilberforce I was trying to do the same thing. Glad I saw your response before I spent all night hacking on it. Thanks a ton, that is a great solution for now.
Looks like my ESP8266 / Espruino equipped reflow toaster will get a web ui tonight! :)
-
Great work on this port! It works great so far. I'm building a solder reflow oven and it has worked out well. But now I want to build a web ui to control it. I can't use websockets as I get the error below. I'm on 1.85 from the download page on an ESP-12
WARNING: Module "crypto" not found WARNING: Expecting a number or
something iterable, got undefined WARNING: Expecting a number or
something iterable, got undefined Uncaught Error: Field or method
"SHA1" does not already exist, and can't create it on undefined at
line 1 col 109
....toString(require("crypto").SHA1(f+"258EAFA5-E914-47DA-95CA-...^ in function called from system
I was using the wrong connection handle. Dumb mistake. It works great now. The additions to the code base are quite minor.
Looks like the device is saving the keys as expected so future connections are secured and the connection is seamless.
So would you guys be interested in me cleaning this up and sending a PR? Is it something you would like to be implemented? If so I think we should decide on how exactly it should work. I would image we would just have the Gatt emit an event on BLE_GAP_EVT_AUTH_KEY_REQUEST and then it would be up to the user to acquire the passkey from the user somehow and submit it back. Right now I just added a gatt.submitPasskey method to the jswrap_bluetooth.c that calls sd_ble_gap_auth_key_reply in bluetooth.c.
Edit: Looks like the encrypted characteristics are working and notifications are working! But now I see that there is no indication implementation and the main characteristic value I need to watch is only readable via indication.