Git Product home page Git Product logo

esphap'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

esphap's Issues

Ethernet connection support?

I was wondering if ESPHap supports wired ethernet connections instead of wifi. I'm trying out Arduino HAP libraries on a Silicognition wESP32 PoE board but haven't come across ethernet-based Homekit code examples.

Device not compatible

I've tested the lastest version. When I try to add the new device to Homekit it won't show up but gives me an error. Device not compatible.

Commit c8242dc

Log:

HomeKit: WiFiServer receives a new client (current 0, max 4)

-> Is this the default? I also seen logs with max 8?

HomeKit: Got new client connection: local 192.168.2.145:5556, remote 192.168.2.191:59027
HomeKit: [Client 1073705188] Got client content from the cache 0
HomeKit: [Client 1073705188] new client accepted
HomeKit: [Client 1073705188] Pair Setup Step 1/3
HomeKit: [Client 1073705188] Pair Setup Step 2/3
HomeKit: [Client 1073705188] Computing SRP shared secret
HomeKit: [Client 1073705188] Verifying peer's proof
HomeKit: [Client 1073705188] Generating own proof
HomeKit: [Client 1073705188] Pair Setup Step 3/3
HomeKit: Added pairing with 09913711-047C-421A-ABCD-6E69DA74037B
HomeKit: Free saved_preinit_pairing_context
HomeKit: [Client 1073705188] Successfully paired
HomeKit: [Client 1073705188] Disconnected!
HomeKit: [Client 1073705188] Closing client connection
HomeKit: [Client 0] client content free
HomeKit: WiFiServer receives a new client (current 0, max 4)
HomeKit: Got new client connection: local 192.168.2.145:5556, remote 192.168.2.191:59029
HomeKit: [Client 1073706532] Got client content from the cache 0
HomeKit: [Client 1073706532] new client accepted
HomeKit: [Client 1073706532] Pair Verify Step 1/2
HomeKit: Free heap: 21224
HomeKit: [Client 1073706532] Pair Verify Step 2/2
HomeKit: [Client 1073706532] Found pairing with 09913711-047C-421A-ABCD-6E69DA74037B
HomeKit: [Client 1073706532] Verification successful, secure session established
HomeKit: Free heap: 21160
HomeKit: [Client 1073706532] Get Accessories
HomeKit: [Client 1073706532] Disconnected!
HomeKit: [Client 1073706532] Closing client connection
HomeKit: [Client 0] client content free

Seems to me that the paring is successful, but the device is not in Homekit accepted.

v2 Higer bandwidth is set.

If you need more info, pls let me know.

Question on notifying HAP

I see 2 different functions that appear to notify HAP.: (homekit_characteristic_notify & HAP_NOTIFY_CHANGES).

Is there a preferred use for each of these? Thanks.

Example for a Garagedoor

first of all: thanks for that great piece of software! i tried some examples and all of them work really well.

when i was looking for a garagedoor-example i was not able to find one :-(
i tried to build one by myself but failed. so is there anyone out there who could show me how to get an garagedoor to wirk?

Can't compile code examples which include hapfilestorage.hpp

Hi,
thanks for your great work, really appreciated!
One problem though:
whenever one of your examples includes hapfilestorage\hapfilestorage.hpp or hapweb\hap_webserver.hpp (like in EspHapAdvancedLed.ino), I get

Arduino: 1.8.13 (Mac OS X), Board: "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None"
...
Alternatives for hapfilestorage\hapfilestorage.hpp: []
EspHapAdvancedDimmableLed:16:45: fatal error: hapfilestorage\hapfilestorage.hpp: No such file or directory
ResolveLibrary(hapfilestorage\hapfilestorage.hpp)
compilation terminated.
-> candidates: []
Bibliothek SPIFFS in Version 1.0 im Ordner: /Users/bob/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/SPIFFS wird verwendet
Bibliothek FS in Version 1.0 im Ordner: /Users/bob/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/FS wird verwendet
Bibliothek ESPHap in Version 1.0 im Ordner: /Users/bob/arduino/libraries/ESPHap wird verwendet
exit status 1
hapfilestorage\hapfilestorage.hpp: No such file or directory

Bildschirmfoto 2020-11-10 um 20 04 28

I checked out the ESPHap master and installed it properly within my library folder (working on macOS):

Bildschirmfoto 2020-11-10 um 20 32 34

I am really clueless here, any help would be great.

example for PM10 / PM2.5 device

I could ask for example with a PM10 or PM2.5 air pollution measuring device.
I tried to do it based on to the EspHap_AirQuality_MQ135 example but it keeps showing me Carbon Dioxide Level(ppm) instead of PM10 level(ug/m3) on my iPhone.

WiFi Config at Runtime

It seems this library doesn’t include a way of configuring the WiFi network at runtime using the web server method that others do. Has anyone integrated a library for this successfully? I’m having trouble getting any of them to work.

Multiple wifi

Hi,

Thanks for this amazing library

I have 2 questions:

  • It is possible to define 2 or 3 wifi so i can move with my homekit object ?
  • I have an object with a strip led, the integration with homekit works fine. BTW i would like to add some leds FX, so is there a way to add a list of "actions" or something like that ?

Error compiling with #define HOMEKIT_DUBUG on ESP32

Getting the following error when compiling with #define HOMEKIT_DUBUG on ESP32 using c822ae8.
...
Arduino: 1.8.13 (Mac OS X), Board: "WEMOS D1 MINI ESP32, 80MHz, Default, 240MHz (WiFi/BT), 921600"

In file included from /Users/evan/Documents/Arduino/libraries/ESPHap/server.c:41:0:
/Users/evan/Documents/Arduino/libraries/ESPHap/server.c: In function 'homekit_server_on_update_characteristics':
/Users/evan/Documents/Arduino/libraries/ESPHap/debug.h:19:29: error: expected ';' before 'printf'
#define DEBUG(message, ...) printf(">>> %s: " message "\n", func, ##VA_ARGS)
^
/Users/evan/Documents/Arduino/libraries/ESPHap/debug.h:39:23: note: in expansion of macro 'DEBUG'
#define DEBUG_HEAP() DEBUG("Free heap: %d", esp_get_free_heap_size());
^
/Users/evan/Documents/Arduino/libraries/ESPHap/server.c:2258:5: note: in expansion of macro 'DEBUG_HEAP'
DEBUG_HEAP();
^
Multiple libraries were found for "WiFi.h"
Used: /Users/evan/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5/libraries/WiFi
Not used: /Applications/Arduino.app/Contents/Java/libraries/WiFi
exit status 1
Error compiling for board WEMOS D1 MINI ESP32.

Window Covering - Roller Blind example

I am interested in converting my existing roller blinds from MQTT/Homebridge to ESPHap.

Is it difficult to add the windowCovering type to ESPHap? I would like to try adding my existing code for stepper control and blind calibration to one of your examples.

Update Characteristics some time failure and didn't received by device

Based on Window Covering Blind Example
I am seeing intermittent callback failure. In some cases, I am getting a callback, but the data passed fails to pass a comparison for characteristic type. Other times sending a command from the Home app doesn't generate a callback. I do get this output:

10:57:52.159 -> >>> HomeKit: [Client 1073701940] Got 191 incomming data, encrypted is
10:57:52.159 -> >>> HomeKit: [Client 1073701940] Update Characteristics
but it is not triggering a callback.

Here is my sketch:

wolfssl.h: No such file or directory

i got extract either [wolfSSL_3_13_0.rar] to Arduino library but still cannot compile the example.
C:\Users\user\Documents\libraries\ESPHap-master\aa.c:2:21: fatal error: wolfssl.h: No such file or directory
#include <wolfssl.h>

Pairing does not persist after reboot

I tried using the EspHapLed8266 example sketch with an ESP8266-12-F board. It compiles and uploads fine, pairing works, and accessory control is mostly great.

After rebooting the ESP8266 however, it forgets the pairing data entirely; HomeKit reports it as unresponsive, and it starts advertising an entirely different accessory for pairing.

Is this a known issue?

Constant pairing with a new device

For devices with HimeKit, the ability to pair with a new device is available all the time. Is it possible to turn on this option in this library? Is pairing possible only when no keys are stored in the memory?

Error Compiling

hi, I was able to successfully use ESPHap with ESP32, but I have problem compiling Sonoff examples for esp8266. I did select esp8266 under the board selection. the error is that it does not see esp_system.h . as far as I know it comes as a core with esp8266 boards installation package on Arduino IDE. what could be going wrong?


/Users/XXXX/Documents/Arduino/libraries/ESPHap-master/aa.c -o /dev/null
In file included from /Users/XXXX/Documents/Arduino/libraries/wolfSSL/wolfssl/wolfcrypt/settings.h:213:0,
from /Users/XXXX/Documents/Arduino/libraries/wolfSSL/wolfssl.h:2,
from /Users/XXXX/Documents/Arduino/libraries/ESPHap-master/aa.c:2:
/Users/Jordans/Documents/Arduino/libraries/wolfSSL/user_settings.h:38:24: fatal error: esp_system.h: No such file or directory
#include <esp_system.h>
^
compilation terminated.


new code for temperature/humidity with DHT11

Hi,
I looked at the code for DHT12 (I2C) that you recommend
but I'm using DHT11 and I had to modify it.
one of the disadvantages of DHT11 is that the SW is reading the data from the a pin and the sensor is very slow.
I converted the code from DHT12, but experience problems with reading the DHT11 sensor when combined with the rest of the ESPHAP code. I would presume it is because of interrupts that interfere with the reading of the sensor. Do you think there could be something done about that?

the other issue is that on the I phone I get only temperature accessory but actually reports temperature and humidity (BTW it shows 0.0 even if I put in constants rather than variables-see the rem in my code) but i'm defining 2 services, temperature and humidity
is my code doing it correct?
here is the entire code:

`
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
//#include <FS.h>
//#include <SPIFFS.h>
#define STATIC_IP_ADDR
///
#include "DHT.h"
#ifdef STATIC_IP_ADDR
IPAddress staticIP(192,168,0,91);
IPAddress gateway(192,168,0,1);
IPAddress subnet(255,255,255,0);
#endif

#include "coredecls.h"
#define DHTTYPE DHT11
#define DHTPIN 2
DHT dht(DHTPIN, DHTTYPE, 12); // 11 works fine for ESP8266

const char* ssid = "SHAW-62CD10";
const char* password = "251169025293";
float hum;
float temp;

unsigned long previousMillis = 0; // will store last temp was read
const long interval = 4000;

extern "C"{
#include "homeintegration.h"
}
#include "homekitintegrationcpp.h"

String pair_file_name="/pair.dat";

//**********************
void init_hap_storage(){

Serial.print("init_hap_storage");

File fsDAT=SPIFFS.open(pair_file_name, "r");
if(!fsDAT){
Serial.println("Failed to read pair.dat");
return;
}
int size=hap_get_storage_size_ex();
char* buf=new char[size];
memset(buf,0xff,size);
int readed=fsDAT.readBytes(buf,size);
Serial.print("Readed bytes ->");
Serial.println(readed);
hap_init_storage_ex(buf,size);
fsDAT.close();
delete []buf;

}
//*****************

//****************
void storage_changed(char * szstorage,int bufsize){

SPIFFS.remove(pair_file_name);
File fsDAT=SPIFFS.open(pair_file_name, "w+");
if(!fsDAT){
Serial.println("Failed to open pair.dat");
return;
}
fsDAT.write((uint8_t*)szstorage, bufsize);

fsDAT.close();
}
//********************
homekit_service_t* hapservice={0};
homekit_service_t* temperature;
homekit_service_t* humidity;

//////////////////////////////////
void setup() {
disable_extra4k_at_link_time();
Serial.begin(115200);
delay(3000);
Format();

 if (!SPIFFS.begin()) {
  Serial.print("SPIFFS Mount failed");
 }

Serial.print("Attempting connection to: ");
Serial.println(ssid);

WiFi.mode(WIFI_STA);
WiFi.begin((char*)ssid, (char*)password);

#ifdef STATIC_IP_ADDR
WiFi.config(staticIP, gateway, subnet);
#endif
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
WiFi.begin(ssid, password);
}
Serial.println("");
Serial.println("WiFi connected!");
#ifdef STATIC_IP_ADDR
Serial.print("Static IP address: ");
#else
Serial.print("Dinamic IP address: ");
#endif

Serial.println(WiFi.localIP());

/// now will setup homekit device

//this is for custom storaage usage
// In given example we are using \pair.dat   file in our spiffs system
//see implementation below
Serial.print("Free heap: ");
Serial.println(system_get_free_heap_size());


init_hap_storage();

set_callback_storage_change(storage_changed);

/// We will use for this example only one accessory (possible to use a several on the same esp)
//Our accessory type is light bulb , apple interface will proper show that
hap_setbase_accessorytype(homekit_accessory_category_thermostat);
/// init base properties
hap_initbase_accessory_service("Environment Sensor","SeaMaster","258521521","DHT11_ESP8266","1.0");

//we will add only one light bulb service and keep pointer for nest using

temperature = hap_add_temperature_service("Temperature");
humidity =   hap_add_humidity_service("Humidity");

//and finally init HAP

hap_init_homekit_server();   

}

////////////////////////////////

void loop() {

hap_homekit_loop();
delay(10);
unsigned long currentMillis = millis();

if (currentMillis - previousMillis >= interval) {
// save the last time you read the sensor
previousMillis = currentMillis;

// Reading temperature for humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (it's a very slow sensor)
hum = dht.readHumidity();          // Read humidity (percent)
temp = dht.readTemperature(false);     // Read temperature as Fahrenheit

Serial.println(temp); // Check if any reads failed and exit early (to try again).
if (isnan(hum) || isnan(temp)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
}
homekit_characteristic_t * ch= homekit_service_characteristic_by_type(temperature, HOMEKIT_CHARACTERISTIC_CURRENT_TEMPERATURE);
ch->value.float_value=temp;
homekit_characteristic_notify(ch,ch->value);
delay(10);
homekit_characteristic_t * ch2= homekit_service_characteristic_by_type(humidity, HOMEKIT_CHARACTERISTIC_CURRENT_RELATIVE_HUMIDITY);
ch2->value.float_value=hum;
homekit_characteristic_notify(ch2,ch2->value);

delay(10);
}

void Format(){
// Next lines have to be done ONLY ONCE!!!!!When SPIFFS is formatted ONCE you can comment these lines out!!
Serial.println("Please wait 30 secs for SPIFFS to be formatted");
SPIFFS.format();
Serial.println("Spiffs formatted");
}`

Use of this in Commercial Products will require MFI Licence ?

Please forgive me if i am confused.
But i saw that the other sdk from espressif has a different commercial version, and that can be used for commercial version and for that mfi license is compulsory.
I wonder if we can use this library in commercial products or not without mfi license?

Setting initial values when starting the Homekit server

Is there a suggested method for setting initial characteristic values in the startup to reflect the actual state of the device?

Is it OK to set characteristics immediately after calling hap_init_homekit_server?

Thanks...

Home Integration: homekit_is_paired 0

Hi! Thank you so much for this library!
I´m using ESPHap with an esp8266 (Wemos D1). I got it working, I can add the accessory to the Home app (sometimes fails as you said in the description), but when I´ve got the accessory paired if I restart the esp8266 (press the restart button) the device not run as before. It got a new ID and starts in "pairing mode".

In the serial plot "Home Integration: homekit_is_paired 0" appears when I restart.
What's going on with this?
Thank you!

ESP01s (esp8266) & IOS14.4 - Device not responding after restart

Hi, just trying new release 1.7, and pairing work better then in older release, but not every try..
Now I'm experimenting with RGB motion example..
After success pairing device work, but after restart i can't reconnect and device not responding.

Looks like problem in older release, after Pair Verify Step is disconnected.

Thx for help and great project!
I use on few devices original Maxim project and looking for alternative which offers more and simpler use third party libs and it is your project.. ;)

