Coder Social home page Coder Social logo

etwmc / personal-homekit-hap Goto Github PK

View Code? Open in Web Editor NEW
237.0 62.0 84.0 1.81 MB

This project will provide source code to build a HomeKit support accessories.

License: MIT License

C++ 17.20% Objective-C 20.54% C 49.88% Makefile 4.35% Shell 0.15% M4 7.89%

personal-homekit-hap's Introduction

PersonalHomeKit


Update at 12/31/2019: For the last two and a half years, I've been working in a smart home company. Therefore, to avoid complication, I have not updated this repo since joined. And while I have continue develop on my personal build and projects using this project, it's unlikely I will be able to publish anything.

The good thing is, since this will continue exist, and the HomeKit Accessory protocol Spec has been released for the hobbyists, there should be sufficient information updating for future iOS support.

In the future, if anyone is interested in contribute for the project, please let me know.

Thanks, Raymond Chan


This is a user based version (the characteristic is depended on the connection session). For dynamic or static version(MCU version), switch to the correspondent branch. Now support multiple characteristic, notify function

Plug for relative project

Want to turn off the lights when everyone is out? How about closing the gas valve? Introduing a derived project: WiFi-Radar. No apps needed, no GPS tracing. All you need is a Wi-Fi network and a *nix running system WiFi-Radar-HAP

Also, the first HomeKit test and benchmark app HomeKitTester


Reset In iOS 9.0 Beta 1, Apple has implemented the check of status flag: a integer display where an accessory should be discoverable. And for any accessory that has paired, the flag should be 0. Therefore, there is a way to reset the pair record in since this version: By adding any argument while launching the program, the program will clear all the previous record of pairing, before start to launch the service. e.g. ./PHK abcdefg This argument might be changed in the future, so if you want to deploy for the future, consider using "PHK reset" as the command.

( However, as it has not been implemented in iOS 8.3 or before, after any reset, iOS devices before iOS 9 will still attempt to connect, which will failed for obvious reason. In that case, a manual removal of the accessory on the iOS end is required. )

===============

This is a spin-off project from my attempt to build a Siri controlled night light, and it will provide source code to build a HomeKit support accessories.

  1. Publish the device as a HomeKit
  2. Allow the controller (iOS device) to pair with the accessory
  3. Allow the controller connect with the accessory after pair
  4. Record the paired controllers UUID and public keys
  5. Provide the controller the service about the accessory
  6. Allow controller to update value
  7. Notify controller about value updated

Current Requirment:

  1. OpenSSL
  2. Avahi (For Linux)

Future Plan:

  1. Support microcontroller

