Avatar for user109470

user109470

Member since Feb 2020 • Last active Mar 2020
  • 1 conversations
  • 3 comments

Most recent activity

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

    Thank you all for the help! I tried uploading the example code to the puck, but when I connect to it from the react native app and printing out all characteristics, I can't seem to find the one I supposedly created using NRF.setServices().
    Am I doing something completely wrong that you can see? When using the same RN library reading from a MDBT42Q it works well.

    Espruino Code:

    console.log(NRF.getAddress());
    console.log(NRF.getBattery());
    
    NRF.setServices({
      0xBCDE : {
        0xABCD : {
          value: 'hi',
          writable : true,   // optional, default is false
          notify : true,   // optional, default is false
          indicate : true,   // optional, default is false
          description: "My Characteristic",  // optional, default is null,
          onWrite : function(evt) {
            console.log(evt.data);
          }
        }
      }
    });
    

    RN code:

    componentDidMount() {
            const bleManager = new BleManager();
    
            bleManager.startDeviceScan(null, null, async (err, device) => {
                if (err) console.log(err)
                else {
                    if (device.localName === DEVICE_NAME) {
                        bleManager.stopDeviceScan()
    
                        const deviceId = device.id;
                        console.log(`Trying to connect to device with MAC: ${deviceId}`);
    
                        try {
                            const device = await bleManager.connectToDevice(deviceId).the­n(d => d.discoverAllServicesAndCharacteristics(­));
                            const svcs = await device.services();
                            console.log('try')
                            for (let ii = 0; ii < svcs.length; ++ii) {
                                const currentService = svcs[ii];
                                let characteristics = await currentService.characteristics();
                                for (let jj = 0; jj < characteristics.length; ++jj) {
                                    const currentCharacteristic = characteristics[jj];
                                    console.table(currentCharacteristic);
                                    if (currentCharacteristic.uuid === CHARACTERISTIC_UUID {
    
    
                                  
                                        console.table(currentCharacteristic);
                                        const cc = await currentCharacteristic.writeWithoutRespon­se(
                                            btoa('1111111')
                                        )
                                        
                                        console.table(currentCharacteristic);
    
                                    }
    
    
                                }
                            }
                        }
                        catch (e) {
                            console.log(e)
                        }
                    }
                }
            })
        }
    
    
    
  • in Puck.js, Pixl.js and MDBT42
    Avatar for user109470

    Thank you so much!
    I managed to read from an espruino board with the react app I developed, now the part I am missing is writing. The javascript links might be helpful, thank you!
    Once I define the characteristic I want to write to, with the code provided below, it recieves the sent data in evt, correct? and I can store that data in an array I can then access to control the car.
    If that is correct, you have been super helpful and I guess I will move to figuring out how to write in the characteristic from the app.

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

    Hi everyone!
    I have a puck.js which I would like to use to control a robotic car, made up of 4 servomotors. In order to control this, I'd want to send the commands to the puck via BLE having a react native application as interface.
    I manged to identify the characteristics I can write to, but I don't know hoe to code the puck so that it reads these characteristics and acts upon what is communicated through them.
    Does anyone have any idea how to help me with this task? Or knows of any effective tutorials I can look into...
    I am quite new to the javascript-bluetooth world so any help is deeply appreciated.
    Silvia

Actions