Log after restart...

>>> HomeKit: find pairings
>>> HomeKit: Preinit pairing context
>>> HomeKit: Using user-specified password: 111-11-111
>>> HomeKit: Free heap: 30320
>>> HomeKit: Calculating public key len=384
>>> HomeKit: Calculating public key result 0
>>> HomeKit: arduino_homekit_preinit success
>>> HomeKit: Configuring mDNS
>>> HomeKit: MDNS.begin: ES-AFC4, IP: 192.168.0.115
>>> HomeKit: Init server over
Web server is NOT SET, waiting for pairing
>>> HomeKit: WiFiServer receives a new client (current 0, max 4)
>>> HomeKit: Got new client connection: local 192.168.0.115:5556, remote 192.168.0.106:51444
>>> HomeKit: [Client 1073692772] Got 158 incomming data, encrypted is 
>>> HomeKit: [Client 1073692772] Pair Verify Step 1/2
>>> HomeKit: Free heap: 25760
>>> HomeKit: [Client 1073692772] Disconnected!
>>> HomeKit: Free heap: 26064
>>> HomeKit: [Client 1073692772] Closing client connection

Full log

IP address: 
192.168.0.115
>>> Home Integration: homekit_is_paired 0
>>> HomeKit: Update the CPU to run at 160MHz
>>> HomeKit: Free heap: 32944
>>> HomeKit: Starting server
>>> HomeKit: Formatting flash at 0x200000
Failed to open pair.dat
>>> HomeKit: storage init 1
>>> HomeKit: if r
>>> HomeKit: generating id
>>> HomeKit: Generated new accessory ID: 72:21:DB:65:BD:82
>>> HomeKit: Generated new accessory ID: 1073686756
>>> HomeKit:  key generated
Failed to open pair.dat
>>> HomeKit:  key saved
>>> HomeKit: Generated new accessory key
Failed to open pair.dat
>>> HomeKit: find pairings
>>> HomeKit: Preinit pairing context
>>> HomeKit: Using user-specified password: 111-11-111
>>> HomeKit: Free heap: 30320
>>> HomeKit: Calculating public key len=384
>>> HomeKit: Calculating public key result 0
>>> HomeKit: arduino_homekit_preinit success
>>> HomeKit: Configuring mDNS
>>> HomeKit: MDNS.begin: ES-3AAF, IP: 192.168.0.115
>>> HomeKit: Init server over
Web server is NOT SET, waiting for pairing
>>> HomeKit: WiFiServer receives a new client (current 0, max 4)
>>> HomeKit: Got new client connection: local 192.168.0.115:5556, remote 192.168.0.193:50082
>>> HomeKit: [Client 1073694964] Got 125 incomming data, encrypted is 
>>> HomeKit: [Client 1073694964] Pair Setup Step 1/3
>>> HomeKit: [Client 1073694964] Got 536 incomming data, encrypted is 
>>> HomeKit: [Client 1073694964] Got 42 incomming data, encrypted is 
>>> HomeKit: [Client 1073694964] Pair Setup Step 2/3
>>> HomeKit: [Client 1073694964] Computing SRP shared secret
>>> HomeKit: [Client 1073694964] Verifying peer's proof
>>> HomeKit: [Client 1073694964] Generating own proof
>>> HomeKit: [Client 1073694964] Got 280 incomming data, encrypted is 
>>> HomeKit: [Client 1073694964] Pair Setup Step 3/3
Failed to open pair.dat
>>> HomeKit: Added pairing with E5D14223-5021-47D6-BE9A-A9F83244461E
>>> HomeKit: Free saved_preinit_pairing_context
>>> HomeKit: Configuring mDNS
>>> HomeKit: MDNS.restart: ES-3AAF, IP: 192.168.0.115
>>> HomeKit: MDNS.begin: ES-3AAF, IP: 192.168.0.115
>>> HomeKit: [Client 1073694964] Successfully paired
>>> HomeKit: [Client 1073694964] Disconnected!
>>> HomeKit: Free heap: 29448
>>> HomeKit: [Client 1073694964] Closing client connection
>>> HomeKit: WiFiServer receives a new client (current 0, max 4)
>>> HomeKit: Got new client connection: local 192.168.0.115:5556, remote 192.168.0.193:50083
>>> HomeKit: [Client 1073696828] Got 158 incomming data, encrypted is 
>>> HomeKit: [Client 1073696828] Pair Verify Step 1/2
>>> HomeKit: Free heap: 28448
>>> HomeKit: [Client 1073696828] Got 247 incomming data, encrypted is 
>>> HomeKit: [Client 1073696828] Pair Verify Step 2/2
>>> HomeKit: [Client 1073696828] Found pairing with E5D14223-5021-47D6-BE9A-A9F83244461E
>>> HomeKit: [Client 1073696828] Verification successful, secure session established
>>> HomeKit: Free heap: 27936
>>> HomeKit: [Client 1073696828] Got 78 incomming data, encrypted is 
>>> HomeKit: [Client 1073696828] Get Accessories
>>> HomeKit: [Client 1073696828] Got 276 incomming data, encrypted is 
>>> HomeKit: [Client 1073696828] Update Characteristics
>>> HomeKit: [Client 1073696828] Got 276 incomming data, encrypted is 
>>> HomeKit: [Client 1073696828] Update Characteristics
>>> HomeKit: [Client 1073696828] Got 276 incomming data, encrypted is 
>>> HomeKit: [Client 1073696828] Update Characteristics
>>> HomeKit: [Client 1073696828] Got 217 incomming data, encrypted is 
>>> HomeKit: [Client 1073696828] Add Pairing
Failed to open pair.dat
>>> HomeKit: Added pairing with 77EEB1B3-18E7-4D24-B316-DA56AA8627A6
>>> HomeKit: [Client 1073696828] Got 217 incomming data, encrypted is 
>>> HomeKit: [Client 1073696828] Add Pairing
Failed to open pair.dat
>>> HomeKit: Added pairing with F1C852ED-F707-4363-89A4-C05CBBEA1A6C
>>> HomeKit: WiFiServer receives a new client (current 1, max 4)
>>> HomeKit: Got new client connection: local 192.168.0.115:5556, remote 192.168.0.138:54779
>>> HomeKit: [Client 1073695316] Got 158 incomming data, encrypted is 
>>> HomeKit: [Client 1073695316] Pair Verify Step 1/2
>>> HomeKit: Free heap: 25760
>>> HomeKit: [Client 1073695316] Got 247 incomming data, encrypted is 
>>> HomeKit: [Client 1073695316] Pair Verify Step 2/2
>>> HomeKit: [Client 1073695316] Found pairing with E5D14223-5021-47D6-BE9A-A9F83244461E
>>> HomeKit: [Client 1073695316] Verification successful, secure session established
>>> HomeKit: Free heap: 25696
>>> HomeKit: [Client 1073695316] Got 78 incomming data, encrypted is 
>>> HomeKit: [Client 1073695316] Get Accessories
>>> HomeKit: [Client 1073695316] Got 276 incomming data, encrypted is 
>>> HomeKit: [Client 1073695316] Update Characteristics
>>> HomeKit: [Client 1073695316] Got 89 incomming data, encrypted is 
>>> HomeKit: [Client 1073695316] Get Characteristics
>>> HomeKit: [Client 1073695316] Got 105 incomming data, encrypted is 
>>> HomeKit: [Client 1073695316] Get Characteristics
>>> HomeKit: [Client 1073696828] Got 90 incomming data, encrypted is 
>>> HomeKit: [Client 1073696828] Get Characteristics
>>> HomeKit: [Client 1073696828] Got 100 incomming data, encrypted is 
>>> HomeKit: [Client 1073696828] Get Characteristics
rl�l⸮⸮|�⸮l⸮|�⸮l⸮b|⸮⸮�⸮�⸮r⸮b⸮b⸮⸮nn⸮lnn⸮⸮⸮b�p⸮lrlrlp⸮n⸮��⸮l⸮⸮bn⸮|�⸮l⸮⸮b⸮⸮nn⸮�l⸮⸮l`�⸮��nnl`���nr⸮⸮⸮nb�l`��r⸮⸮nb�l`�⸮b⸮��⸮lr⸮`�⸮⸮n⸮�SPIFFS Mount failedFree heap: 35832
init_hap_storageFailed to read pair.dat
>>> HomeKit: init_storage_ex size 0x1c1
>>> Home Integration: hap_services added chararacteristic  0: 23 
>>> Home Integration: hap_services added chararacteristic  1: 25 
>>> Home Integration: hap_services added chararacteristic  2: 8 
>>> Home Integration: hap_services added chararacteristic  3: 13 
>>> Home Integration: hap_services added chararacteristic  4: 2F 
..............WiFi connected
IP address: 
192.168.0.115
>>> Home Integration: homekit_is_paired 0
>>> HomeKit: Update the CPU to run at 160MHz
>>> HomeKit: Free heap: 32944
>>> HomeKit: Starting server
>>> HomeKit: Formatting flash at 0x200000
Failed to open pair.dat
>>> HomeKit: storage init 1
>>> HomeKit: if r
>>> HomeKit: generating id
>>> HomeKit: Generated new accessory ID: 1F:9B:24:5F:76:89
>>> HomeKit: Generated new accessory ID: 1073692052
>>> HomeKit:  key generated
Failed to open pair.dat
>>> HomeKit:  key saved
>>> HomeKit: Generated new accessory key
Failed to open pair.dat
>>> HomeKit: find pairings
>>> HomeKit: Preinit pairing context
>>> HomeKit: Using user-specified password: 111-11-111
>>> HomeKit: Free heap: 30320
>>> HomeKit: Calculating public key len=384
>>> HomeKit: Calculating public key result 0
>>> HomeKit: arduino_homekit_preinit success
>>> HomeKit: Configuring mDNS
>>> HomeKit: MDNS.begin: ES-AFC4, IP: 192.168.0.115
>>> HomeKit: Init server over
Web server is NOT SET, waiting for pairing
>>> HomeKit: WiFiServer receives a new client (current 0, max 4)
>>> HomeKit: Got new client connection: local 192.168.0.115:5556, remote 192.168.0.106:51444
>>> HomeKit: [Client 1073692772] Got 158 incomming data, encrypted is 
>>> HomeKit: [Client 1073692772] Pair Verify Step 1/2
>>> HomeKit: Free heap: 25760
>>> HomeKit: [Client 1073692772] Disconnected!
>>> HomeKit: Free heap: 26064
>>> HomeKit: [Client 1073692772] Closing client connection

EspHapLed8266 example creates new Led on every reboot

Every time I reboot I have to re-add a new led? And the old parring is still there, just with a "offline" text.

Here is my log after rebooting the NodeMCU Board:

19:42:40.497 -> rl�$⸮⸮|�⸮$⸮|���⸮�d⸮�b|⸮⸮⸮⸮�⸮r⸮b⸮�#⸮p~⸮N⸮lon⸮⸮⸮#�p⸮$sl{lp⸮o⸮���⸮l�⸮⸮�b�o⸮|�l⸮l⸮�p⸮⸮no⸮�$⸮⸮�$`�⸮��on�l ���or⸮⸮⸮N�⸮�$`��rےo�⸮�d`�⸮{⸮p⸮�l⸮r�⸮ �⸮⸮o⸮�Borneland
19:42:41.155 -> .
19:42:41.155 -> IP address: 
19:42:41.155 -> 10.0.1.23
19:42:41.155 -> Free heap: 37704
19:42:41.155 -> init_hap_storageReaded bytes ->>>> HomeKit: init_storage_ex size 0x1c1
19:42:41.155 -> >>> Home Integration: hap_services added chararacteristic  0: 23 
19:42:41.194 -> >>> Home Integration: hap_services added chararacteristic  1: 25 
19:42:41.194 -> >>> Home Integration: homekit_is_paired 0
19:42:41.194 -> >>> HomeKit: Update the CPU to run at 160MHz
19:42:41.194 -> >>> HomeKit: Free heap: 35992
19:42:41.194 -> >>> HomeKit: Starting server
19:42:41.194 -> >>> HomeKit: Formatting flash at 0x200000
19:42:41.261 -> >>> HomeKit: storage init 1
19:42:41.261 -> >>> HomeKit: if r
19:42:41.261 -> >>> HomeKit: generating id
19:42:41.261 -> >>> HomeKit: Generated new accessory ID: BE:B1:BF:E1:7F:4B
19:42:41.261 -> >>> HomeKit: Generated new accessory ID: 1073689556
19:42:41.261 -> >>> HomeKit:  key generated
19:42:41.365 -> >>> HomeKit:  key saved
19:42:41.398 -> >>> HomeKit: Generated new accessory key
19:42:41.473 -> >>> HomeKit: find pairings
19:42:41.473 -> >>> HomeKit: Preinit pairing context
19:42:41.473 -> >>> HomeKit: Using user-specified password: 111-11-111
19:42:41.511 -> >>> HomeKit: Free heap: 33200
19:42:47.524 -> >>> HomeKit: Calculating public key len=384
19:42:50.641 -> >>> HomeKit: Calculating public key result 0
19:42:50.641 -> >>> HomeKit: arduino_homekit_preinit success
19:42:50.641 -> >>> HomeKit: Configuring mDNS
19:42:50.675 -> >>> HomeKit: MDNS.begin: ES-7259, IP: 10.0.1.23
19:42:50.675 -> >>> HomeKit: Init server over
19:43:08.613 -> >>> HomeKit: WiFiServer receives a new client (current 0, max 4)
19:43:08.613 -> >>> HomeKit: Got new client connection: local 10.0.1.23:5556, remote 10.0.1.11:54131
19:43:08.613 -> >>> HomeKit: [Client 1073692148] Got 158 incomming data, encrypted is 
19:43:08.613 -> >>> HomeKit: [Client 1073692148] Pair Verify Step 1/2
19:43:08.966 -> >>> HomeKit: Free heap: 28528
19:43:09.003 -> >>> HomeKit: [Client 1073692148] Disconnected!
19:43:09.003 -> >>> HomeKit: Free heap: 29328
19:43:09.003 -> >>> HomeKit: [Client 1073692148] Closing client connection
19:43:11.610 -> >>> HomeKit: WiFiServer receives a new client (current 0, max 4)
19:43:11.610 -> >>> HomeKit: Got new client connection: local 10.0.1.23:5556, remote 10.0.1.11:54132
19:43:11.643 -> >>> HomeKit: [Client 1073693948] Got 158 incomming data, encrypted is 
19:43:11.643 -> >>> HomeKit: [Client 1073693948] Pair Verify Step 1/2
19:43:11.962 -> >>> HomeKit: Free heap: 28528
19:43:14.277 -> >>> HomeKit: [Client 1073693948] Disconnected!
19:43:14.277 -> >>> HomeKit: Free heap: 29608
19:43:14.277 -> >>> HomeKit: [Client 1073693948] Closing client connection
19:43:16.659 -> >>> HomeKit: WiFiServer receives a new client (current 0, max 4)
19:43:16.659 -> >>> HomeKit: Got new client connection: local 10.0.1.23:5556, remote 10.0.1.11:54134
19:43:16.693 -> >>> HomeKit: [Client 1073694732] Got 158 incomming data, encrypted is 
19:43:16.693 -> >>> HomeKit: [Client 1073694732] Pair Verify Step 1/2
19:43:16.998 -> >>> HomeKit: Free heap: 28720
19:43:17.202 -> >>> HomeKit: [Client 1073694732] Disconnected!
19:43:17.202 -> >>> HomeKit: Free heap: 29328
19:43:17.202 -> >>> HomeKit: [Client 1073694732] Closing client connection
19:43:19.870 -> >>> HomeKit: WiFiServer receives a new client (current 0, max 4)
19:43:19.870 -> >>> HomeKit: Got new client connection: local 10.0.1.23:5556, remote 10.0.1.7:49250
19:43:19.870 -> >>> HomeKit: [Client 1073692092] Got 158 incomming data, encrypted is 
19:43:19.870 -> >>> HomeKit: [Client 1073692092] Pair Verify Step 1/2
19:43:20.216 -> >>> HomeKit: Free heap: 28528
19:43:20.216 -> >>> HomeKit: [Client 1073692092] Disconnected!
19:43:20.216 -> >>> HomeKit: Free heap: 29328
19:43:20.216 -> >>> HomeKit: [Client 1073692092] Closing client connection

Changing Default Password

Hi!
Can we add a void in homeintegration.c to change the default password? So if we call in the .ino file the Hap function we can change the default password.
Are there any limitations on changing the password from 111-11-111 to any other (pairing limitations etc...)?

implement custom service and characteristic

Hi, thanks for the great work.

one little question,
is it possible to implement a custom service and characteristic?
i will need it for a smart meter, reading volts, amperes, watts etc.
as I read in the apple spec, I need custom UUIDs for that.

would be great if you could explain that or implement.

Thanks

Thermostat

Hello. Sorry for my bad English. I want to ask about your library. It's easy to make a light bulb or temperature indicator turn off. But I can't figure out how to implement a full-fledged thermostat for switching (heating, cooling), temperature control and the like?? I add hap_setbase_accessorytype(homekit_accessory_category_thermostat); Then I read the description of characteristic.h /**
Defines that the accessory contains a thermostat.

Required Characteristics:

  • CURRENT_HEATING_COOLING_STATE
  • TARGET_HEATING_COOLING_STATE
  • CURRENT_TEMPERATURE
  • TARGET_TEMPERATURE
  • TEMPERATURE_DISPLAY_UNITS

Optional Characteristics:

  • NAME
  • CURRENT_RELATIVE_HUMIDITY
  • TARGET_RELATIVE_HUMIDITY
  • COOLING_THRESHOLD_TEMPERATURE
  • HEATING_THRESHOLD_TEMPERATURE
    */
    But I can't figure out how to add all the Required Characteristics so that the iphone can see and show them?

I add hapservice = hap_add_switch_service("OnOffThermostat", led_callback, (void*)&led_gpio);
hapservice = hap_add_temperature_service ("Temperature"); But how do I add a field to set the target temperature value? Or maybe I'm not doing it right?

In the example folder, there is an example of a thermostat, but it just displays the temperature and humidity sensors, this is not a full-fledged thermostat.

Only 7 services?

In homeintegration.c, the following is defined:
#define MAX_HAP_SERVICES 7

However, at the top of the file, MAX_SERVICES is defined as 20.

What’s the difference between these two?

Switch returns to on without input

I ran the EspHapLed example and got it working fine, but the switch always returns to the on position in HomeKit. Is this expected behavior? I expected the switch to "stick" in the position.

RPReplay_Final1612094092.mp4

Here's the serial monitor output from the same time, showing that the messages were received.

11:54:22.188 -> >>> HomeKit: [Client 1073694364] Got 188 incomming data, encrypted is 
11:54:22.188 -> >>> HomeKit: [Client 1073694364] Update Characteristics
11:54:22.235 -> led_callback
11:54:22.235 -> set_led
11:54:22.235 -> notify hap
11:54:22.235 -> found characteristic
11:54:23.727 -> >>> HomeKit: [Client 1073694364] Got 188 incomming data, encrypted is 
11:54:23.727 -> >>> HomeKit: [Client 1073694364] Update Characteristics
11:54:23.727 -> led_callback
11:54:23.774 -> set_led
11:54:23.774 -> notify hap
11:54:23.774 -> found characteristic
11:54:25.261 -> >>> HomeKit: [Client 1073694364] Got 188 incomming data, encrypted is 
11:54:25.261 -> >>> HomeKit: [Client 1073694364] Update Characteristics
11:54:25.261 -> led_callback
11:54:25.308 -> set_led
11:54:25.308 -> notify hap
11:54:25.308 -> found characteristic
11:54:26.714 -> >>> HomeKit: [Client 1073694364] Got 188 incomming data, encrypted is 
11:54:26.714 -> >>> HomeKit: [Client 1073694364] Update Characteristics
11:54:26.714 -> led_callback
11:54:26.714 -> set_led
11:54:26.714 -> notify hap
11:54:26.714 -> found characteristic
11:55:33.698 -> >>> HomeKit: [Client 1073694364] Got 189 incomming data, encrypted is 
11:55:33.698 -> >>> HomeKit: [Client 1073694364] Update Characteristics

Error in homeintegration.c

so finally I figured out why the humidity never worked correctly!
in file homeintegration.c you had:
`
homekit_service_t* hap_add_humidity_service(const char* szname){

homekit_service_t*service=NEW_HOMEKIT_SERVICE(TEMPERATURE_SENSOR, .characteristics=(homekit_characteristic_t*[]) {
            NEW_HOMEKIT_CHARACTERISTIC(NAME, szname),
            NEW_HOMEKIT_CHARACTERISTIC(CURRENT_RELATIVE_HUMIDITY, 0),
            NULL`

it should've been:
`
homekit_service_t* hap_add_humidity_service(const char* szname){

homekit_service_t*service=NEW_HOMEKIT_SERVICE(HUMIDITY_SENSOR, .characteristics=(homekit_characteristic_t*[]) {
            NEW_HOMEKIT_CHARACTERISTIC(NAME, szname),
            NEW_HOMEKIT_CHARACTERISTIC(CURRENT_RELATIVE_HUMIDITY, 0),
            NULL`

Now I have Temperature and humidity showing together, with proper icons and proper values! it only took me 3 days. LOL
please correct in your library and close this case.
there is still remaining issue with the serial monitor overflowing with
`>> HomeKit: [Client 1073691748] Got characteristic 1.10 change event

HomeKit: [Client 1073691748] Got characteristic 1.13 change event`
but I will open new case for that one

fatal error: SPIFFS.h: No such file or directory

I'm really excited about trying this out! but I'm getting an error.
I get this error when trying to compile EspHapLed:
EspHapLed:4:20: fatal error: SPIFFS.h: No such file or directory #include <SPIFFS.h> ^ compilation terminated. exit status 1 SPIFFS.h: No such file or directory

I'm using a NodeMCU board
Screen Shot 2020-04-18 at 2 48 35 PM

Do you know what's wrong? Thanks!

Compilation error of the LED Example

I am using a OLIMEX ESP32-EVB. With Arduino IDE 1.8.13 and the latest ESPHap.
If I compile an Arduino led blinking example it works perfectly, the same if I compile the WIFI scan example I can scan the networks at home and have a list. I tried also the the ESP32 ChipID example and I can get my chip ID on the serial console, so I think the board is up and running without issues.

But when I run the EspHapLed I get several errors about cJSON and other components with multiple definitions.
I think this is due to the use of esp32 1.0.5-rc4 instead of the stable. That is due to the fact that the previous release does not run with the latest MacOS installation, so I guess that from the next release this error will be produced also by the stable. Is there something that I can do to avoid this error?

/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_GetErrorPtr':
/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/json/cJSON/cJSON.c:78: multiple definition of `cJSON_GetErrorPtr'
libraries/ESPHap/cJSON.c.o:/Users/ema/Documents/Arduino/libraries/ESPHap/cJSON.c:72: first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_Version':
cJSON.c:(.text.cJSON_Version+0x0): multiple definition of `cJSON_Version'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_Version+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_InitHooks':
cJSON.c:(.text.cJSON_InitHooks+0x0): multiple definition of `cJSON_InitHooks'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_InitHooks+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_Delete':
cJSON.c:(.text.cJSON_Delete+0x0): multiple definition of `cJSON_Delete'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_Delete+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_SetNumberHelper':
cJSON.c:(.text.cJSON_SetNumberHelper+0x0): multiple definition of `cJSON_SetNumberHelper'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_SetNumberHelper+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_ParseWithOpts':
cJSON.c:(.text.cJSON_ParseWithOpts+0x0): multiple definition of `cJSON_ParseWithOpts'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_ParseWithOpts+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_Parse':
cJSON.c:(.text.cJSON_Parse+0x0): multiple definition of `cJSON_Parse'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_Parse+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_Print':
cJSON.c:(.text.cJSON_Print+0x0): multiple definition of `cJSON_Print'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_Print+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_PrintUnformatted':
cJSON.c:(.text.cJSON_PrintUnformatted+0x0): multiple definition of `cJSON_PrintUnformatted'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_PrintUnformatted+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_PrintBuffered':
cJSON.c:(.text.cJSON_PrintBuffered+0x0): multiple definition of `cJSON_PrintBuffered'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_PrintBuffered+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_PrintPreallocated':
cJSON.c:(.text.cJSON_PrintPreallocated+0x0): multiple definition of `cJSON_PrintPreallocated'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_PrintPreallocated+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_GetArraySize':
cJSON.c:(.text.cJSON_GetArraySize+0x0): multiple definition of `cJSON_GetArraySize'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_GetArraySize+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_GetArrayItem':
Multiple libraries were found for "WiFi.h"
 Used: /Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/libraries/WiFi
 Not used: /Applications/Arduino.app/Contents/Java/libraries/WiFi
cJSON.c:(.text.cJSON_GetArrayItem+0x0): multiple definition of `cJSON_GetArrayItem'
 Not used: /Users/ema/Documents/Arduino/libraries/WiFiNINA
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_GetArrayItem+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_GetObjectItem':
cJSON.c:(.text.cJSON_GetObjectItem+0x0): multiple definition of `cJSON_GetObjectItem'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_GetObjectItem+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_GetObjectItemCaseSensitive':
cJSON.c:(.text.cJSON_GetObjectItemCaseSensitive+0x0): multiple definition of `cJSON_GetObjectItemCaseSensitive'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_GetObjectItemCaseSensitive+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_HasObjectItem':
cJSON.c:(.text.cJSON_HasObjectItem+0x0): multiple definition of `cJSON_HasObjectItem'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_HasObjectItem+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_AddItemToArray':
cJSON.c:(.text.cJSON_AddItemToArray+0x0): multiple definition of `cJSON_AddItemToArray'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_AddItemToArray+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_AddItemToObject':
cJSON.c:(.text.cJSON_AddItemToObject+0x0): multiple definition of `cJSON_AddItemToObject'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_AddItemToObject+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_AddItemToObjectCS':
cJSON.c:(.text.cJSON_AddItemToObjectCS+0x0): multiple definition of `cJSON_AddItemToObjectCS'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_AddItemToObjectCS+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_AddItemReferenceToArray':
cJSON.c:(.text.cJSON_AddItemReferenceToArray+0x0): multiple definition of `cJSON_AddItemReferenceToArray'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_AddItemReferenceToArray+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_AddItemReferenceToObject':
cJSON.c:(.text.cJSON_AddItemReferenceToObject+0x0): multiple definition of `cJSON_AddItemReferenceToObject'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_AddItemReferenceToObject+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_DetachItemViaPointer':
cJSON.c:(.text.cJSON_DetachItemViaPointer+0x0): multiple definition of `cJSON_DetachItemViaPointer'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_DetachItemViaPointer+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_DetachItemFromArray':
cJSON.c:(.text.cJSON_DetachItemFromArray+0x0): multiple definition of `cJSON_DetachItemFromArray'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_DetachItemFromArray+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_DeleteItemFromArray':
cJSON.c:(.text.cJSON_DeleteItemFromArray+0x0): multiple definition of `cJSON_DeleteItemFromArray'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_DeleteItemFromArray+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_DetachItemFromObject':
cJSON.c:(.text.cJSON_DetachItemFromObject+0x0): multiple definition of `cJSON_DetachItemFromObject'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_DetachItemFromObject+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_DetachItemFromObjectCaseSensitive':
cJSON.c:(.text.cJSON_DetachItemFromObjectCaseSensitive+0x0): multiple definition of `cJSON_DetachItemFromObjectCaseSensitive'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_DetachItemFromObjectCaseSensitive+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_DeleteItemFromObject':
cJSON.c:(.text.cJSON_DeleteItemFromObject+0x0): multiple definition of `cJSON_DeleteItemFromObject'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_DeleteItemFromObject+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_DeleteItemFromObjectCaseSensitive':
cJSON.c:(.text.cJSON_DeleteItemFromObjectCaseSensitive+0x0): multiple definition of `cJSON_DeleteItemFromObjectCaseSensitive'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_DeleteItemFromObjectCaseSensitive+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_InsertItemInArray':
cJSON.c:(.text.cJSON_InsertItemInArray+0x0): multiple definition of `cJSON_InsertItemInArray'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_InsertItemInArray+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_ReplaceItemViaPointer':
cJSON.c:(.text.cJSON_ReplaceItemViaPointer+0x0): multiple definition of `cJSON_ReplaceItemViaPointer'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_ReplaceItemViaPointer+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_ReplaceItemInArray':
cJSON.c:(.text.cJSON_ReplaceItemInArray+0x0): multiple definition of `cJSON_ReplaceItemInArray'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_ReplaceItemInArray+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_CreateNull':
cJSON.c:(.text.cJSON_CreateNull+0x0): multiple definition of `cJSON_CreateNull'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_CreateNull+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_CreateTrue':
cJSON.c:(.text.cJSON_CreateTrue+0x0): multiple definition of `cJSON_CreateTrue'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_CreateTrue+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_CreateFalse':
cJSON.c:(.text.cJSON_CreateFalse+0x0): multiple definition of `cJSON_CreateFalse'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_CreateFalse+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_CreateBool':
cJSON.c:(.text.cJSON_CreateBool+0x0): multiple definition of `cJSON_CreateBool'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_CreateBool+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_CreateNumber':
cJSON.c:(.text.cJSON_CreateNumber+0x0): multiple definition of `cJSON_CreateNumber'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_CreateNumber+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_CreateString':
cJSON.c:(.text.cJSON_CreateString+0x0): multiple definition of `cJSON_CreateString'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_CreateString+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_CreateRaw':
cJSON.c:(.text.cJSON_CreateRaw+0x0): multiple definition of `cJSON_CreateRaw'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_CreateRaw+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_CreateArray':
cJSON.c:(.text.cJSON_CreateArray+0x0): multiple definition of `cJSON_CreateArray'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_CreateArray+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_CreateObject':
cJSON.c:(.text.cJSON_CreateObject+0x0): multiple definition of `cJSON_CreateObject'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_CreateObject+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_CreateIntArray':
cJSON.c:(.text.cJSON_CreateIntArray+0x0): multiple definition of `cJSON_CreateIntArray'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_CreateIntArray+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_CreateFloatArray':
cJSON.c:(.text.cJSON_CreateFloatArray+0x0): multiple definition of `cJSON_CreateFloatArray'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_CreateFloatArray+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_CreateDoubleArray':
cJSON.c:(.text.cJSON_CreateDoubleArray+0x0): multiple definition of `cJSON_CreateDoubleArray'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_CreateDoubleArray+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_CreateStringArray':
cJSON.c:(.text.cJSON_CreateStringArray+0x0): multiple definition of `cJSON_CreateStringArray'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_CreateStringArray+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_Duplicate':
cJSON.c:(.text.cJSON_Duplicate+0x0): multiple definition of `cJSON_Duplicate'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_Duplicate+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_Minify':
cJSON.c:(.text.cJSON_Minify+0x0): multiple definition of `cJSON_Minify'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_Minify+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_IsInvalid':
cJSON.c:(.text.cJSON_IsInvalid+0x0): multiple definition of `cJSON_IsInvalid'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_IsInvalid+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_IsFalse':
cJSON.c:(.text.cJSON_IsFalse+0x0): multiple definition of `cJSON_IsFalse'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_IsFalse+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_IsTrue':
cJSON.c:(.text.cJSON_IsTrue+0x0): multiple definition of `cJSON_IsTrue'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_IsTrue+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_IsBool':
cJSON.c:(.text.cJSON_IsBool+0x0): multiple definition of `cJSON_IsBool'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_IsBool+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_IsNull':
cJSON.c:(.text.cJSON_IsNull+0x0): multiple definition of `cJSON_IsNull'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_IsNull+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_IsNumber':
cJSON.c:(.text.cJSON_IsNumber+0x0): multiple definition of `cJSON_IsNumber'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_IsNumber+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_IsString':
cJSON.c:(.text.cJSON_IsString+0x0): multiple definition of `cJSON_IsString'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_IsString+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_IsArray':
cJSON.c:(.text.cJSON_IsArray+0x0): multiple definition of `cJSON_IsArray'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_IsArray+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_IsObject':
cJSON.c:(.text.cJSON_IsObject+0x0): multiple definition of `cJSON_IsObject'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_IsObject+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_IsRaw':
cJSON.c:(.text.cJSON_IsRaw+0x0): multiple definition of `cJSON_IsRaw'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_IsRaw+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_Compare':
cJSON.c:(.text.cJSON_Compare+0x0): multiple definition of `cJSON_Compare'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_Compare+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_malloc':
cJSON.c:(.text.cJSON_malloc+0x0): multiple definition of `cJSON_malloc'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_malloc+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_free':
cJSON.c:(.text.cJSON_free+0x0): multiple definition of `cJSON_free'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_free+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_ReplaceItemInObject':
cJSON.c:(.text.cJSON_ReplaceItemInObject+0x0): multiple definition of `cJSON_ReplaceItemInObject'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_ReplaceItemInObject+0x0): first defined here
/Users/ema/Library/Arduino15/packages/esp32/hardware/esp32/1.0.5-rc4/tools/sdk/lib/libjson.a(cJSON.o): In function `cJSON_ReplaceItemInObjectCaseSensitive':
cJSON.c:(.text.cJSON_ReplaceItemInObjectCaseSensitive+0x0): multiple definition of `cJSON_ReplaceItemInObjectCaseSensitive'
libraries/ESPHap/cJSON.c.o:cJSON.c:(.text.cJSON_ReplaceItemInObjectCaseSensitive+0x0): first defined here
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board OLIMEX ESP32-EVB.

Double switch not working as expected on ESP8266

Hi,

Thanks for this project, it's GREAT :-)

I have an issue with a double switch i'm trying to make. When both are off in IOS home, and I turn on switch 1, switch 2 will also turn on. If both are off, and I turn on switch 2, only switch 2 will turn on as expected.
What can I be doing wrong?

Best regards,
Christian

/*
ESPHap example EspHapLed for ESP8266

This example for ESPHap shows how to control a LED
with Apple Home app. It implements accessory type "light bulb".

This example code is part of the public domain
*/

#include <Arduino.h>

#ifdef ESP32
#include <SPIFFS.h>
#endif
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>

#include "coredecls.h"
const char* ssid = "xx";
const char* password = "xx";

const int identity_led=3;
const int led_gpio = 2;
const int led1_gpio = 0;

extern "C"{
#include "homeintegration.h"
}
#include "homekitintegrationcpp.h"

homekit_service_t* hapservice={0};
String pair_file_name="/pair.dat";
//esp8266::MDNSImplementation::MDNSResponder* MDNS1;

LOCAL os_timer_t callbacktimer;

void setup() {
disable_extra4k_at_link_time();
Serial.begin(115200);
delay(10);

// We start by connecting to a WiFi network

#ifdef ESP32
if (!SPIFFS.begin(true)) {
// Serial.print("SPIFFS Mount failed");
}
#endif
#ifdef ESP8266
if (!SPIFFS.begin()) {
Serial.print("SPIFFS Mount failed");
}
#endif

Serial.println(ssid);

#ifdef ESP8266
WiFi.mode(WIFI_STA);
WiFi.begin((char*)ssid, (char*)password);
#else
WiFi.begin(ssid, password);
#endif
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
// Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());

pinMode(led_gpio,OUTPUT);
pinMode(led1_gpio,OUTPUT);
///setup identity gpio
// hap_set_identity_gpio(identity_led); //identity_led=2 will blink on identity

/// now will setup homekit device

//this is for custom storaage usage
// In given example we are using \pair.dat   file in our spiffs system
//see implementation below
Serial.print("Free heap: ");
Serial.println(system_get_free_heap_size());

init_hap_storage();

set_callback_storage_change(storage_changed);

/// We will use for this example only one accessory (possible to use a several on the same esp)
//Our accessory type is light bulb, Apple interface will proper show that

// hap_setbase_accessorytype(homekit_accessory_category_lightbulb);
hap_setbase_accessorytype(homekit_accessory_category_switch);

/// init base properties
hap_initbase_accessory_service("","test","0","Fun","1.42"); 

//we will add only one light bulb service and keep pointer for nest using
//hapservice= hap_add_lightbulb_service("Led",led_callback,(void*)&led_gpio);
hapservice= hap_add_switch_service("AUX",led_callback,(void*)&led_gpio);
hapservice= hap_add_switch_service("CD",led1_callback,(void*)&led1_gpio);
//and finally init HAP

hap_init_homekit_server();

}

void loop() {

hap_homekit_loop();
//delay(2);
return;
}

void init_hap_storage(){
Serial.print("init_hap_storage");

File fsDAT=SPIFFS.open(pair_file_name, "r");
if(!fsDAT){
Serial.println("Failed to read pair.dat");
return;
}
int size=hap_get_storage_size_ex();
char* buf=new char[size];
memset(buf,0xff,size);
int readed=fsDAT.readBytes(buf,size);
// Serial.print("Readed bytes ->");
// Serial.println(readed);
hap_init_storage_ex(buf,size);
fsDAT.close();
delete []buf;
}

void storage_changed(char * szstorage,int bufsize){

SPIFFS.remove(pair_file_name);
File fsDAT=SPIFFS.open(pair_file_name, "w+");
if(!fsDAT){
Serial.println("Failed to open pair.dat");
return;
}
fsDAT.write((uint8_t*)szstorage, bufsize);

fsDAT.close();
}
//can be used for any logic, it will automatically inform Apple about state changes
void set_led(bool val){
Serial.println("set_led");
digitalWrite(led_gpio, val?HIGH:LOW);
//we need notify apple about changes

if(hapservice){
Serial.println("notify hap");
//getting on/off characteristic
homekit_characteristic_t * ch= homekit_service_characteristic_by_type(hapservice, HOMEKIT_CHARACTERISTIC_ON);
if(ch){
Serial.println("found characteristic");
if(ch->value.bool_value!=val){ //wil notify only if different
ch->value.bool_value=val;
homekit_characteristic_notify(ch,ch->value);
}
}
}
}

void set_led1(bool val){
Serial.println("set_led1");
digitalWrite(led1_gpio, val?HIGH:LOW);
//we need notify apple about changes

if(hapservice){
Serial.println("notify hap");
//getting on/off characteristic
homekit_characteristic_t * ch= homekit_service_characteristic_by_type(hapservice, HOMEKIT_CHARACTERISTIC_ON);
if(ch){
Serial.println("found characteristic");
if(ch->value.bool_value!=val){ //wil notify only if different
ch->value.bool_value=val;
homekit_characteristic_notify(ch,ch->value);
}
}
}
}

void led_callback(homekit_characteristic_t *ch, homekit_value_t value, void *context) {
Serial.println("led_callback");
set_led(ch->value.bool_value);
}

void led1_callback(homekit_characteristic_t *ch, homekit_value_t value, void *context) {
Serial.println("led1_callback");
set_led1(ch->value.bool_value);
}

Accessory 'No Response'

Hello :)

