-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is this HomeKit-HAP not support for IOS10.3.3 ? #73
Comments
Can you send me the code? Its hard to debug
I have it running at my house, and I haven’t heard any complaint on unsupport yet, and I’m using the code to handle IP can setup right now, so I think it should be still compatible with iOS 10.3.3
…Sent from my iPhone
On Oct 31, 2017, at 12:11 AM, jabenwang ***@***.***> wrote:
Hi @etwmc ,
I use your Personal-HomeKit-HAP to write a demo running on my openwrt , it works sucessfully!
And I added two accessory, lightbule and a switch , which can be dicoveried by Apple homekit on my phone, but they all show as Not supported and needs to update by using the manufacturer's app. I have no idea why this show.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Ok, this my accessory.cpp code , I also sent you an e-mail, please have a check,many thanks~ `/*
#include "Accessory.h" #include "PHKAccessory.h" #include "PHKNetworkIP.h" #include #include using namespace std; pthread_mutex_t recordMutex; set trackingUserList; intCharacteristics *occupyState; #define userListAddr "./userList" void _newConnection(connectionInfo* info) {
} void _deadConnection(connectionInfo *info) {
} void loadUserList() { void saveUserList() { string trackable(connectionInfo *sender) { string calculateOccupy(connectionInfo *sender) { void switchTrackable(bool oldValue, bool newValue, connectionInfo *sender) { void identity(bool oldValue, bool newValue, connectionInfo *sender) { void lightIdentify(bool oldValue, bool newValue,connectionInfo *sender) { AccessorySet *accSet; void AddOccupySensor(){
} void AddLight(){
} void AddSwitch(){
} void initAccessorySet() {
}; ` |
You need to add permission_notify to power state for both switch and light. It’s a new requirement in iOS 10.
…Sent from my iPhone
On Oct 31, 2017, at 12:39 AM, jabenwang ***@***.***> wrote:
Ok, this my accessory.cpp code
`/*
This accessory.cpp is configurated for light accessory
*/
#include "Accessory.h"
#include "PHKAccessory.h"
#include "PHKNetworkIP.h"
#include
#include
using namespace std;
pthread_mutex_t recordMutex;
set trackingUserList;
set <connectionInfo*> activeUsers;
intCharacteristics *occupyState;
#define userListAddr "./userList"
void _newConnection(connectionInfo* info) {
printf("New connection %s\n", info->hostname.c_str());
pthread_mutex_lock(&recordMutex);
bool originalOutput = activeUsers.size() > 0;
if ( trackingUserList.count(info->hostname) > 0 )
activeUsers.insert(info);
bool laterOutput = activeUsers.size() > 0;
pthread_mutex_unlock(&recordMutex);
if (originalOutput != laterOutput) {
//Should notify
printf("Changed\n");
occupyState->notify();
}
}
void _deadConnection(connectionInfo *info) {
pthread_mutex_lock(&recordMutex);
bool originalOutput = activeUsers.size() > 0;
activeUsers.erase(info);
bool laterOutput = activeUsers.size() > 0;
pthread_mutex_unlock(&recordMutex);
if (originalOutput != laterOutput) {
//Should notify
printf("Changed\n");
occupyState->notify();
}
}
void loadUserList() {
ifstream fs;
fs.open(userListAddr, std::ifstream::in);
char buffer[256];
bool isEmpty = fs.peek() == EOF;
while (!isEmpty&&fs.is_open()&&fs.good()&&!fs.eof()) {
fs.getline(buffer, 256);
string s = string(buffer);
trackingUserList.insert(s);
}
fs.close();
}
void saveUserList() {
ofstream fs;
fs.open(userListAddr, std::ifstream::out);
for (set::iterator it = trackingUserList.begin(); it != trackingUserList.end(); it++) {
fs << *it << "\n";
}
fs.close();
}
string trackable(connectionInfo *sender) {
pthread_mutex_lock(&recordMutex);
string result = trackingUserList.count(sender->hostname) > 0? "1": "0";
pthread_mutex_unlock(&recordMutex);
return result;
}
string calculateOccupy(connectionInfo *sender) {
pthread_mutex_lock(&recordMutex);
string result = activeUsers.size() > 0? "1": "0";
pthread_mutex_unlock(&recordMutex);
return result;
}
void switchTrackable(bool oldValue, bool newValue, connectionInfo *sender) {
if (newValue) {
//Track this device
trackingUserList.insert(sender->hostname);
saveUserList();
//Update active list
_newConnection(sender);
} else {
//Stop tracking
trackingUserList.erase(sender->hostname);
saveUserList();
//Update active list
_deadConnection(sender);
}
}
void identity(bool oldValue, bool newValue, connectionInfo *sender) {
printf("Identify\n");
}
void lightIdentify(bool oldValue, bool newValue,connectionInfo *sender) {
printf("Start Identify Light\n");
}
AccessorySet *accSet;
void AddOccupySensor(){
Accessory *sensorAcc = new Accessory();
addInfoServiceToAccessory(sensorAcc, "Occupy Sensor", "ET", "Occupy Sensor v1", "12345678", &identity);
accSet->addAccessory(sensorAcc);
Service *sensorService = new Service(serviceType_occupancySensor);
sensorAcc->addService(sensorService);
boolCharacteristics *trackableState = new boolCharacteristics(0x10000, premission_read|premission_write);
trackableState->characteristics::setValue("false");
trackableState->perUserQuery = &trackable;
trackableState->valueChangeFunctionCall = &switchTrackable;
sensorAcc->addCharacteristics(sensorService, trackableState);
occupyState = new intCharacteristics(charType_occupancyDetected, premission_read|premission_notify, 0, 1, 1, unit_none);
occupyState->characteristics::setValue("0");
occupyState->perUserQuery = &calculateOccupy;
sensorAcc->addCharacteristics(sensorService, occupyState);
}
void AddLight(){
Accessory *lightAcc = new Accessory();
addInfoServiceToAccessory(lightAcc, "Light 1", "ET", "Light v1", "12345678", &lightIdentify);
accSet->addAccessory(lightAcc);
Service *lightService = new Service(serviceType_lightBulb);
lightAcc->addService(lightService);
boolCharacteristics *powerState = new boolCharacteristics(charType_on, premission_read|premission_write);
powerState->characteristics::setValue("true");
lightAcc->addCharacteristics(lightService, powerState);
intCharacteristics *brightnessState = new intCharacteristics(charType_brightness, premission_read|premission_write, 0, 100, 1, unit_percentage);
brightnessState->characteristics::setValue("50");
lightAcc->addCharacteristics(lightService, brightnessState);
}
void AddSwitch(){
Accessory *switchAcc = new Accessory();
addInfoServiceToAccessory(switchAcc, "Switch 1", "ET", "Switch v1", "12345678", &lightIdentify);
accSet->addAccessory(switchAcc);
Service *switchService = new Service(serviceType_switch);
switchAcc->addService(switchService);
boolCharacteristics *powerState = new boolCharacteristics(charType_on, premission_read|premission_write);
powerState->characteristics::setValue("true");
switchAcc->addCharacteristics(switchService, powerState);
}
void initAccessorySet() {
newConnection = &_newConnection;
deadConnection = &_deadConnection;
loadUserList();
pthread_mutex_init(&recordMutex, NULL);
currentDeviceType = deviceType_bridge;
printf("Initial Accessory\n");
accSet = &AccessorySet::getInstance();
Accessory *bridge = new Accessory();
addInfoServiceToAccessory(bridge, "NDBJ", "ET", "Bridge", "12345678", &identity);
accSet->addAccessory(bridge);
AddLight();
AddOccupySensor();
AddSwitch();
};
`
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Ok, thank you very much~ |
Hi @etwmc ,
I use your Personal-HomeKit-HAP to write a demo running on my openwrt , it works sucessfully!
And I added two accessory, lightbule and a switch , which can be dicoveried by Apple homekit on my phone, but they all show as Not supported and needs to update by using the manufacturer's app. I have no idea why this show.
The text was updated successfully, but these errors were encountered: