etwmc / Personal-HomeKit-HAP

This project will provide source code to build a HomeKit support accessories.
MIT License
236 stars 85 forks source link

BoolCharacteristic value #65

Open beckmx opened 7 years ago

beckmx commented 7 years ago

@etwmc I am using the latest version of iOS10.2 beta, and realize that the boolCharacteristic never gets fired with "true" statements. So I was debugging the code and realized it returns "true" or "false" on the first time PHK startup, but after that, the "home" app just sends "1" or "0", this is a little fix I implemented to understand both ways, it should be placed in the PHKAccessory.h:

virtual void setValue(string str) {
        bool newValue = false;
        if(strncmp("true", str.c_str(), 4)==0 || strncmp("1", str.c_str(), 1)==0){
       newValue=true;
    }
        if (valueChangeFunctionCall)
            valueChangeFunctionCall(_value, newValue);
        _value = newValue;
    }

Greetings!