Avatar for EspruinošŸ„µEspressifšŸ„µ

EspruinošŸ„µEspressifšŸ„µ

Member since Mar 2023 • Last active Jun 2023
  • 2 conversations
  • 12 comments

Most recent activity

  • in Bangle.js
    Avatar for EspruinošŸ„µEspressifšŸ„µ

    We're adding logs to findout where the problem is stemming from. It probably is related to running out of memory but we changed all of our allocations to be static so not sure why thats happening

  • in Bangle.js
    Avatar for EspruinošŸ„µEspressifšŸ„µ
        new Uint8Array([battery_status_flags, power_state_flags>>8, power_state_flags&255, battery_level]).buffer
    

    Are you sure this is correct? It seems like you're encoding it in big endian, wouldn't the correct encoding be

        new Uint8Array([battery_status_flags, power_state_flags&0xff, power_state_flags>>8, battery_level]).buffer
    
  • in Bangle.js
    Avatar for EspruinošŸ„µEspressifšŸ„µ

    I'm getting a weird error too when I use NRF.updateServices,

    Execution Interrupted during event processing.
    Execution Interrupted during event processing.
    

    I've set an interval of 40 seconds, to update the characteristic, it's not like it's updating a few times a second. Is there any reason for this?

  • in Bangle.js
    Avatar for EspruinošŸ„µEspressifšŸ„µ

    I've seen all of that, it's not very helpful for someone at my level. The GATT specification is slightly more helpful because it atleast contains the format for the payload.

  • in Bangle.js
    Avatar for EspruinošŸ„µEspressifšŸ„µ

    Oops sorry my bad, it's this GATT_Specification_Supplement_v8 the -1 was appended by windows I guess it's stopped using (1) to indicate duplicate files. I've added screenshots from the specification directly. Do you know why the specification is so difficult to implement, seems like it's raising the barrier of entry for no reason. Specially since they provide basically no information on how to actually implement it. Do you think you have any reference implementations or blogs that can help.

  • in Bangle.js
    Avatar for EspruinošŸ„µEspressifšŸ„µ

    I don't think this will probably affect me because I plan on polling the characteristic anyway but getting notifications would be much better so data can be sent automatically. Is this related to how fast you call updateServices?

    @Gordon have you experienced this problem

  • in Bangle.js
    Avatar for EspruinošŸ„µEspressifšŸ„µ

    Hello, I'm trying to implement the Bluetooth SIG Battery Service but it's very complicated and there's absolutely no help in terms of example available online. I'm not trying to implement all of the characteristics in that service only battery_level & battery_level_status. Implementing is very confusing because the documentation provided by bluetooth doesn't match any of the implementations you can observe on github. Even in NRF's own implementation of the specification the battery service only has two characteristics as opposed to the 5 provided by the specification. Also apparently you're supposed to combine the unit for a value with the actual value somehow which I don't understand and I can't really find any references for it in the specification.

    Can someone please look over my implementation if it follows the specification correctly. For reference I am using Assigned Numbers Revision Date: 20230313 & GATT_Specification_Supplement_v8-1 as reference. I really appreciate the help, thank you in advance.

    let IS_CHARGING = false;
    // Globals
    let IS_CONNECTED;
    
    function onConnect() {
        IS_CONNECTED = true
    }
    
    function onDisconnect() {
        IS_CONNECTED = false
    }
    
    function onCharge(charging) {
        IS_CHARGING = charging
    }
    
    function build_battery_status(){
        const battery_level = E.getBattery()
        // 0 good, 1 bad
        let is_charge_good = battery_level > 80 ? true: false
        const battery_status_flags = 2;
        let power_state_flags = 1
        if(IS_CHARGING){
            // Charging
            power_state_flags = power_state_flags | 32
        }else{
            // Active Discharging
            power_state_flags = power_state_flags | 64
        }
        if(is_charge_good){
            // Good
            power_state_flags = power_state_flags | 128
        }else{
            // Bad
            power_state_flags = power_state_flags | 256
        }
        // I know this part is technically incorrect because battery_status_flags & 
        // battery_level should be 1 octet but since I don't know I don't understand 
        // the endianness(I know it's little endian) I have referained from encoding
        // it directly
        const encoded = new Uint16Array([battery_status_flags, power_state_flags, battery_level]).buffer
        return encoded
    }
    
    function update_battery_status(){
        NRF.updateServices({
            0x180F: {
                0x2A19: {
                    value: [E.getBattery()]
                },
                0x2BED: {
                    value:build_battery_status()
                },
            },
        })
    }
    
    function onInit() {
        Bangle.on('charging', onCharge);
        NRF.on('connect', onConnect);
        NRF.on('disconnect', onDisconnect);
        NRF.setServices({
            // Battery level service
            0x180F: {
                0x2A19: {
                    notify: true,
                    readable: true,
                    indicate: true,
                    description: "Battery Level",
                    value: [E.getBattery()]
                },
                0x2BED: {
                    notify: true,
                    readable: true,
                    indicate: true,
                    description: "Battery Status",
                    value:build_battery_status()
                },
            }
        })
    
        setInterval(update_battery_status, 40_000)
    }
    
  • in Bangle.js
    Avatar for EspruinošŸ„µEspressifšŸ„µ

    Do I have to be worried about whats happening here? Because I honestly don't understand whats happening.

Actions