I am using the EspHap_Switch example. I have set the ssid and password to match my network. #define ENABLE_WIFI_MANAGER is commented out.

I have successfully connected the ESP to my home WiFi and paried the switch accessory with the Home app on my iPhone.

The iPad is set to act as a Home Hub, with the intention that I will be able to access the accessories while I am away from home. The iPad will stay in the home even when I sell it, so the iPad has its own iTunes/iCloud account, which is logged in, and this is different to the iTunes/iCloud account on my iPhoneX. To get the accessories on my iPhoneX, I sent a guest invite from Home on the iPad to the iPhoneX. The guest access is configured such that guests are permitted to modify/add/remove accessories and can access while away from the home.

When I turn off WiFi on my iPhoneX, to simulate being away from home, and then place my iPhoneX on the desk with the Home app open, the switch accessory continues to show healthy for some minutes, but then shows No Response in the Home app. Note, I haven't pressed the button, just left the Home app open on the Home or Garage room. I'm looking at my iPhoneX and it's saying it right now. It shows an exclamation mark on the accessory in the Home app, and has the state ("Off") in red text. It also says, "Test Switch No Response" (I named the accessory Test Switch when I added it to the Home app.

If I minimise the Home app on my iPhoneX and then open it again, the Test Switch state changes to "Updating" and then after a few seconds, shows "Off", which is the correct status and the "No Response" message goes away.