=============== Dear Lawyer of Apple,
If you want me to pull down the code, just send me an email. (No phone call, I don't pick up unknown number. ) I'm a reasonable kid, and I like Apple, so no need for DMCA, just talk to me, we can make a deal.

Build method: After copy the codes, please follow these steps:

  1. On non-OSX platform, please install avahi-deamon (or any dns-sd implement), clang and OpenSSL.
  2. Set the following value in Configuration.h
    i. HomeKitLog -> Whether the program return message to console

ii.HomeKitReplyHeaderLog -> Whether the program should return the accessory message (Recommend debug only)

iii. Device setting: deviceName (Name), deviceIdentity (Device ID publish in HomeKit, usually your MAC address), manufactuerName (Manufactuer Name shown in HomeKit Framework), devicePassword (Password, please choose 9 non sequential, or repeat digits in XXX-XX-XXX fashion, e.g. 421-35-195), deviceUUID (UUID for iOS to verify your accessory identity)

iv. (IMPORTANT) controllerRecordsAddress -> where should the program store the pair record. It is left empty to prevent you compile without setting Configuration.h

v. numberOfClient -> Please increase or lower it based on your hardware power. HomeKit framework require the accessory to response in 1-2 seconds before timeout.

vi. (IMPORTANT) If you are porting the program to MCU (NOT OFFICIAL TESTED), change MCU to 1, and implement pair record service in PHKControllerRecord.cpp, as MCU usually use EEPROM instead a file system.

  1. Implement Accessory function: The program publish a light service (and identify service, which is the essential function of any HomeKit accessory). However, the service does nothing as the variety configuration one could come up to achieve this project (I'm currently using a Ubuntu server, with serial connected Arduino)

Therefore, change the PHKArduinoLightInterface.c to your own configuration setupPort() -> setup the connection/GPIO/other thing you need to change the light startIdentify() -> a method to show users this accessory is the one they ask to identify (for example, blink three time) setLightStrength(int strengthLevel) -> change the light stength, the int is from 0-255

To create your own service, please reference to the Accessory.cpp. You can add characteristic in a service, service in an accessory, and accessory in accessory set. However, accessory id is unique in accessory set, and characteristic id is unique in accessory. (NOT SERVICE)

(Please beware the number of characteristic, service and accessory, and the getter based on id is hard coded in the numberOf_ and _AtIndex. This is done to reduce the multithread complexity. So if you are going to implement a dynamic setting (for example, make a accessory bridge with PnP accessories), please keep the function be thread-safe at all time. )
4. Then, make and enjoy.

personal-homekit-hap's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

personal-homekit-hap's Issues

PHK a needs to be restarted periodically.

I use PHK which runs on a raspi 2 with an iPhone app. When I run PHK everything works and I'm able to control my devices with Siri.
But, the PHK bridge become undiscoverable the next day even though the PHK is still running on raspi. Everything starts to work again if I kill PHK and restart it. My email: [email protected]
Thanks much for sharing this great code.

fatal error: dns_sd.h

I already install avahi, but keeps pulling me this error on compilation, any ideas how to get it pass?

greetings! (btw I am trying to compile it on top of a arm board)

Question

I'm trying to compile the static branch of the code, but I got:
In file included from main.cpp:11:0:
PHKNetworkIP.h:40:27: error: ISO C++ forbids initialization of member ‘index’ [-fpermissive]
PHKNetworkIP.h:40:27: error: making ‘index’ static [-fpermissive]
PHKNetworkIP.h:40:27: error: ISO C++ forbids in-class initialization of non-const static member ‘index’
PHKNetworkIP.h:41:18: error: ISO C++ forbids initialization of member ‘data’ [-fpermissive]
PHKNetworkIP.h:41:18: error: making ‘data’ static [-fpermissive]
PHKNetworkIP.h:41:18: error: invalid in-class initialization of static data member of non-integral type ‘char*’
PHKNetworkIP.h:42:27: error: ISO C++ forbids initialization of member ‘length’ [-fpermissive]
PHKNetworkIP.h:42:27: error: making ‘length’ static [-fpermissive]
PHKNetworkIP.h:42:27: error: ISO C++ forbids in-class initialization of non-const static member ‘length’
PHKNetworkIP.h:43:21: error: ISO C++ forbids initialization of member ‘activate’ [-fpermissive]
PHKNetworkIP.h:43:21: error: making ‘activate’ static [-fpermissive]
PHKNetworkIP.h:43:21: error: ISO C++ forbids in-class initialization of non-const static member ‘activate’
PHKNetworkIP.h:50:27: error: ISO C++ forbids initialization of member ‘count’ [-fpermissive]
PHKNetworkIP.h:50:27: error: making ‘count’ static [-fpermissive]
PHKNetworkIP.h:50:27: error: ISO C++ forbids in-class initialization of non-const static member ‘count’
PHKNetworkIP.h:88:22: error: ISO C++ forbids initialization of member ‘connected’ [-fpermissive]
PHKNetworkIP.h:88:22: error: making ‘connected’ static [-fpermissive]
PHKNetworkIP.h:88:22: error: ISO C++ forbids in-class initialization of non-const static member ‘connected’
PHKNetworkIP.h:92:41: error: ISO C++ forbids initialization of member ‘numberOfMsgRec’ [-fpermissive]
PHKNetworkIP.h:92:41: error: making ‘numberOfMsgRec’ static [-fpermissive]
PHKNetworkIP.h:92:41: error: ISO C++ forbids in-class initialization of non-const static member ‘numberOfMsgRec’
PHKNetworkIP.h:93:42: error: ISO C++ forbids initialization of member ‘numberOfMsgSend’ [-fpermissive]
PHKNetworkIP.h:93:42: error: making ‘numberOfMsgSend’ static [-fpermissive]
PHKNetworkIP.h:93:42: error: ISO C++ forbids in-class initialization of non-const static member ‘numberOfMsgSend’
PHKNetworkIP.h:94:22: error: ISO C++ forbids initialization of member ‘subSocket’ [-fpermissive]
PHKNetworkIP.h:94:22: error: making ‘subSocket’ static [-fpermissive]
PHKNetworkIP.h:94:22: error: ISO C++ forbids in-class initialization of non-const static member ‘subSocket’

What am I doing wrong?

fan and light Accessory.cpp

Im still getting errors with make...I haven't modified the fan+light.cpp at all, except renaming it.

pi@Raspbian ~/Personal-HomeKit-HAP- $ sudo make all
gcc -O0 -w -o chacha20.o -c Chacha20/chacha20_simple.c
gcc -O0 -w -o curve25519.o -c curve25519/curve25519-donna.c
gcc -O0 -w -o ed25519.o -c ed25519-donna/ed25519.c
gcc -O0 -w -o poly1305.o -c poly1305-opt-master/poly1305.c
gcc -O0 -w -c rfc6234-master/hkdf.c -o rfc6234-master/hkdf.o
gcc -O0 -w -c rfc6234-master/hmac.c -o rfc6234-master/hmac.o
gcc -O0 -w -c rfc6234-master/sha.c -o rfc6234-master/sha.o
g++ -O0 -w -c main.cpp
g++ -O0 -w -c PHKAccessory.cpp
g++ -O0 -w -c PHKControllerRecord.cpp
g++ -O0 -w -c PHKNetworkIP.cpp
gcc -c -o PHKArduinoLightInterface.o PHKArduinoLightInterface.c
gcc -O0 -lcrypto -w -c srp/srp.c -o srp/srp.o
gcc -O0 -lcrypto -w -c srp/cstr.c -o srp/cstr.o
gcc -O0 -lcrypto -w -c srp/t_math.c -o srp/t_math.o
gcc -O0 -lcrypto -w -c srp/srp6_server.c -o srp/srp6_server.o
gcc -O0 -lcrypto -w -c srp/t_conf.c -o srp/t_conf.o
gcc -O0 -lcrypto -w -c srp/t_conv.c -o srp/t_conv.o
gcc -O0 -lcrypto -w -c srp/t_pw.c -o srp/t_pw.o
gcc -O0 -lcrypto -w -c srp/t_misc.c -o srp/t_misc.o
gcc -O0 -lcrypto -w -c srp/t_truerand.c -o srp/t_truerand.o
gcc -O0 -lcrypto -w -c srp/t_read.c -o srp/t_read.o
g++ -O0 -w -c Accessory.cpp
In file included from Accessory.cpp:7:0:
PHKAccessory.h: In function ‘void initAccessorySet()’:
PHKAccessory.h:297:5: error: ‘AccessorySet::AccessorySet()’ is private
AccessorySet() {
^
Accessory.cpp:21:31: error: within this context
accSet = new AccessorySet();
^
Accessory.cpp:23:80: error: ‘lightIdentify’ was not declared in this scope
addInfoServiceToAccessory(lightAcc, "Light 1", "ET", "Light", "12345678", &lightIdentify);
^
Accessory.cpp:43:71: error: ‘fanIdentify’ was not declared in this scope
addInfoServiceToAccessory(fan, "Fan 1", "ET", "Fan", "12345678", &fanIdentify);
^
makefile:42: recipe for target 'Accessory.o' failed
make: *** [Accessory.o] Error 1
pi@Raspbian ~/Personal-HomeKit-HAP- $

License

Under what License do you provide this code?

Stop Connect but don't know why

hey
everythings worked perfectly but after a total purge of my raspberry and reconfiguring PHK Stop Connect after "Successfully Connect"... i don't know why it's random :/
an idea ?

Initial Accessory
Serial Port: -1
*** WARNING *** The program 'PHK' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=PHK
Start Connect: 11
Start Pair Verify
State = 1
Pair Verify M1
State = 3
Pair Verify M3
Successfully Connect
Stop Connect: 11

_ZNSt8ios_baseC2Ev

Hello @etwmc today I encounter this issue on another platform, any idea what could this mean?

./PHK: can't resolve symbol '_ZNSt8ios_baseC2Ev' in lib './PHK'.

Do you think with the -static flag the application can run fine?

Greetings!

Make error

Hello,

I get an error at make.
When it come to PHKAccessory.cpp compil error:
PHKAccessory.cpp: In function 'void updateValueFromDeviceEnd(characteristics_, int, int, std::string)':
PHKAccessory.cpp:336:114: error: cannot pass objects of non-trivially-copyable type 'std::string {aka class std::basic_string}' through '...'
snprintf(broadcastTemp, 1024, "{"characteristics":[{"aid":%d,"iid":%d,"value":%s}]}", aid, iid, value);
^
makefile:42: recipe for target 'PHKAccessory.o' failed
make: *_* [PHKAccessory.o] Error 1

What's wrong ?
Thanks

Startup on boot raspberry

Hi,

I've got a good setup with the dynamic fork and would like to start it at boot on my raspberry. Unfortunately it does not work using the way described in the wiki. One thing I noticed is that is starts using root user, perhaps this causes problems.

The controller file is created and the service seems running, however I cannot add the accessory on my phone.

Does anyone have an idea on what causes this problem? I tries to su - xbian in the homekit file located in the /etc/init.d, but it did not work (probably did something wrong though..)

Thanks!
Roy

Make errors

Total NOOB here. I am trying to get your code running on a Raspberry Pi.

I have already performed the following:

  • apt-get install libavahi-compat-libdnssd-dev openssl clang -y
  • git clone https://github.com/etwmc/PersonalHomeKit.git
  • cd PersonalHomeKit
  • make

Get the following error message:

root@raspberrypi:/PersonalHomeKit# make
clang -Ofast -w -o chacha20.o -c Chacha20/chacha20_simple.c
error: invalid integral value 'fast' in '-Ofast'
error: invalid integral value 'fast' in '-Ofast'
makefile:23: recipe for target 'chacha20.o' failed
make: *** [chacha20.o] Error 1
root@raspberrypi:
/PersonalHomeKit#

UPDATE: I got a little further on Ubuntu 14 VM

root@ubuntu-Server-14:/PersonalHomeKit# make
clang -Ofast -w -o chacha20.o -c Chacha20/chacha20_simple.c
clang -Ofast -w -o curve25519.o -c curve25519/curve25519-donna.c
clang -Ofast -w -o ed25519.o -c ed25519-donna/ed25519.c
clang -Ofast -w -o poly1305.o -c poly1305-opt-master/poly1305.c
clang -Ofast -w -c rfc6234-master/hkdf.c -o rfc6234-master/hkdf.o
clang -Ofast -w -c rfc6234-master/hmac.c -o rfc6234-master/hmac.o
clang -Ofast -w -c rfc6234-master/sha.c -o rfc6234-master/sha.o
clang++ -Ofast -w -c main.cpp
clang++ -Ofast -w -c PHKAccessory.cpp
clang++ -Ofast -w -c PHKControllerRecord.cpp
PHKControllerRecord.cpp:29:37: error: expected expression
fs.open(controllerRecordsAddress, std::ifstream::in);
^ # caret pointing to ,
PHKControllerRecord.cpp:61:41: error: expected expression
fs.open(controllerRecordsAddress, std::ofstream::trunc);
^ # caret pointing to ,
2 errors generated.
make: *** [PHKControllerRecord.o] Error 1
root@ubuntu-Server-14:
/PersonalHomeKit#

UPDATE2: Noticed LLVM 3.0 on RPi, 3.4 on Ubuntu 14. Changed makefile CFLAG from -Ofast to -O0 on RPi, but now get this:

clang++ -O0 -w -c PHKAccessory.cpp
PHKAccessory.cpp:129:19: error: use of undeclared identifier 'INT32_MIN'
if (minVal != INT32_MIN)
^
PHKAccessory.cpp:133:19: error: use of undeclared identifier 'INT32_MAX'
if (maxVal != INT32_MAX)
^
PHKAccessory.cpp:183:19: error: use of undeclared identifier 'INT32_MIN'
if (minVal != INT32_MIN)
^
PHKAccessory.cpp:187:19: error: use of undeclared identifier 'INT32_MAX'
if (maxVal != INT32_MAX)
^
4 errors generated.
makefile:35: recipe for target 'PHKAccessory.o' failed
make: *** [PHKAccessory.o] Error 1
root@raspberrypi:~/PersonalHomeKit#

Silly question about sensor value update

Hi,
I'm trying to create a simple temperature sensor with your Homekit HAP but I'm not sure I fully understood the architecture: looking at Accessory.cpp it's pretty straightforward that the callback 'valueChangeFunctionCall' is invoked when the controller sets a new value for the characteristics but it's not clear (at least to me) what is the sibling 'read' callback.

The question is: is there a callback that is called whenever the controller asks for the current state? In the temperature example, I would like to return the current temperature (based on a call to an http server or whatever) but I wasn't able to do so.
I tried extending an intCharacteristics to my custom characteristics that override the constructor, value() and setValue() methods, to no avail: 'value()' is never changed...

Any hint on this?

Thanks!

Multiple accessories

Hi,

Great work in creating and sharing this library. I will try to contribute and would like to add more accessories, but how would you suggest to approach this? One option is by changing the code to create more accessories and open ports for each. Another option is perhaps to create a sort of dynamic library which different accessory can use to run seperate programs with seperate functionality. Or do you suggest some other approach?

Thanks again!

Roy

C# port data request

Hi,

I am making a port to c#.
Because the absence of right functioning libraries I had to create some myself already (chacha20poly1305 and specific SRP implementation).

At this moment I am stuck on verifying the controller info signature using Ed25519.
Could you give me some intermediate values of your project in hex-byte arrays? Eg the shared secret, the session key, input and output of chacha20poly1305 algorithm and preferably the deserialized tlv data of that? The other inputs for the ed25519 algorithm as well of course.

That way I could check my source to see where it fails. I assume it is the ed25519 library I am using this time or some byte gets lost during an earlier process.
Since I get to m5 the session key and therefore shared secret must be right.
I can also deserialize tlv data after decrypting chachapoly so those algorithms work as well. I just can't verify the signature in the decrypted subtlv data.

Thank you very much!

bad args in Accessory.cpp

PowerState is based on boolean and brightnessState is based on int but they both call changeLightIntensity which accepts int. I think you want something like changePowerState which accepts booleans.

boolCharacteristics *powerState = new boolCharacteristics(charType_on, premission_read|premission_write|premission_notify);
powerState->setValue("true");
powerState->valueChangeFunctionCall = &changeLightIntensity;
lightAcc->addCharacteristics(lightService, powerState);

intCharacteristics *brightnessState = new intCharacteristics(charType_brightness, premission_read|premission_write|premission_notify, 0, 100, 1, unit_percentage);
brightnessState->setValue("50");
brightnessState->valueChangeFunctionCall = &changeLightIntensity;
lightAcc->addCharacteristics(lightService, brightnessState);

Segmentation fault

The PHK server crashes immediately after trying to add the bridge to the iPhone app. Specifically after responding to the Alert that says this accessory is not certified. This problem started after I switched to iOS 9 (beta 4).

statusCode is uninitialized in handleAccessory in PHKAccessory.cpp

Hi,
I've gotten much farther with your new drop. I had a problem with statusCode being used in the while loop in handleAccessory before it was initialized. I just changed the declaration to
int statusCode = 0;

and now I'm getting events processed.
Thanks,
Steve

fan and light

Hi there...ive finally got a chance to play with this and I have an issue...
I've used the example you've supplied to use the fan and light together.
it all seems to setup fine, and both the fan and light are available for me to switch in the iOS app.
As I'm only testing this right now, the only modification I've made is to log what device is being switched and if its being switched on or off....

for the light...

class lightPowerState: public boolCharacteristics {
public:
lightPowerState(int &index): boolCharacteristics(index, charType_on, premission_read|premission_write){}
string value() {
if (lightStength > 0)
return "1";
return "0";
}
void setValue(string str) {
this->boolCharacteristics::setValue(str);
if (_value) {
setLightStrength(255);
printf("switching light on\n");
} else {
setLightStrength(0);
printf("switching light off\n");
}
}
};

and for the fan...

class fanPowerState: public boolCharacteristics {
public:
fanPowerState(int &index): boolCharacteristics(index, charType_on, premission_read|premission_write){}
string value() {
if (fanSpeedVal > 0)
return "1";
return "0";
}
void setValue(string str) {
this->boolCharacteristics::setValue(str);
if (_value) {
fanSpeedVal = 255;
setFanSpeed(255);
printf("switching fan on\n");
} else {
fanSpeedVal = 0;
setFanSpeed(0);
printf("switching fan off\n");
}
}
};

The problem is this, no matter what device i switch, the output only ever shows "switching fan on" or "switching fan off"....the light never gets switched....only the fan.

if i use the iOS simulator the console output is as follows....

HomeKitDemo[30415:632924] Error read Char: <HMCharacteristic: 0x7f9401783c30>, error: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Invalid value around character 45.) UserInfo=0x7f94015b4700 {NSDebugDescription=Invalid value around character 45.}
2014-11-20 13:46:56.739 HomeKitDemo[30415:632924] Error read Char: <HMCharacteristic: 0x7f94017a7560>, error: Error Domain=HMErrorDomain Code=54 "Failed with OSStatus code -6723 (kCanceledErr)" UserInfo=0x7f940148d7d0 {NSLocalizedDescription=Failed with OSStatus code -6723 (kCanceledErr)}
2014-11-20 13:46:56.740 HomeKitDemo[30415:632924] Error read Char: <HMCharacteristic: 0x7f94017b0170>, error: Error Domain=HMErrorDomain Code=54 "Failed with OSStatus code -6723 (kCanceledErr)" UserInfo=0x7f9403a35400 {NSLocalizedDescription=Failed with OSStatus code -6723 (kCanceledErr)}

Am i doing something wrong?
Your assistance is appreciated.

adding ON/OFF callback

please add callback for turning on?off the light in PHKArduinoLightInterface.c or can you tell me how to map these things so that i can add it myself.

http requests

Great project, i have this up and running on a pi but as a beginner I'm having trouble implementing my own devices.
How would i go about using http requests in this project, as pretty much all of my home automation system is controlled in this way.
i appreciate that this isn't an issue as such, but i, and many other beginners, would really appreciate an example of how this could be achieved.If you could give me some pointers i would be happy to put a guide together and add it to the wiki.

create multiple lights and execute shell scripts

hey guys!
as my programming skills are very basic i need some help.

I would like to create multiple lights and execute a shell script when a lamp is turned on or off.

for example
"if lamp1 is turned on execute /home/pi/lamp1_on.sh"
"if lamp1 is turned on execute /home/pi/lamp1_off.sh"
"if lamp2 is turned on execute /home/pi/lamp2_on.sh"
"if lamp2 is turned on execute /home/pi/lamp2_off.sh
and so on..

How could i achieve this?
Where do i need to edit the code?
I looked inside the accessory.cpp and PHKArduinoInterface files an tried to modify the
inline void turnOnLight() { setLightStrength(255); }
inline void turnOffLight() { setLightStrength(0); }

with adding System(Home/pi/test.sh);
But that didn't worked.

Can anyone help me?
Thank you very much! You're doing great work here

OpenWrt

I have an openwrt device but I was wondering if anyone here have already tried it?, I already tried this repo on AriettaG25, Intel Edison

fan and light Accessory.cpp

Hi, I'm trying to use the fan and light Accessory.cpp but I'm getting error with make....

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Tue Jun 9 19:06:36 2015 from gavsmac
pi@Raspbian ~ $ cd Personal-HomeKit-HAP-
pi@Raspbian ~/Personal-HomeKit-HAP- $ sudo make
gcc -O0 -w -o chacha20.o -c Chacha20/chacha20_simple.c
gcc -O0 -w -o curve25519.o -c curve25519/curve25519-donna.c
gcc -O0 -w -o ed25519.o -c ed25519-donna/ed25519.c
gcc -O0 -w -o poly1305.o -c poly1305-opt-master/poly1305.c
gcc -O0 -w -c rfc6234-master/hkdf.c -o rfc6234-master/hkdf.o
gcc -O0 -w -c rfc6234-master/hmac.c -o rfc6234-master/hmac.o
gcc -O0 -w -c rfc6234-master/sha.c -o rfc6234-master/sha.o
g++ -O0 -w -c main.cpp
g++ -O0 -w -c PHKAccessory.cpp
g++ -O0 -w -c PHKControllerRecord.cpp
g++ -O0 -w -c PHKNetworkIP.cpp
gcc -c -o PHKArduinoLightInterface.o PHKArduinoLightInterface.c
gcc -O0 -lcrypto -w -c srp/srp.c -o srp/srp.o
gcc -O0 -lcrypto -w -c srp/cstr.c -o srp/cstr.o
gcc -O0 -lcrypto -w -c srp/t_math.c -o srp/t_math.o
gcc -O0 -lcrypto -w -c srp/srp6_server.c -o srp/srp6_server.o
gcc -O0 -lcrypto -w -c srp/t_conf.c -o srp/t_conf.o
gcc -O0 -lcrypto -w -c srp/t_conv.c -o srp/t_conv.o
gcc -O0 -lcrypto -w -c srp/t_pw.c -o srp/t_pw.o
gcc -O0 -lcrypto -w -c srp/t_misc.c -o srp/t_misc.o
gcc -O0 -lcrypto -w -c srp/t_truerand.c -o srp/t_truerand.o
gcc -O0 -lcrypto -w -c srp/t_read.c -o srp/t_read.o
g++ -O0 -w -c Accessory.cpp
Accessory.cpp: In function ‘void initAccessorySet()’:
Accessory.cpp:22:77: error: too few arguments to function ‘void addInfoServiceToAccessory(Accessory_, std::string, std::string, std::string, std::string, identifyFunction)’
addInfoServiceToAccessory(lightAcc, "Light 1", "ET", "Light", "12345678");
^
In file included from Accessory.cpp:7:0:
PHKAccessory.h:321:6: note: declared here
void addInfoServiceToAccessory(Accessory *acc, string accName, string manufactuerName, string modelName, string serialNumber, identifyFunction identifyCallback);
^
Accessory.cpp:42:68: error: too few arguments to function ‘void addInfoServiceToAccessory(Accessory_, std::string, std::string, std::string, std::string, identifyFunction)’
addInfoServiceToAccessory(fan, "Fan 1", "ET", "Fan", "12345678");
^
In file included from Accessory.cpp:7:0:
PHKAccessory.h:321:6: note: declared here
void addInfoServiceToAccessory(Accessory acc, string accName, string manufactuerName, string modelName, string serialNumber, identifyFunction identifyCallback);
^
makefile:36: recipe for target 'Accessory.o' failed
make: *
* [Accessory.o] Error 1
pi@Raspbian ~/Personal-HomeKit-HAP- $

PHK need D-bus to communicate with avahi-daemon ?

if i change in avahi-daemon.conf "enable-dbus=yes" to "enable-dbus=no" the IPhone don't find the PHK
and there are no error message
i need to now if the PHK use d-bus to communicate with avahi-daemon

Not able to pair the acessory

Hi,

Iam trying to pair but iam stucked with following error what can be the reason anybody know. iam trying this on my ubantu meachine.

venu@venu-desktop:/media/venu/Backup/Personal-HomeKit-HAP-master$ ./PHK reset
Initial Accessory
Serial Port: -1
*** WARNING *** The program 'PHK' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=PHK
Start Connect: 10
Return len 132 for socket 10
Message: POST /pair-setup HTTP/1.1
Host: House\032Light._hap._tcp.local
Content-Length: 6
Content-Type: application/pairing+tlv8

handlePairSeup, 354: State_M1_SRPStartRequest
handlePairSeup, 603, responseBuffer = HTTP/1.1 200 OK
Content-Type: application/pairing+tlv8
Content-Length: 412

����������W2��/�ʾ���r[��R)��n5�/����������8��t�+���Y��`F�@j��IM��8���A/�;��˰tu+�"���� ��oX������

�l1ɨUd�
X���t@#4�I���R������sn��;
���
���b&o0%��#�^��h��_�+w�h���*���%q�J�γ�ڛq�����/��%�Gʧs��rO���"�@zۦ8��[�e���d�|"#����#">H�u[&����y5�Y����!��V[�4r��"t���j��V�����������k�n���������0wX �hE���I;�;���w� �|��4�S���]��, responseLen = 492
Pair Setup Transfered length 492
handlePairSeup, 388: State_M3_SRPVerifyRequest
Password Correct
handlePairSeup, 603, responseBuffer = HTTP/1.1 200 OK
Content-Type: application/pairing+tlv8
Content-Length: 69

���O�d:��t�q�
����#�U���, responseLen = 148
Pair Setup Transfered length 148
handlePairSeup, 438: State_M5_ExchangeRequest
Return len 0 for socket 10
Message: POST /pair-setup HTTP/1.1
Host: House\032Light._hap._tcp.local
Content-Length: 159
Content-Type: application/pairing+tlv8

��Kᆑ(Q2 M���fMZ��kd����&ȝȍ�cI�g
��Z&���)��N�C���0�jg�����kᴺ/�N

����!Mzð�W�Q�!�W��3��m=�2�8�g��oC�Ui���D�2u�IO�<@��X��.��/����|�$��!Jr+c���c��"��єlӜ^�T} y��#[���|;�[�9��

Stop Connect: 10
Start Connect: 11
Return len 165 for socket 11
Message: POST /pair-verify HTTP/1.1
Host: House\032Light._hap._tcp.local
Content-Length: 37
Content-Type: application/pairing+tlv8

���� �[�B�Z֝{���S$��~��<�t�����s
��Z&���)��N�C���0�jg�����kᴺ/�N

����!Mzð�W�Q�!�W��3��m=�2�8�g��oC�Ui���D�2u�IO�<@��X��.��/����|�$��!Jr+c����c����єlӜ^�T} y��#[���|;�[�9��

Start Pair Verify
Pair Verify M1
Pair Verify M3
Verify success
Successfully Connect
send: 0
send: 0
send: 1
Request: GET /accessories HTTP/1.1
Host: House\032Light._hap._tcp.local

Verify successfully!
Receive request: GET /accessories HTTP/1.1
Host: House\032Light._hap._tcp.local

Ask for accessories info
Reply: HTTP/1.1 200 OK
Content-Type: application/hap+json
Content-Length: 666

{"accessories":[{"aid":1,"services":[{"iid":1,"type":"3E","characteristics":[{"value":"Light 1","perms":["pr"],"type":"23","iid":2,"format":"string"},{"value":"ET","perms":["pr"],"type":"20","iid":3,"format":"string"},{"value":"Light","perms":["pr"],"type":"21","iid":4,"format":"string"},{"value":"12345678","perms":["pr"],"type":"30","iid":5,"format":"string"},{"perms":["pw"],"type":"14","iid":6,"format":"bool"}]},{"iid":7,"type":"43","characteristics":[{"value":"Light","perms":["pr"],"type":"23","iid":8,"format":"string"},{"value":50,"minValue":0,"maxValue":100,"minStep":1,"perms":["pr","pw","ev"],"type":"8","iid":9,"unit":"percentage","format":"int"}]}]}]}
send: 1
send: 100000000000000
send: 2
Request: �va�@g ء�$m���Wt��g�R�}
�VY%��S!�#�ߓ�OHwB�)���3����0n^~8�}r,�L�:6�?ۈ��)�B�1��M{�c�ZZ"��R2�y#92+ѥ���a7y�:F�L���a�?=T.���s�������b6�����7��NѼB�M�V���҇�*�����!�
Passed-in data is no-verified!
Return len 0 for socket 11
Message:
Stop Connect: 11

reconnecting after initial pairing

Getting another slight issue....after restarting once my devices are all setup, it seems to struggle to reconnect...

root@raspberrypi:~/PersonalHomeKit-Dynamic# ./PHK
Initial Accessory
Serial Port: -1
*** WARNING *** The program 'PHK' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=PHK
Start Connect: 10
Start Pair Verify
State = 1
Pair Verify M1
State = 3
Pair Verify M3
Successfully Connect
Stop Connect: 10
Start Connect: 11
Start Pair Verify
State = 1
Pair Verify M1
State = 3
Pair Verify M3
Successfully Connect
Stop Connect: 11

during this time, all devices on my phone stay red and i can't control them.
The only way I've got the devices working again is to delete them from the iOS app, delete the controller file, pair the devices again and they work.
Ive verified that the controller file is recreated.
I'm getting the same behaviour on the iOS simulator as well.
IIRC this issue has occurred before but was fixed .

Can't add more than 3 Lights without crash

hi :) (sorry for my poor english i'm french)
this library is awesome it's so amazing to add voice control on my raspberry !!
but i don't understand something, when i try to add more than 3 lights the app crash i don't know why can you help me ?
I use the dyncamic version :)

this is the log :
http://pastebin.com/7g6HCWrM

and my Accessory.cpp :)
http://pastebin.com/eg2JVxzy

if on the "for" line 126 i use
for (int i = 0; i<3; i++)

instead of
for (int i = 0; i<5; i++)

every thing is ok ! i don't know why
thanks in advance !! :)

Randomly control/notify failed (could not authenticate the message)

Update 2: After removing all the libmosquitto related code, it still logs Stop Connect and at the same time authentication error on the phone appears. Still cannot find real causes.

Update: It seems that the issue was caused by my mistaken use of libmosquitto instead of Personal-HomeKit-HAP.

I cross-compile it for my openwrt(mipsel, little-endian) router with bswap header and declaration commented out(or it'll give compilation errors), as well as change the line in PHKNetworkIP.cpp to return !e.c[0]; according to #53 .

It seems to work fine. No issues with pairing. However, when I control it (with the Elgato Eve app), it will fail to renew some characteristics every several times on the phone with this authentication error, but the setValue() callback function is called:
img_7970

This happens more frequently on the power bool characteristic than other ones, though it can update the value only on the server side correctly most of the times.

Here is the log of me turning on and off several times with some of them failed:
randomerrorlog.txt

(Every time authentication error occurs the log will log:

Return len 0 for socket X
Message:
Stop Connect: X

where X is around 10)

Notify value changes

Hi,

I just saw in your ready that you would like to include notifications. I just tried the ask siri to notify when my lights turn on and it actually tried to do it. Unfortunatly it did not work, but it seems it's possible. Is this correct?
If so, do you still plan to include notifications and when? Perhaps I can assist in some way if you give me some pointers on how to achieve this.
Either way thanks you very much!

Roy

Devices disconnect

Hi, running on OS X,
The controller file is now created when i pair with a device...i can switch the device about three times before it disconnects, when that happens it will not reconnect, the only way is to delete the device, pair it again, and then re-pair it, where it will work for approx 3 times again, before disconnecting again.

The contents of the controller file after a device has paired...

83113C1C-CBFC-4F6C-BF6D-F43DF99229CCé£oAã≠Ì
¸�\›lm›ï=ö¯Çwmë˛*HAú:@fi≠

My log....

Mac-Pro:PersonalHomeKit $ ./PHK
Initial Accessory
Serial Port: -1
Start Connect: 6
Start pairing state: 1
Start pairing state: 3
0Start pairing state: 5
Chacha20-Poly1305 on M5 packet check out
Send M6
Start Connect: 7
State = 1
State = 3
Stop Connect: 7
Start Connect: 7
State = 1
State = 3
Stop Connect: 7

Many thanks for your work on this...any ideas?

Compile Error

Hey!
Im get an error when i try to compile PersonalHomeKit on my Raspberry Pi.
Can anyone help me?

Thank you very much.

gcc -O0 -w -o ed25519.o -c ed25519-donna/ed25519.c
In file included from ed25519-donna/ed25519.c:19:0:
ed25519-donna/ed25519-randombytes.h:83:26: fatal error: openssl/rand.h: Datei oder Verzeichnis nicht gefunden
compilation terminated.
makefile:27: recipe for target 'ed25519.o' failed
make: *** [ed25519.o] Error 1

just a query

Is it possible to put avahi source here in project just like srp and chacha libraries?
so that when we run PHK, bonjour service will get set up and the dependency on having avahi daemon is removed? also can we use mDNSresponder source from apple?

Thank you.

PHK not decrypting/verifiying data

On 6S+ iOS9.0.2 (jailbroken, for the matter)
Raspberry Pi B2
Latest github commit.

After sending accessories info, the PHK daemon freezes and does not continue.

Ask for accessories info
Reply: HTTP/1.1 200 OK
Content-Type: application/hap+json
Content-Length: 743

{"accessories":[{"aid":1,"services":[{"iid":1,"type":"3E","characteristics":[{"value":"Light 1","perms":["pr"],"type":"23","iid":2,"format":"string"},{"value":"ET","perms":["pr"],"type":"20","iid":3,"format":"string"},{"value":"Light","perms":["pr"],"type":"21","iid":4,"format":"string"},{"value":"12345678","perms":["pr"],"type":"30","iid":5,"format":"string"},{"perms":["pw"],"type":"14","iid":6,"format":"bool"}]},{"iid":7,"type":"43","characteristics":[{"value":"Light","perms":["pr"],"type":"23","iid":8,"format":"string"},{"value":true,"perms":["pr","pw","ev"],"type":"25","iid":9,"format":"bool"},{"value":50,"minValue":0,"maxValue":100,"minStep":1,"perms":["pr","pw","ev"],"type":"8","iid":10,"unit":"percentage","format":"int"}]}]}]}
send: 1
send: 100000000000000
send: 2
I??|<QW???9??y?3?f??*bA4'0??Z)ߍ??9
Passed-in data is no-verified!

Error G++

Hi,

Is there someone how can help me to solve this issue ?
I'm trying to install al this on a RPi
But when I do a "make", this is the error I get :

root@mainpi:~/Personal-HomeKit-HAP-master# make
g++ -Os -s -w -c main.cpp
In file included from main.cpp:11:0:
PHKNetworkIP.h:82:27: error: ISO C++ forbids initialization of member ‘index’ [-fpermissive]
PHKNetworkIP.h:82:27: error: making ‘index’ static [-fpermissive]
PHKNetworkIP.h:82:27: error: ISO C++ forbids in-class initialization of non-const static member ‘index’
PHKNetworkIP.h:83:18: error: ISO C++ forbids initialization of member ‘data’ [-fpermissive]
PHKNetworkIP.h:83:18: error: making ‘data’ static [-fpermissive]
PHKNetworkIP.h:83:18: error: invalid in-class initialization of static data member of non-integral type

Thanks for the help

Memory access error when trying to pair

I have cloned PHK, fixed the .h file initialization errors by moving the inits to constructors.
Could then compile and start PHK, I am seeing the device I added in the HomeKit demo app.
When tapping it and confirming the pairing warnning I get a memory access error (german: "Speicherzugriffsfehler"):

pi@rpi-home ~/PersonalHomeKit $ ./PHK
*** WARNING *** The program 'PHK' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=PHK>
Start Connect: 10
Speicherzugriffsfehler

I have added logs and it doesn't reach the first one of them:

void *connectionLoop(void *argument) {
    int subSocket = *(int*)argument;ssize_t len;
    if (subSocket >= 0) {
        printf("Start Connect: %d\n", subSocket);

        do {
            char *buffer = new char[4096];
printf("before read");
            len = read(*(int*)argument, buffer, 4096);
printf("after read");
            PHKNetworkMessage msg(buffer);
            if (len > 0) {
                if (!strcmp(msg.directory, "pair-setup")){

                    /*
                     * The processo f pair-setup
                     */

printf("before handlePairsetup");
                    handlePairSeup(*(int*)argument, buffer);

                }

I wonder if this could be a compiler issue?

Using a Raspberry Pi, this is what the compiler says:

pi@rpi-home ~/PersonalHomeKit $ make clean all
rm -rf ./*.o Chacha20/*.o curve25519/*.o ed25519-donna/*.o poly1305-opt-master/*.o rfc6234-master/*.o srp/*.o PHK
gcc -O3 -w -o chacha20.o -c Chacha20/chacha20_simple.c
gcc -O3 -w -o curve25519.o -c curve25519/curve25519-donna.c
gcc -O3 -w -o ed25519.o -c ed25519-donna/ed25519.c
gcc -O3 -w -o poly1305.o -c poly1305-opt-master/poly1305.c
gcc -O3 -w -c rfc6234-master/hkdf.c -o rfc6234-master/hkdf.o
gcc -O3 -w -c rfc6234-master/hmac.c -o rfc6234-master/hmac.o
gcc -O3 -w -c rfc6234-master/sha.c -o rfc6234-master/sha.o
g++ -O3 -w -c main.cpp
g++ -O3 -w -c PHKAccessory.cpp
g++ -O3 -w -c PHKControllerRecord.cpp
g++ -O3 -w -c PHKNetworkIP.cpp
gcc    -c -o PHKArduinoLightInterface.o PHKArduinoLightInterface.c
gcc -O3 -lcrypto -w -c srp/srp.c -o srp/srp.o
gcc -O3 -lcrypto -w -c srp/cstr.c -o srp/cstr.o
gcc -O3 -lcrypto -w -c srp/t_math.c -o srp/t_math.o
gcc -O3 -lcrypto -w -c srp/srp6_server.c -o srp/srp6_server.o
gcc -O3 -lcrypto -w -c srp/t_conf.c -o srp/t_conf.o
gcc -O3 -lcrypto -w -c srp/t_conv.c -o srp/t_conv.o
gcc -O3 -lcrypto -w -c srp/t_pw.c -o srp/t_pw.o
gcc -O3 -lcrypto -w -c srp/t_misc.c -o srp/t_misc.o
gcc -O3 -lcrypto -w -c srp/t_truerand.c -o srp/t_truerand.o
gcc -O3 -lcrypto -w -c srp/t_read.c -o srp/t_read.o
g++ -O3 -o PHK chacha20.o curve25519.o ed25519.o poly1305.o rfc6234-master/hkdf.o rfc6234-master/hmac.o rfc6234-master/sha.o main.o PHKAccessory.o PHKControllerRecord.o PHKNetworkIP.o PHKArduinoLightInterface.o srp/srp.o srp/cstr.o srp/t_math.o srp/srp6_server.o srp/t_conf.o srp/t_conv.o srp/t_pw.o srp/t_misc.o srp/t_truerand.o srp/t_read.o -lssl -lcrypto -ldl -pthread -ldns_sd

Latest commit does not compile

root@raspberrypi:/PersonalHomeKit# make
gcc -O0 -w -o chacha20.o -c Chacha20/chacha20_simple.c
gcc -O0 -w -o curve25519.o -c curve25519/curve25519-donna.c
gcc -O0 -w -o ed25519.o -c ed25519-donna/ed25519.c
gcc -O0 -w -o poly1305.o -c poly1305-opt-master/poly1305.c
gcc -O0 -w -c rfc6234-master/hkdf.c -o rfc6234-master/hkdf.o
gcc -O0 -w -c rfc6234-master/hmac.c -o rfc6234-master/hmac.o
gcc -O0 -w -c rfc6234-master/sha.c -o rfc6234-master/sha.o
g++ -O0 -w -c main.cpp
g++ -O0 -w -c PHKAccessory.cpp
In file included from PHKAccessory.cpp:9:0:
PHKAccessory.h:53:5: error: expected ‘}’ before ‘charType_ipCameraStop’
charType_ipCameraStop = 0x17,
^
PHKAccessory.h:53:5: error: typedef ‘charType_ipCameraStop’ is initialized (use decltype instead)
PHKAccessory.h:54:5: error: typedef ‘charType_lockControlPoint’ is initialized (use decltype instead)
charType_lockControlPoint = 0x19,
^
PHKAccessory.h:55:5: error: typedef ‘charType_lockAutoTimeout’ is initialized (use decltype instead)
charType_lockAutoTimeout = 0x1A,
^
PHKAccessory.h:56:5: error: typedef ‘charType_lockLastAction’ is initialized (use decltype instead)
charType_lockLastAction = 0x1C,
^
PHKAccessory.h:57:5: error: typedef ‘charType_lockCurrentState’ is initialized (use decltype instead)
charType_lockCurrentState = 0x1D,
^
PHKAccessory.h:58:5: error: typedef ‘charType_lockTargetState’ is initialized (use decltype instead)
charType_lockTargetState = 0x1E,
^
PHKAccessory.h:59:5: error: typedef ‘charType_logs’ is initialized (use decltype instead)
charType_logs = 0x1F,
^
PHKAccessory.h:60:5: error: typedef ‘charType_manufactuer’ is initialized (use decltype instead)
charType_manufactuer = 0x20,
^
PHKAccessory.h:61:5: error: typedef ‘charType_modelName’ is initialized (use decltype instead)
charType_modelName = 0x21,
^
PHKAccessory.h:62:5: error: typedef ‘charType_motionDetect’ is initialized (use decltype instead)
charType_motionDetect = 0x22,
^
PHKAccessory.h:63:5: error: typedef ‘charType_serviceName’ is initialized (use decltype instead)
charType_serviceName = 0x23,
^
PHKAccessory.h:64:5: error: typedef ‘charType_obstruction’ is initialized (use decltype instead)
charType_obstruction = 0x24,
^
PHKAccessory.h:65:5: error: typedef ‘charType_on’ is initialized (use decltype instead)
charType_on = 0x25,
^
PHKAccessory.h:66:5: error: typedef ‘charType_outletInUse’ is initialized (use decltype instead)
charType_outletInUse = 0x26,
^
PHKAccessory.h:67:5: error: typedef ‘charType_outputVolume’ is initialized (use decltype instead)
charType_outputVolume = 0x27,
^
PHKAccessory.h:68:5: error: typedef ‘charType_rotationDirection’ is initialized (use decltype instead)
charType_rotationDirection = 0x28,
^
PHKAccessory.h:69:5: error: typedef ‘charType_rotationSpeed’ is initialized (use decltype instead)
charType_rotationSpeed = 0x29,
^
PHKAccessory.h:70:5: error: typedef ‘charType_rtcpExtProp’ is initialized (use decltype instead)
charType_rtcpExtProp = 0x2A,
^
PHKAccessory.h:71:5: error: typedef ‘charType_rtcpVideoPayload’ is initialized (use decltype instead)
charType_rtcpVideoPayload = 0x2B,
^
PHKAccessory.h:72:5: error: typedef ‘charType_rtcpAudioPayload’ is initialized (use decltype instead)
charType_rtcpAudioPayload = 0x2C,
^
PHKAccessory.h:73:5: error: typedef ‘charType_rtcpAudioClock’ is initialized (use decltype instead)
charType_rtcpAudioClock = 0x2D,
^
PHKAccessory.h:74:5: error: typedef ‘charType_rtcpProtocol’ is initialized (use decltype instead)
charType_rtcpProtocol = 0x2E
^
PHKAccessory.h:104:1: error: expected declaration before ‘}’ token
} charType;
^
makefile:36: recipe for target 'PHKAccessory.o' failed
make: *** [PHKAccessory.o] Error 1
root@raspberrypi:
/PersonalHomeKit# make
g++ -O0 -w -c PHKAccessory.cpp
In file included from PHKAccessory.cpp:9:0:
PHKAccessory.h:53:5: error: expected ‘}’ before ‘charType_ipCameraStop’
charType_ipCameraStop = 0x17,
^
PHKAccessory.h:53:5: error: typedef ‘charType_ipCameraStop’ is initialized (use decltype instead)
PHKAccessory.h:54:5: error: typedef ‘charType_lockControlPoint’ is initialized (use decltype instead)
charType_lockControlPoint = 0x19,
^
PHKAccessory.h:55:5: error: typedef ‘charType_lockAutoTimeout’ is initialized (use decltype instead)
charType_lockAutoTimeout = 0x1A,
^
PHKAccessory.h:56:5: error: typedef ‘charType_lockLastAction’ is initialized (use decltype instead)
charType_lockLastAction = 0x1C,
^
PHKAccessory.h:57:5: error: typedef ‘charType_lockCurrentState’ is initialized (use decltype instead)
charType_lockCurrentState = 0x1D,
^
PHKAccessory.h:58:5: error: typedef ‘charType_lockTargetState’ is initialized (use decltype instead)
charType_lockTargetState = 0x1E,
^
PHKAccessory.h:59:5: error: typedef ‘charType_logs’ is initialized (use decltype instead)
charType_logs = 0x1F,
^
PHKAccessory.h:60:5: error: typedef ‘charType_manufactuer’ is initialized (use decltype instead)
charType_manufactuer = 0x20,
^
PHKAccessory.h:61:5: error: typedef ‘charType_modelName’ is initialized (use decltype instead)
charType_modelName = 0x21,
^
PHKAccessory.h:62:5: error: typedef ‘charType_motionDetect’ is initialized (use decltype instead)
charType_motionDetect = 0x22,
^
PHKAccessory.h:63:5: error: typedef ‘charType_serviceName’ is initialized (use decltype instead)
charType_serviceName = 0x23,
^
PHKAccessory.h:64:5: error: typedef ‘charType_obstruction’ is initialized (use decltype instead)
charType_obstruction = 0x24,
^
PHKAccessory.h:65:5: error: typedef ‘charType_on’ is initialized (use decltype instead)
charType_on = 0x25,
^
PHKAccessory.h:66:5: error: typedef ‘charType_outletInUse’ is initialized (use decltype instead)
charType_outletInUse = 0x26,
^
PHKAccessory.h:67:5: error: typedef ‘charType_outputVolume’ is initialized (use decltype instead)
charType_outputVolume = 0x27,
^
PHKAccessory.h:68:5: error: typedef ‘charType_rotationDirection’ is initialized (use decltype instead)
charType_rotationDirection = 0x28,
^
PHKAccessory.h:69:5: error: typedef ‘charType_rotationSpeed’ is initialized (use decltype instead)
charType_rotationSpeed = 0x29,
^
PHKAccessory.h:70:5: error: typedef ‘charType_rtcpExtProp’ is initialized (use decltype instead)
charType_rtcpExtProp = 0x2A,
^
PHKAccessory.h:71:5: error: typedef ‘charType_rtcpVideoPayload’ is initialized (use decltype instead)
charType_rtcpVideoPayload = 0x2B,
^
PHKAccessory.h:72:5: error: typedef ‘charType_rtcpAudioPayload’ is initialized (use decltype instead)
charType_rtcpAudioPayload = 0x2C,
^
PHKAccessory.h:73:5: error: typedef ‘charType_rtcpAudioClock’ is initialized (use decltype instead)
charType_rtcpAudioClock = 0x2D,
^
PHKAccessory.h:74:5: error: typedef ‘charType_rtcpProtocol’ is initialized (use decltype instead)
charType_rtcpProtocol = 0x2E
^
PHKAccessory.h:104:1: error: expected declaration before ‘}’ token
} charType;
^
makefile:36: recipe for target 'PHKAccessory.o' failed
make: *** [PHKAccessory.o] Error 1
root@raspberrypi:~/PersonalHomeKit#

byteswap.h and OSX

byteswap.h is not portable and is not included in OSX so the code does not compile on OS X anymore.

make error with Dynamic fork

Can i use the fan+light accessory with this dynamic fork? or have i misunderstood.
Im getting errors if i make with fan+light instead of the default light.....

root@raspberrypi:/PersonalHomeKit-Dynamic# make
gcc -O0 -w -o chacha20.o -c Chacha20/chacha20_simple.c
gcc -O0 -w -o curve25519.o -c curve25519/curve25519-donna.c
gcc -O0 -w -o ed25519.o -c ed25519-donna/ed25519.c
gcc -O0 -w -o poly1305.o -c poly1305-opt-master/poly1305.c
gcc -O0 -w -c rfc6234-master/hkdf.c -o rfc6234-master/hkdf.o
gcc -O0 -w -c rfc6234-master/hmac.c -o rfc6234-master/hmac.o
gcc -O0 -w -c rfc6234-master/sha.c -o rfc6234-master/sha.o
g++ -O0 -w -c main.cpp
g++ -O0 -w -c PHKAccessory.cpp
g++ -O0 -w -c PHKControllerRecord.cpp
g++ -O0 -w -c PHKNetworkIP.cpp
gcc -c -o PHKArduinoLightInterface.o PHKArduinoLightInterface.c
gcc -O0 -lcrypto -w -c srp/srp.c -o srp/srp.o
gcc -O0 -lcrypto -w -c srp/cstr.c -o srp/cstr.o
gcc -O0 -lcrypto -w -c srp/t_math.c -o srp/t_math.o
gcc -O0 -lcrypto -w -c srp/srp6_server.c -o srp/srp6_server.o
gcc -O0 -lcrypto -w -c srp/t_conf.c -o srp/t_conf.o
gcc -O0 -lcrypto -w -c srp/t_conv.c -o srp/t_conv.o
gcc -O0 -lcrypto -w -c srp/t_pw.c -o srp/t_pw.o
gcc -O0 -lcrypto -w -c srp/t_misc.c -o srp/t_misc.o
gcc -O0 -lcrypto -w -c srp/t_truerand.c -o srp/t_truerand.o
gcc -O0 -lcrypto -w -c srp/t_read.c -o srp/t_read.o
g++ -O0 -w -c Accessory.cpp
Accessory.cpp: In constructor ‘lightPowerState::lightPowerState(int&)’:
Accessory.cpp:15:106: error: no matching function for call to ‘boolCharacteristics::boolCharacteristics(int&, charType, int)’
lightPowerState(int &index): boolCharacteristics(index, charType_on, premission_read|premission_write){}
^
Accessory.cpp:15:106: note: candidates are:
In file included from Accessory.cpp:7:0:
PHKAccessory.h:137:5: note: boolCharacteristics::boolCharacteristics(short unsigned int, int)
boolCharacteristics(unsigned short _type, int _premission): characteristics(_type, _premission) {}
^
PHKAccessory.h:137:5: note: candidate expects 2 arguments, 3 provided
PHKAccessory.h:133:7: note: boolCharacteristics::boolCharacteristics(const boolCharacteristics&)
class boolCharacteristics: public characteristics {
^
PHKAccessory.h:133:7: note: candidate expects 1 argument, 3 provided
Accessory.cpp: In constructor ‘lightBrightness::lightBrightness(int&)’:
Accessory.cpp:35:140: error: no matching function for call to ‘intCharacteristics::intCharacteristics(int&, charType, int, int, int, int, unit)’
lightBrightness(int &index):intCharacteristics(index, charType_brightness, premission_read|premission_write, 0, 100, 1, unit_percentage) {}
^
Accessory.cpp:35:140: note: candidates are:
In file included from Accessory.cpp:7:0:
PHKAccessory.h:176:5: note: intCharacteristics::intCharacteristics(short unsigned int, int, int, int, int, unit)
intCharacteristics(unsigned short _type, int _premission, int minVal, int maxVal, int step, unit charUnit): characteristics(_type, _premission), _minVal(minVal), _maxVal(maxVal), _step(step), _unit(charUnit) {
^
PHKAccessory.h:176:5: note: candidate expects 6 arguments, 7 provided
PHKAccessory.h:170:7: note: intCharacteristics::intCharacteristics(const intCharacteristics&)
class intCharacteristics: public characteristics {
^
PHKAccessory.h:170:7: note: candidate expects 1 argument, 7 provided
Accessory.cpp: In constructor ‘lightService::lightService(int&)’:
Accessory.cpp:49:102: error: no matching function for call to ‘Service::Service(int&, charType)’
serviceName(index, charType_serviceName, premission_read, 0), powerState(index), brightness(index)
^
Accessory.cpp:49:102: note: candidates are:
In file included from Accessory.cpp:7:0:
PHKAccessory.h:213:5: note: Service::Service(int)
Service(int _uuid): uuid(_uuid) {}
^
PHKAccessory.h:213:5: note: candidate expects 1 argument, 2 provided
PHKAccessory.h:209:7: note: Service::Service(const Service&)
class Service {
^
PHKAccessory.h:209:7: note: candidate expects 1 argument, 2 provided
Accessory.cpp:49:102: error: no matching function for call to ‘stringCharacteristics::stringCharacteristics(int&, charType, , int)’
serviceName(index, charType_serviceName, premission_read, 0), powerState(index), brightness(index)
^
Accessory.cpp:49:102: note: candidates are:
In file included from Accessory.cpp:7:0:
PHKAccessory.h:198:5: note: stringCharacteristics::stringCharacteristics(short unsigned int, int, short unsigned int)
stringCharacteristics(unsigned short _type, int _premission, unsigned short _maxLen): characteristics(_type, _premission), maxLen(_maxLen) {}
^
PHKAccessory.h:198:5: note: candidate expects 3 arguments, 4 provided
PHKAccessory.h:193:7: note: stringCharacteristics::stringCharacteristics(const stringCharacteristics&)
class stringCharacteristics: public characteristics {
^
PHKAccessory.h:193:7: note: candidate expects 1 argument, 4 provided
Accessory.cpp:51:30: error: ‘deviceName’ was not declared in this scope
serviceName.setValue(deviceName);
^
Accessory.cpp: At global scope:
Accessory.cpp:73:5: error: ‘infoService’ does not name a type
infoService info;
^
Accessory.cpp: In constructor ‘MainAccessory::MainAccessory(int)’:
Accessory.cpp:77:5: error: class ‘MainAccessory’ does not have any field named ‘info’
info(numberOfInstance), light(numberOfInstance) {}
^
Accessory.cpp:77:51: error: no matching function for call to ‘Accessory::Accessory(int&)’
info(numberOfInstance), light(numberOfInstance) {}
^
Accessory.cpp:77:51: note: candidates are:
In file included from Accessory.cpp:7:0:
PHKAccessory.h:254:5: note: Accessory::Accessory()
Accessory() {}
^
PHKAccessory.h:254:5: note: candidate expects 0 arguments, 1 provided
PHKAccessory.h:219:7: note: Accessory::Accessory(const Accessory&)
class Accessory {
^
PHKAccessory.h:219:7: note: no known conversion for argument 1 from ‘int’ to ‘const Accessory&’
Accessory.cpp: In member function ‘virtual Service* MainAccessory::serviceAtIndex(int)’:
Accessory.cpp:82:25: error: ‘info’ was not declared in this scope
return &info;
^
Accessory.cpp: In constructor ‘fanPowerState::fanPowerState(int&)’:
Accessory.cpp:92:104: error: no matching function for call to ‘boolCharacteristics::boolCharacteristics(int&, charType, int)’
fanPowerState(int &index): boolCharacteristics(index, charType_on, premission_read|premission_write){}
^
Accessory.cpp:92:104: note: candidates are:
In file included from Accessory.cpp:7:0:
PHKAccessory.h:137:5: note: boolCharacteristics::boolCharacteristics(short unsigned int, int)
boolCharacteristics(unsigned short _type, int _premission): characteristics(_type, _premission) {}
^
PHKAccessory.h:137:5: note: candidate expects 2 arguments, 3 provided
PHKAccessory.h:133:7: note: boolCharacteristics::boolCharacteristics(const boolCharacteristics&)
class boolCharacteristics: public characteristics {
^
PHKAccessory.h:133:7: note: candidate expects 1 argument, 3 provided
Accessory.cpp: In constructor ‘fanSpeed::fanSpeed(int&)’:
Accessory.cpp:112:133: error: no matching function for call to ‘intCharacteristics::intCharacteristics(int&, charType, int, int, int, int, unit)’
fanSpeed(int &index):intCharacteristics(index, charType_brightness, premission_read|premission_write, 0, 100, 1, unit_percentage) {}
^
Accessory.cpp:112:133: note: candidates are:
In file included from Accessory.cpp:7:0:
PHKAccessory.h:176:5: note: intCharacteristics::intCharacteristics(short unsigned int, int, int, int, int, unit)
intCharacteristics(unsigned short _type, int _premission, int minVal, int maxVal, int step, unit charUnit): characteristics(_type, _premission), _minVal(minVal), _maxVal(maxVal), _step(step), _unit(charUnit) {
^
PHKAccessory.h:176:5: note: candidate expects 6 arguments, 7 provided
PHKAccessory.h:170:7: note: intCharacteristics::intCharacteristics(const intCharacteristics&)
class intCharacteristics: public characteristics {
^
PHKAccessory.h:170:7: note: candidate expects 1 argument, 7 provided
Accessory.cpp: In constructor ‘fanService::fanService(int&)’:
Accessory.cpp:126:97: error: no matching function for call to ‘Service::Service(int&, charType)’
serviceName(index, charType_serviceName, premission_read, 0), powerState(index), speed(index)
^
Accessory.cpp:126:97: note: candidates are:
In file included from Accessory.cpp:7:0:
PHKAccessory.h:213:5: note: Service::Service(int)
Service(int _uuid): uuid(_uuid) {}
^
PHKAccessory.h:213:5: note: candidate expects 1 argument, 2 provided
PHKAccessory.h:209:7: note: Service::Service(const Service&)
class Service {
^
PHKAccessory.h:209:7: note: candidate expects 1 argument, 2 provided
Accessory.cpp:126:97: error: no matching function for call to ‘stringCharacteristics::stringCharacteristics(int&, charType, , int)’
serviceName(index, charType_serviceName, premission_read, 0), powerState(index), speed(index)
^
Accessory.cpp:126:97: note: candidates are:
In file included from Accessory.cpp:7:0:
PHKAccessory.h:198:5: note: stringCharacteristics::stringCharacteristics(short unsigned int, int, short unsigned int)
stringCharacteristics(unsigned short _type, int _premission, unsigned short _maxLen): characteristics(_type, _premission), maxLen(_maxLen) {}
^
PHKAccessory.h:198:5: note: candidate expects 3 arguments, 4 provided
PHKAccessory.h:193:7: note: stringCharacteristics::stringCharacteristics(const stringCharacteristics&)
class stringCharacteristics: public characteristics {
^
PHKAccessory.h:193:7: note: candidate expects 1 argument, 4 provided
Accessory.cpp: At global scope:
Accessory.cpp:147:5: error: ‘infoService’ does not name a type
infoService info;
^
Accessory.cpp: In constructor ‘FanAccessory::FanAccessory(int)’:
Accessory.cpp:150:44: error: class ‘FanAccessory’ does not have any field named ‘info’
FanAccessory(int aid): Accessory(aid), info(numberOfInstance), fan(numberOfInstance) {}
^
Accessory.cpp:150:88: error: no matching function for call to ‘Accessory::Accessory(int&)’
FanAccessory(int aid): Accessory(aid), info(numberOfInstance), fan(numberOfInstance) {}
^
Accessory.cpp:150:88: note: candidates are:
In file included from Accessory.cpp:7:0:
PHKAccessory.h:254:5: note: Accessory::Accessory()
Accessory() {}
^
PHKAccessory.h:254:5: note: candidate expects 0 arguments, 1 provided
PHKAccessory.h:219:7: note: Accessory::Accessory(const Accessory&)
class Accessory {
^
PHKAccessory.h:219:7: note: no known conversion for argument 1 from ‘int’ to ‘const Accessory&’
Accessory.cpp: In member function ‘virtual Service* FanAccessory::serviceAtIndex(int)’:
Accessory.cpp:155:25: error: ‘info’ was not declared in this scope
return &info;
^
makefile:36: recipe for target 'Accessory.o' failed
make: *** [Accessory.o] Error 1
root@raspberrypi:
/PersonalHomeKit-Dynamic#

cannot discover accessories

when you pair for the first time then the accessories are getting detected but next time after pair verify, client disconnects. I am using HAT to test my accessories.

Relocations in generic ELF (EM: 8)

Hello @etwmc I did some modifications to the code but I realized it didn't compile, then I rollbacked and realized the repository as is gives an strange message, have you seen something similar?, the error appears when trying to link:

++ -Os -s -o PHK chacha20.o curve25519.o ed25519.o poly1305.o rfc6234-master/hkdf.o rfc6234-master/hmac.o rfc6234-master/sha.o main.o PHKAccessory.o PHKControllerRecord.o PHKNetworkIP.o PHKArduinoLightInterface.o srp/srp.o srp/cstr.o srp/t_math.o srp/srp6_server.o srp/t_conf.o srp/t_conv.o srp/t_pw.o srp/t_misc.o srp/t_truerand.o srp/t_read.o Accessory.o -lssl -lcrypto -ldl -lpthread -ldns_sd

/opt/rh/devtoolset-2/root/usr/libexec/gcc/i686-redhat-linux/4.8.2/ld: chacha20.o: Relocations in generic ELF (EM: 8)
/opt/rh/devtoolset-2/root/usr/libexec/gcc/i686-redhat-linux/4.8.2/ld: chacha20.o: Relocations in generic ELF (EM: 8)
chacha20.o: could not read symbols: File in wrong format

make error (Dynamic)

Do i need to do anything different with this Dynamic fork as I'm getting errors?
Excellent progress BTW.

root@raspberrypi:~/PersonalHomeKit# make
g++ -O0 -w -c PHKAccessory.cpp
In file included from PHKAccessory.cpp:9:0:
PHKAccessory.h: In member function ‘bool Accessory::removeService(Service_)’:
PHKAccessory.h:234:19: error: ‘it’ does not name a type
for (auto it = _services.begin(); it != _services.end(); it++) {
^
PHKAccessory.h:234:43: error: expected ‘;’ before ‘it’
for (auto it = _services.begin(); it != services.end(); it++) {
^
PHKAccessory.h:234:43: error: ‘it’ was not declared in this scope
PHKAccessory.h: In member function ‘bool Accessory::removeCharacteristics(characteristics
)’:
PHKAccessory.h:244:19: error: ‘it’ does not name a type
for (auto it = _services.begin(); it != _services.end(); it++) {
^
PHKAccessory.h:244:43: error: expected ‘;’ before ‘it’
for (auto it = _services.begin(); it != _services.end(); it++) {
^
PHKAccessory.h:244:43: error: ‘it’ was not declared in this scope
PHKAccessory.h:245:23: error: ‘jt’ does not name a type
for (auto jt = (_it)->_characteristics.begin(); jt != (_it)->_characteristics.end(); jt++) {
^
PHKAccessory.h:245:61: error: expected ‘;’ before ‘jt’
for (auto jt = (_it)->_characteristics.begin(); jt != (_it)->_characteristics.end(); jt++) {
^
PHKAccessory.h:245:61: error: ‘jt’ was not declared in this scope
PHKAccessory.h: In member function ‘Service* Accessory::serviceAtIndex(int)’:
PHKAccessory.h:257:19: error: ‘it’ does not name a type
for (auto it = _services.begin(); it != _services.end(); it++) {
^
PHKAccessory.h:257:43: error: expected ‘;’ before ‘it’
for (auto it = _services.begin(); it != _services.end(); it++) {
^
PHKAccessory.h:257:43: error: ‘it’ was not declared in this scope
PHKAccessory.h: In member function ‘characteristics* Accessory::characteristicsAtIndex(int)’:
PHKAccessory.h:265:19: error: ‘it’ does not name a type
for (auto it = _services.begin(); it != _services.end(); it++) {
^
PHKAccessory.h:265:43: error: expected ‘;’ before ‘it’
for (auto it = _services.begin(); it != _services.end(); it++) {
^
PHKAccessory.h:265:43: error: ‘it’ was not declared in this scope
PHKAccessory.h:266:23: error: ‘jt’ does not name a type
for (auto jt = (_it)->_characteristics.begin(); jt != (_it)->_characteristics.end(); jt++) {
^
PHKAccessory.h:266:61: error: expected ‘;’ before ‘jt’
for (auto jt = (_it)->_characteristics.begin(); jt != (_it)->_characteristics.end(); jt++) {
^
PHKAccessory.h:266:61: error: ‘jt’ was not declared in this scope
PHKAccessory.h: In member function ‘Accessory* AccessorySet::accessoryAtIndex(int)’:
PHKAccessory.h:285:19: error: ‘it’ does not name a type
for (auto it = _accessories.begin(); it != _accessories.end(); it++) {
^
PHKAccessory.h:285:46: error: expected ‘;’ before ‘it’
for (auto it = _accessories.begin(); it != accessories.end(); it++) {
^
PHKAccessory.h:285:46: error: ‘it’ was not declared in this scope
PHKAccessory.h: In member function ‘bool AccessorySet::removeAccessory(Accessory
)’:
PHKAccessory.h:298:19: error: ‘it’ does not name a type
for (auto it = _accessories.begin(); it != _accessories.end(); it++) {
^
PHKAccessory.h:298:46: error: expected ‘;’ before ‘it’
for (auto it = _accessories.begin(); it != accessories.end(); it++) {
^
PHKAccessory.h:298:46: error: ‘it’ was not declared in this scope
makefile:36: recipe for target 'PHKAccessory.o' failed
make: *
* [PHKAccessory.o] Error 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.