You are reading a single comment by @tronic98776 and its replies. Click here to read the full conversation.
  • So I think I'm making some progress here. I've been playing around with the @allObjects solution in an editor so I can get some output in the browser.

    
    // setup of you convenience hidKeyBoardObject... (here or later)
    var hidKBD = ( 
    { 
        //member of hidKBD, currently empty
        string: "" , 
        type: function(s) {     
            this.string += s;
            if (this.string.length = s.length) {
                this._send(this.string.charAt(0));
            } 
        }, 
    
        //sends first character then references _sent .this so this.string in _sent will be the string from _send
        _send: function(c) { 
            console.log(c,this._sent.bind(this));
        },
    
        //subtracts first letter from string then passes new first letter to _send
        _sent: function() { 
            this.string = this.string.substring(1);
            if (this.string.length > 0) {
                this._send(this.string.charAt(0));
            }
        }
    } );
    
    // setup and other code functions of yours (here or before hidKBD)
    //function onInit() {
    // invoke your set up code as needed (init and getting connections)
    hidKBD.type("ABC");
    //hidKBD.type("XYZ");
    //}
    
    

    I've added some of my own commenting just to verify that I understand what is happening.

    But due to the placement of the console.log on line 15, the log returns "A", but then the bind doesn't seem to envoke the _sent function and just prints the contents of _sent in the console:

    //console output
    
    A ƒ () { 
            this.string = this.string.substring(1);
            if (this.string.length > 0) {
                this._send(this.string.charAt(0));
            }
        }
    

    How can I set up something so I can play with the code and have it returning a something representative of the BLE HID output to a browser.

    Many thanks guys.

About

Avatar for tronic98776 @tronic98776 started