The iPad is plugged in to power, but the screen has gone to sleep (I don't want to leave the iPad screen on 24/7 with no sleep).

I am not sure how to proceed to make it reliably stay available in the Home app, without it changing to "No Response". Are you able to help with this please? I am keen to do whatever debugging can help with the investigation :)

After some testing like this, I have changed the iPad iTunes/iCloud account, to use the same one on both the iPhoneX and iPad and re-added the accessory. Now the accessory in the iPhoneX (with WiFi turned off) seems to be working better, I have left the phone on and with the Home app open on the iPhoneX for 15 minutes and it has not come up with "no response" yet.

Could it be related to accessing the accessories as an invited guest and different iTunes/iCloud accounts? Or is there something else we can investigate?

Details:

  • Arduino 1.8.13
  • iPhoneX iOS 14.4 (192.168.1.101)
  • iPad 8th gen, iPadOS 14.4 (192.168.1.100)
  • ESPHap: v1.0.7
  • ESP8266 v2.7.4 (in Boards Manager)
  • Board: NodeMCU 1.0 (ESP-12E Module) - Note, this is a NodeMCU v1.0 Rev2.0 (192.168.1.155)
  • CPU Freq: 120MHz
  • Flash Size: 4MB (FS:2MB oTA:~1019KB)
  • Debug port: Disabled
  • Debug level: None
  • IwIP Variant: v2 Lower Memory Changed this to v2 Higher Bandwidth (as per comment below)
  • VTables: Flash
  • Exceptions: Legacy (new can return nullptr)
  • Erase Flash: Only Sketch
  • SSL Support: Basic SSL ciphers (lower ROM usage) - Note, I am using WolfSSL 3.13.0 as per Readme instructions.
  • Port COM3 - Note, I have the NodeMCU connected via USB.

