Avatar for user63214

user63214

Member since Mar 2016 • Last active Jan 2019
  • 3 conversations
  • 26 comments

Most recent activity

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user63214

    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.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user63214

    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.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user63214

    I would think so yes. The camera does not show a pin until the bonding is started.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user63214

    Ok, I thought that was the case. I'm not familiar with the nRF52 libs but if I find some time I'll see if I can't figure it out and submit a PR.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user63214

    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.

  • in General
    Avatar for user63214

    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!

  • in General
    Avatar for user63214

    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;
    
    }
    
    • 30 comments
    • 9,432 views
Actions