Network equipment which may appear in the mDNS logs:

  • 192.168.1.100 - (as above) iPad 8th Gen, iPadOS 14.4, used as the Home Hub.
  • 192.168.1.101 - (as above) iPhone X iOS 14.4, used for controlling the accessories both locally on WiFi and with WiFi turned off to simulate being remote.
  • 192.168.1.102 - My Ryzen 7 Win10x64 PC, used for programming the NodeMCU.
  • 192.168.1.103 - Vero4k+ media player. Note, this is a AirPlay receiver, so appears in the mDNS logs.
  • 192.168.1.105 - Unrelated iPad Air, not used for this project, but is in the house on wifi. This is my girlfriends.
  • 192.168.1.106 - Unrelated iPhoneX (another one), not used for this project, but is in the house on wifi. This is my girlfriends.

Thank you :)

IOT device (mdns) stops responding to HAP after a few time (esp32)

After some time, devices, especially without offen notifications to HAP for instance Light Bulbs,
stops responding to HAP and status on the Home screen is "No response"

This is monitored on several devices, which are not frequently sent notification to HAP.
Not easylly to reproduce on the devices like thermostat, they are quite frequently sent notification

Not able to pair with Homekit under iOS 14.4.

Hello,

this library is exactly what I was looking for. Easily create some lights to integrate into homekit without an additional bridge etc. Thanks a lot for this!

I tried several of the example sketches but were never able to successfully pair with HomeKit. I used my iPhone 12 mini with the first public beta of iOS 14.4.
Just now I used an old iPad with 12.4. installed and pairing worked without problem. So maybe they changed something?

This is the Output on Serial:

16:33:34.400 -> >>> HomeKit: Init server over
16:38:22.055 -> >>> HomeKit: WiFiServer receives a new client (current 0, max 4)
16:38:22.055 -> >>> HomeKit: Got new client connection: local 192.168.177.135:5556, remote 192.168.177.172:56389
16:38:22.089 -> >>> HomeKit: [Client 1073698628] Got 129 incomming data, encrypted is
16:38:22.089 -> >>> HomeKit: [Client 1073698628] Pair Setup Step 1/3
16:38:49.304 -> >>> HomeKit: [Client 1073698628] Got 582 incomming data, encrypted is
16:38:49.338 -> >>> HomeKit: [Client 1073698628] Pair Setup Step 2/3
16:38:49.338 -> >>> HomeKit: [Client 1073698628] Computing SRP shared secret
16:39:02.471 -> >>> HomeKit: [Client 1073698628] Verifying peer's proof
16:39:02.471 -> >>> HomeKit: [Client 1073698628] Generating own proof
16:39:02.576 -> >>> HomeKit: [Client 1073698628] Got 284 incomming data, encrypted is
16:39:02.576 -> >>> HomeKit: [Client 1073698628] Pair Setup Step 3/3
16:39:03.508 -> >>> HomeKit: Added pairing with 41E4BE6F-D3F6-4F78-AF13-8BF51D5F472F
16:39:03.579 -> >>> HomeKit: Free saved_preinit_pairing_context
16:39:03.579 -> >>> HomeKit: Configuring mDNS
16:39:03.579 -> >>> HomeKit: MDNS.restart: EspLed-59F3, IP: 192.168.177.135
16:39:03.579 -> >>> HomeKit: MDNS.begin: EspLed-59F3, IP: 192.168.177.135
16:39:03.616 -> >>> HomeKit: [Client 1073698628] Successfully paired
16:39:03.687 -> >>> HomeKit: [Client 1073698628] Disconnected!
16:39:03.687 -> >>> HomeKit: Free heap: 26472
16:39:03.720 -> >>> HomeKit: [Client 1073698628] Closing client connection
16:39:03.720 -> >>> HomeKit: WiFiServer receives a new client (current 0, max 4)
16:39:03.720 -> >>> HomeKit: Got new client connection: local 192.168.177.135:5556, remote 192.168.177.172:56390
16:39:03.720 -> >>> HomeKit: [Client 1073698628] Got 162 incomming data, encrypted is
16:39:03.754 -> >>> HomeKit: [Client 1073698628] Pair Verify Step 1/2
16:39:04.370 -> >>> HomeKit: Free heap: 25472
16:39:04.438 -> >>> HomeKit: [Client 1073698628] Got 251 incomming data, encrypted is
16:39:04.438 -> >>> HomeKit: [Client 1073698628] Pair Verify Step 2/2
16:39:04.438 -> >>> HomeKit: [Client 1073698628] Found pairing with 41E4BE6F-D3F6-4F78-AF13-8BF51D5F472F
16:39:05.975 -> >>> HomeKit: [Client 1073698628] Verification successful, secure session established
16:39:05.975 -> >>> HomeKit: Free heap: 25280
16:39:06.041 -> >>> HomeKit: [Client 1073698628] Disconnected!
16:39:06.041 -> >>> HomeKit: Free heap: 26280
16:39:06.041 -> >>> HomeKit: [Client 1073698628] Closing client connection

On the iOS side: I enter the pasword (all 1s) then it starts to pair but never finishes. I waited quite a bit, but nothing.
I have deleted the pair.dat through the webserver and then tried again several times, but it never finishes.

The QR-Code is not generated properly. After uploading the sketch the setup.html is 0 KB. After the failed pairing the QR-code is generated, but when I use it, Homekit tells me I have to reset the device, because it is already paired. But it is not visible in Homekit.

Setup: LOLin v3 NodeMCU ESP8622
MacOS Catalina 10.14.6

Serial Monitor overflowing with "Got characteristic X.XX change event"

I'm getting serial monitor overflowing with the following data every time I open the application on my iPhone:


HomeKit: [Client 1073688948] Got characteristic 1.10 change event
HomeKit: [Client 1073688948] Got characteristic 1.13 change event
HomeKit: [Client 1073688948] Got characteristic 1.10 change event
HomeKit: [Client 1073688948] Got characteristic 1.13 change event
HomeKit: [Client 1073688948] Got characteristic 1.10 change event
HomeKit: [Client 1073688948] Got characteristic 1.13 change event
HomeKit: [Client 1073688948] Got characteristic 1.10 change event


and that repeats for long time even I I close the application (maybe still displays what's in the buffer?)
then after some time there the following error:


HomeKit: [Client 1073697900] Got characteristic 1.10 change event
HomeKit: [Client 1073697900] Got characteristic 1.13 change event
!!! HomeKit: [Client 1073697900] error_in_write_data is true, abort write data
!!! HomeKit: [Client 1073697900] error_in_write_data is true, abort write data
!!! HomeKit: [Client 1073697900] error_in_write_data is true, abort write data
HomeKit: [Client 1073697900] Got characteristic 1.10 change event
HomeKit: [Client 1073697900] Got characteristic 1.13 change event
!!! HomeKit: [Client 1073697900] error_in_write_data is true, abort write data
!!! HomeKit: [Client 1073697900] error_in_write_data is true, abort write data
!!! HomeKit: [Client 1073697900] error_in_write_data is true, abort write data
HomeKit: [Client 1073697900] Got characteristic 1.10 change event
HomeKit: [Client 1073697900] Got characteristic 1.13 change event


you have my sketch in #2.
it happens even if I remove the second sensor and use only temperature sensor
the application appears to work OK, but there is definitely something going wrong for that much chatter on the serial monitor...
Please help

Accessory not showing up for pairing any longer?

@Yurik72 I'm experiencing strange problem. So is friend of mine @mlanziner who is trying the same thing on different computer. The problem is that after successful compiling of the new example, the accessory does not show up as accessory available for pairing. Now even my old code that I sent you before for DHT11 is behaving the same.
On very rare occasions I see the accessory showing up or pairing but then it does not complete the paring process successfully on the iPhone. On the terminal window it shows pairing is successful, but is usually much shorter on messages that what I've seen before when it use to actually do pair successfully.
I tried formating the entire flash, and formating the SPIFS as well. No luck.
Here is the log from my serial terminal after reboot and one of the rare cases that it showed for pairing but actually failed pairing on the iPhone. your example code has not been changed, except I added format for SPIFFS and change the pin for DHT11 to GPIO2
`ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1392, room 16
tail 0
chksum 0xd0
csum 0xd0
v3d128e5c
~ld
Please wait few seconds for SPIFFS to be formatted
SPIFFS formatted
Grapevine
..
IP address:
192.168.1.107
Free heap: 36336
init_hap_storageFailed to read pair.dat

Home Integration: hap_services added chararacteristic 0: 23
Home Integration: hap_services added chararacteristic 1: 11
Home Integration: add_hum as accessory , next accessory 2
Home Integration: homekit_is_paired 0
HomeKit: Update the CPU to run at 160MHz
HomeKit: Free heap: 33424
HomeKit: Starting server
HomeKit: Formatting flash at 0x200000
HomeKit: storage init 1
HomeKit: if r
HomeKit: generating id
HomeKit: Generated new accessory ID: 82:A8:A3:40:34:B5
HomeKit: Generated new accessory ID: 1073688596
HomeKit: key generated
HomeKit: key saved
HomeKit: Generated new accessory key
HomeKit: find pairings
HomeKit: Preinit pairing context
HomeKit: Using user-specified password: 111-11-111
HomeKit: Free heap: 30800
HomeKit: Calculating public key len=384
HomeKit: Calculating public key result 0
HomeKit: arduino_homekit_preinit success
HomeKit: Configuring mDNS
HomeKit: MDNS.begin: ES-F118, IP: 192.168.1.107
HomeKit: Init server over
Web server is NOT SET, waiting for pairing
Temp21.90 Hum:62.00
Temp24.00 Hum:44.00
Temp24.10 Hum:43.00
HomeKit: WiFi connected, ip: 192.168.1.107, mask: 255.255.255.0, gw: 192.168.1.254
HomeKit: Configuring mDNS
HomeKit: MDNS.restart: ES-F118, IP: 192.168.1.107
HomeKit: MDNS.begin: ES-F118, IP: 192.168.1.107
Temp24.20 Hum:42.00
Temp24.30 Hum:41.00
Temp24.40 Hum:40.00
HomeKit: WiFiServer receives a new client (current 0, max 4)
HomeKit: Got new client connection: local 192.168.1.107:5556, remote 192.168.1.104:56576
HomeKit: [Client 1073696140] Got 125 incomming data, encrypted is
HomeKit: [Client 1073696140] Pair Setup Step 1/3
HomeKit: [Client 1073696140] Got 578 incomming data, encrypted is
HomeKit: [Client 1073696140] Pair Setup Step 2/3
HomeKit: [Client 1073696140] Computing SRP shared secret
HomeKit: [Client 1073696140] Verifying peer's proof
HomeKit: [Client 1073696140] Generating own proof
Temp24.50 Hum:40.00
HomeKit: [Client 1073696140] Got 280 incomming data, encrypted is
HomeKit: [Client 1073696140] Pair Setup Step 3/3
HomeKit: Added pairing with 31C042E2-1767-4A74-8CF9-AF735720357B
HomeKit: Free saved_preinit_pairing_context
HomeKit: Configuring mDNS
HomeKit: MDNS.restart: ES-F118, IP: 192.168.1.107
HomeKit: MDNS.begin: ES-F118, IP: 192.168.1.107
HomeKit: [Client 1073696140] Successfully paired
HomeKit: [Client 1073696140] Disconnected!
HomeKit: Free heap: 29656
HomeKit: [Client 1073696140] Closing client connection
Temp24.90 Hum:39.00
Temp25.00 Hum:39.00
Temp25.20 Hum:38.00
Temp25.40 Hum:38.00
Temp25.60 Hum:37.00
Temp25.80 Hum:37.00

`

and here is an example of what ussulay shows on the serial terminal screen after reboot, but nothing chows as available to pair in home kit:
`
ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1392, room 16
tail 0
chksum 0xd0
csum 0xd0
v3d128e5c
~ld
Please wait few seconds for SPIFFS to be formatted
SPIFFS formatted
Grapevine
.....
IP address:
192.168.1.107
Free heap: 36336
init_hap_storageFailed to read pair.dat

Home Integration: hap_services added chararacteristic 0: 23
Home Integration: hap_services added chararacteristic 1: 11
Home Integration: add_hum as accessory , next accessory 2
Home Integration: homekit_is_paired 0
HomeKit: Update the CPU to run at 160MHz
HomeKit: Free heap: 33424
HomeKit: Starting server
HomeKit: Formatting flash at 0x200000
HomeKit: storage init 1
HomeKit: if r
HomeKit: generating id
HomeKit: Generated new accessory ID: 0F:57:B3:66:17:F2
HomeKit: Generated new accessory ID: 1073688596
HomeKit: key generated
HomeKit: key saved
HomeKit: Generated new accessory key
HomeKit: find pairings
HomeKit: Preinit pairing context
HomeKit: Using user-specified password: 111-11-111
HomeKit: Free heap: 30800
HomeKit: Calculating public key len=384
HomeKit: Calculating public key result 0
HomeKit: arduino_homekit_preinit success
HomeKit: Configuring mDNS
HomeKit: Init server over
Web server is NOT SET, waiting for pairing
Temp26.30 Hum:50.00
Temp26.00 Hum:42.00
HomeKit: WiFi connected, ip: 192.168.1.107, mask: 255.255.255.0, gw: 192.168.1.254
HomeKit: Configuring mDNS
HomeKit: MDNS.begin: ES-66DD, IP: 192.168.1.107
Temp25.80 Hum:39.00
Temp25.80 Hum:38.00
Temp25.80 Hum:38.00
Temp25.80 Hum:38.00
Temp25.70 Hum:37.00
Temp25.80 Hum:38.00
Temp25.70 Hum:38.00
`
My buddy's problem is exactly the same as mine, except I don't think he've seen the accessory available for pairing on rare occasion. I wonder if some update screw the working of the mDNS or something else.
Any ideas?
Cheers!

Using HTTPClient in sketch gives error

Hi

Im trying to add a url POST action to my sketch. But when adding this line this line to my code:
HTTPClient http;

I get this error:
/Users/jonasborneland/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: /Users/jonasborneland/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/tools/sdk/lib/libaxtls.a(crypto_misc.o): in function base64_decode':
xtensa-lx106-elfhome/earle/src/axtls-8266/crypto/crypto_misc.c:327: multiple definition of base64_decode'; libraries/ESPHap-master/base64.c.o:/Users/jonasborneland/Documents/Arduino/libraries/ESPHap-master/base64.c:64: first defined here collect2: error: ld returned 1 exit status exit status 1 Error compiling for board NodeMCU 1.0 (ESP-12E Module).

I have included ESP8266HTTPClient.h:
#include <ESP8266HTTPClient.h>

Compiling with platformio

Hello!

You made a great library. Everything works with Arduino IDE, but Arduino IDE is absolutely not convenient to use. I prefer to use Platformio IDE for my home automation. Some strange things happens when using this library with Platformio. Сompiler does not see some functions from homeintegration.h.

ESPHap example EspHapLed for ESP32 compiles with Platformio, but simple modifications of this example gives error while compiling with Platformio (compiles well with Arduino IDE).

Modification is the replacement of an accessory from lightbulb to switch:
hap_setbase_accessorytype(homekit_accessory_category_switch);
hap_initbase_accessory_service("host", "Yurik72", "0", "EspHapLed", "1.0");
hapservice = hap_add_switch_service("FAN", led_callback, (void*)&led_gpio);

This giving next error:
src/main.cpp: In function 'void setup()':
src/main.cpp:152:76: error: 'hap_add_switch_service' was not declared in this scope

Update:
It looks like it's a Mac OS Catalina and newer related issue.

Typo in accessories.c

There is a typo in accessories.c on line 3, double "at the end of the line, giving a warning on compilation

Add to the homeintegration.c & second setup accessory for one ESP

Hi,

Is it possible that you could add this to the homeintegration.c? I've programmed this piece of code for my ceiling fan, by adding this code you can edit the rotation speed and direction. The min_step can be removed, since this is what I personally want. If you try to add a fan it will not work by default.

Another thing, I try to figure out how I'm able to use the same ESP(32) to run two homekit "devices". Meaning that when I have a fan but I need to add it as a new device to the Home app. I have a couple of fan's but I don't want to share my fan with other people, it seems better solution to make an different setup so that an other person can add it to their Home app. Of course, using a second ESP board is a solution but it is a struggle.

homekit_service_t* hap_new_fan_service(const char* szname, hap_callback cb, void* context) {
	return NEW_HOMEKIT_SERVICE(FAN2, .characteristics = (homekit_characteristic_t*[]) {
		NEW_HOMEKIT_CHARACTERISTIC(NAME, szname),
		NEW_HOMEKIT_CHARACTERISTIC(ROTATION_DIRECTION, 0, .callback=HOMEKIT_CHARACTERISTIC_CALLBACK(cb, .context=context)),
		NEW_HOMEKIT_CHARACTERISTIC(ACTIVE, 0, .callback=HOMEKIT_CHARACTERISTIC_CALLBACK(cb, .context=context),
),
		NEW_HOMEKIT_CHARACTERISTIC(ROTATION_SPEED, 0,  .min_step = (float[]) {16.666}, .callback=HOMEKIT_CHARACTERISTIC_CALLBACK(cb, .context=context)

),
NULL
	});
}

How to make Switch with no webserver on ESP8266 ?

Hi,

THANKS for this project it's GREAT :-)

I'm trying to make a switch without webserver, tried to undefine the below, but getting errors about server when compiling

//#define ENABLE_WIFI_MANAGER // if we want to have built-in wifi configuration
// Otherwise direct connect ssid and pwd will be used
// for Wifi manager need extra library //https://github.com/tzapu/WiFiManager

//#define ENABLE_WEB_SERVER //if we want to have built in web server /site
//#define ENABLE_OTA //if Over the air update need , ENABLE_WEB_SERVER must be defined first

Any pointers?
Best regards,
Christian

Initial value bool error with INIT_CHARACHTERISTIC_VAL(bool,ch,false);

Hi,

When I try to implement initial value from the library API description, I get and bool and ch not declared error?

Optinally you can set a default (initial) value to be informed Apple about initial state

homekit_characteristic_t * ch= homekit_service_characteristic_by_type(hapservice, HOMEKIT_CHARACTERISTIC_ON);
INIT_CHARACHTERISTIC_VAL(bool,ch,false); // will inform apple that lights is OFF

I get this error:

EspHapSwitch8266_Double_Web:146:27: error: expected primary-expression before 'bool'
INIT_CHARACHTERISTIC_VAL(bool,ch,false); // will inform apple that lights is OFF
^
EspHapSwitch8266_Double_Web:146:32: error: 'ch' was not declared in this scope
INIT_CHARACHTERISTIC_VAL(bool,ch,false); // will inform apple that lights is OFF
^
EspHapSwitch8266_Double_Web:146:40: error: 'INIT_CHARACHTERISTIC_VAL' was not declared in this scope
INIT_CHARACHTERISTIC_VAL(bool,ch,false); // will inform apple that lights is OFF

Best regards,
Christian

Прошивка на 4 датчика температуры на SONOFF с интеграцией Homekit

Здравствуйте!

Заинтересовал проект умного дома на Homekit, но везде есть только один вариант одно устройство один датчик, А у меня есть контроллеры которые имеют по 4 и более датчиков (DS18B20). Если все это попробовать интегрировать в homekt, то придется ставить на каждый датчик отдельное устройство, что не есть удобно в моем случае.

Если это возможно просьба помочь в написании такой прошивки.
Заранее благодарю.

С уважением, Андрей

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.