Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit in the number of devices? #712

Closed
homonto opened this issue Dec 11, 2023 · 33 comments
Closed

Limit in the number of devices? #712

homonto opened this issue Dec 11, 2023 · 33 comments

Comments

@homonto
Copy link

homonto commented Dec 11, 2023

Hi,

So I've built a bridge with 8 remote sensors - ESPnow.
Each provides: temperature, humidity, light, charging and battery.
Bridge provides only charging and battery.
What I am seeing is: the moment I add 8th sensor I am not getting the result I wanted.
Is there any limitation?

this is the beginning of the run with all info:

20:13:06.710 > 
20:13:06.710 > ************************************************************
20:13:06.710 > Welcome to HomeSpan!
20:13:06.710 > Apple HomeKit for the Espressif ESP-32 WROOM and Arduino IDE
20:13:06.715 > ************************************************************
20:13:06.720 > 
20:13:06.720 > ** Please ensure serial monitor is set to transmit <newlines>
20:13:06.726 > 
20:13:06.726 > Message Logs:     Level 0
20:13:06.729 > Status LED:       Pin 33
20:13:06.731 > Device Control:   Pin 23
20:13:06.731 > Sketch Version:   127.231211.2012
20:13:06.734 > HomeSpan Version: 1.8.0
20:13:06.737 > Arduino-ESP Ver.: 2.0.11
20:13:06.740 > ESP-IDF Version:  4.4.5
20:13:06.743 > ESP32 Chip:       ESP32-D0WDQ6 Rev 1 dual-core 4MB Flash
20:13:06.745 > ESP32 Board:      esp32
20:13:06.748 > PWM Resources:    16 channels, 8 timers, max 20-bit duty resolution
20:13:06.754 > Sodium Version:   1.0.12-idf  Lib 9.4
20:13:06.757 > MbedTLS Version:  mbed TLS 2.28.3
20:13:06.762 > Sketch Compiled:  Dec 11 2023 19:44:20
20:13:06.765 > Partition:        app0
20:13:06.765 > MAC Address:      1A:FF:01:01:01:01
20:13:06.770 > 
20:13:06.770 > Device Name:      bridge1
20:13:06.770 > 
20:13:06.770 > [setup]: !!! OTA NOT ENABLED !!! 
20:13:06.776 > [setup]: ========== Setup finished ==========
20:13:06.779 > 
20:13:06.779 > 
20:13:06.779 > *** HomeSpan Info ***
20:13:06.781 > 
20:13:06.781 > ➤ Accessory:  AID=1
20:13:06.781 >    ➟ Service AccessoryInformation:  IID=1, UUID="3E"
20:13:06.787 >       ⇨ Characteristic Name("bridge1"):  IID=2, UUID="23", Perms=PR
20:13:06.793 >       ⇨ Characteristic Manufacturer("PAPIO LTD"):  IID=3, UUID="20", Perms=PR
20:13:06.801 >       ⇨ Characteristic SerialNumber("0cb815cd4d3c_010101"):  IID=4, UUID="30", Perms=PR
20:13:06.809 >       ⇨ Characteristic Model("ESP32"):  IID=5, UUID="21", Perms=PR
20:13:06.815 >       ⇨ Characteristic FirmwareRevision("127.231211.2012"):  IID=6, UUID="52", Perms=PR EV
20:13:06.823 >       ⇨ Characteristic Identify(0):  IID=7, UUID="14", Perms=PW
20:13:06.829 >    ➟ Service BatteryService:  IID=8, UUID="96"
20:13:06.831 >       ⇨ Characteristic Name("Battery sensor"):  IID=9, UUID="23", Perms=PR
20:13:06.840 >       ⇨ Characteristic BatteryLevel(50):  IID=10, UUID="68", Perms=PR EV, Range=[0,100]
20:13:06.849 >       ⇨ Characteristic ChargingState(0):  IID=11, UUID="8F", Perms=PR EV, Range=[0,2]
20:13:06.854 >       ⇨ Characteristic StatusLowBattery(0):  IID=12, UUID="79", Perms=PR EV, Range=[0,1]
20:13:06.862 > ➤ Accessory:  AID=2
20:13:06.865 >    ➟ Service AccessoryInformation:  IID=1, UUID="3E"
20:13:06.870 >       ⇨ Characteristic Identify(0):  IID=2, UUID="14", Perms=PW
20:13:06.876 >       ⇨ Characteristic Name("box 1 sensors"):  IID=3, UUID="23", Perms=PR
20:13:06.881 >       ⇨ Characteristic SerialNumber("1A:01:01:01:01:01"):  IID=4, UUID="30", Perms=PR
20:13:06.890 >       ⇨ Characteristic FirmwareRevision(""):  IID=5, UUID="52", Perms=PR EV
20:13:06.895 >    ➟ Service TemperatureSensor:  IID=6, UUID="8A"
20:13:06.901 >       ⇨ Characteristic CurrentTemperature(0):  IID=7, UUID="11", Perms=PR EV, Custom-Range=[-50,150]
20:13:06.909 >       ⇨ Characteristic StatusFault(0):  IID=8, UUID="77", Perms=PR EV, Range=[0,1]
20:13:06.918 >    ➟ Service HumiditySensor:  IID=9, UUID="82"
20:13:06.920 >       ⇨ Characteristic CurrentRelativeHumidity(0):  IID=10, UUID="10", Perms=PR EV, Custom-Range=[0,100]
20:13:06.931 >       ⇨ Characteristic StatusFault(0):  IID=11, UUID="77", Perms=PR EV, Range=[0,1]
20:13:06.937 >    ➟ Service LightSensor:  IID=12, UUID="84"
20:13:06.943 >       ⇨ Characteristic CurrentAmbientLightLevel(0.1):  IID=13, UUID="6B", Perms=PR EV, Range=[0.0001,100000]
20:13:06.951 >       ⇨ Characteristic StatusFault(0):  IID=14, UUID="77", Perms=PR EV, Range=[0,1]
20:13:06.959 >    ➟ Service BatteryService:  IID=15, UUID="96"
20:13:06.962 >       ⇨ Characteristic Name("Battery sensor"):  IID=16, UUID="23", Perms=PR
20:13:06.970 >       ⇨ Characteristic BatteryLevel(0):  IID=17, UUID="68", Perms=PR EV, Range=[0,100]
20:13:06.979 >       ⇨ Characteristic ChargingState(0):  IID=18, UUID="8F", Perms=PR EV, Range=[0,2]
20:13:06.984 >       ⇨ Characteristic StatusLowBattery(1):  IID=19, UUID="79", Perms=PR EV, Range=[0,1]
20:13:06.993 > ➤ Accessory:  AID=3
20:13:06.995 >    ➟ Service AccessoryInformation:  IID=1, UUID="3E"
20:13:07.001 >       ⇨ Characteristic Identify(0):  IID=2, UUID="14", Perms=PW
20:13:07.006 >       ⇨ Characteristic Name("box 2 sensors"):  IID=3, UUID="23", Perms=PR
20:13:07.012 >       ⇨ Characteristic SerialNumber("1A:01:01:01:01:02"):  IID=4, UUID="30", Perms=PR
20:13:07.020 >       ⇨ Characteristic FirmwareRevision(""):  IID=5, UUID="52", Perms=PR EV
20:13:07.026 >    ➟ Service TemperatureSensor:  IID=6, UUID="8A"
20:13:07.031 >       ⇨ Characteristic CurrentTemperature(0):  IID=7, UUID="11", Perms=PR EV, Custom-Range=[-50,150]
20:13:07.040 >       ⇨ Characteristic StatusFault(0):  IID=8, UUID="77", Perms=PR EV, Range=[0,1]
20:13:07.048 >    ➟ Service HumiditySensor:  IID=9, UUID="82"
20:13:07.051 >       ⇨ Characteristic CurrentRelativeHumidity(0):  IID=10, UUID="10", Perms=PR EV, Custom-Range=[0,100]
20:13:07.062 >       ⇨ Characteristic StatusFault(0):  IID=11, UUID="77", Perms=PR EV, Range=[0,1]
20:13:07.068 >    ➟ Service LightSensor:  IID=12, UUID="84"
20:13:07.073 >       ⇨ Characteristic CurrentAmbientLightLevel(0.1):  IID=13, UUID="6B", Perms=PR EV, Range=[0.0001,100000]
20:13:07.081 >       ⇨ Characteristic StatusFault(0):  IID=14, UUID="77", Perms=PR EV, Range=[0,1]
20:13:07.090 >    ➟ Service BatteryService:  IID=15, UUID="96"
20:13:07.095 >       ⇨ Characteristic Name("Battery sensor"):  IID=16, UUID="23", Perms=PR
20:13:07.101 >       ⇨ Characteristic BatteryLevel(0):  IID=17, UUID="68", Perms=PR EV, Range=[0,100]
20:13:07.109 >       ⇨ Characteristic ChargingState(0):  IID=18, UUID="8F", Perms=PR EV, Range=[0,2]
20:13:07.115 >       ⇨ Characteristic StatusLowBattery(1):  IID=19, UUID="79", Perms=PR EV, Range=[0,1]
20:13:07.123 > ➤ Accessory:  AID=4
20:13:07.126 >    ➟ Service AccessoryInformation:  IID=1, UUID="3E"
20:13:07.131 >       ⇨ Characteristic Identify(0):  IID=2, UUID="14", Perms=PW
20:13:07.137 >       ⇨ Characteristic Name("box 3 sensors"):  IID=3, UUID="23", Perms=PR
20:13:07.143 >       ⇨ Characteristic SerialNumber("1A:01:01:01:01:03"):  IID=4, UUID="30", Perms=PR
20:13:07.151 >       ⇨ Characteristic FirmwareRevision(""):  IID=5, UUID="52", Perms=PR EV
20:13:07.156 >    ➟ Service TemperatureSensor:  IID=6, UUID="8A"
20:13:07.162 >       ⇨ Characteristic CurrentTemperature(0):  IID=7, UUID="11", Perms=PR EV, Custom-Range=[-50,150]
20:13:07.170 >       ⇨ Characteristic StatusFault(0):  IID=8, UUID="77", Perms=PR EV, Range=[0,1]
20:13:07.179 >    ➟ Service HumiditySensor:  IID=9, UUID="82"
20:13:07.182 >       ⇨ Characteristic CurrentRelativeHumidity(0):  IID=10, UUID="10", Perms=PR EV, Custom-Range=[0,100]
20:13:07.193 >       ⇨ Characteristic StatusFault(0):  IID=11, UUID="77", Perms=PR EV, Range=[0,1]
20:13:07.198 >    ➟ Service LightSensor:  IID=12, UUID="84"
20:13:07.204 >       ⇨ Characteristic CurrentAmbientLightLevel(0.1):  IID=13, UUID="6B", Perms=PR EV, Range=[0.0001,100000]
20:13:07.212 >       ⇨ Characteristic StatusFault(0):  IID=14, UUID="77", Perms=PR EV, Range=[0,1]
20:13:07.220 >    ➟ Service BatteryService:  IID=15, UUID="96"
20:13:07.226 >       ⇨ Characteristic Name("Battery sensor"):  IID=16, UUID="23", Perms=PR
20:13:07.231 >       ⇨ Characteristic BatteryLevel(0):  IID=17, UUID="68", Perms=PR EV, Range=[0,100]
20:13:07.240 >       ⇨ Characteristic ChargingState(0):  IID=18, UUID="8F", Perms=PR EV, Range=[0,2]
20:13:07.248 >       ⇨ Characteristic StatusLowBattery(1):  IID=19, UUID="79", Perms=PR EV, Range=[0,1]
20:13:07.254 > ➤ Accessory:  AID=5
20:13:07.257 >    ➟ Service AccessoryInformation:  IID=1, UUID="3E"
20:13:07.262 >       ⇨ Characteristic Identify(0):  IID=2, UUID="14", Perms=PW
20:13:07.268 >       ⇨ Characteristic Name("box 4 sensors"):  IID=3, UUID="23", Perms=PR
20:13:07.273 >       ⇨ Characteristic SerialNumber("1A:01:01:01:01:04"):  IID=4, UUID="30", Perms=PR
20:13:07.281 >       ⇨ Characteristic FirmwareRevision(""):  IID=5, UUID="52", Perms=PR EV
20:13:07.287 >    ➟ Service TemperatureSensor:  IID=6, UUID="8A"
20:13:07.293 >       ⇨ Characteristic CurrentTemperature(0):  IID=7, UUID="11", Perms=PR EV, Custom-Range=[-50,150]
20:13:07.301 >       ⇨ Characteristic StatusFault(0):  IID=8, UUID="77", Perms=PR EV, Range=[0,1]
20:13:07.309 >    ➟ Service HumiditySensor:  IID=9, UUID="82"
20:13:07.312 >       ⇨ Characteristic CurrentRelativeHumidity(0):  IID=10, UUID="10", Perms=PR EV, Custom-Range=[0,100]
20:13:07.323 >       ⇨ Characteristic StatusFault(0):  IID=11, UUID="77", Perms=PR EV, Range=[0,1]
20:13:07.331 >    ➟ Service BatteryService:  IID=12, UUID="96"
20:13:07.334 >       ⇨ Characteristic Name("Battery sensor"):  IID=13, UUID="23", Perms=PR
20:13:07.343 >       ⇨ Characteristic BatteryLevel(0):  IID=14, UUID="68", Perms=PR EV, Range=[0,100]
20:13:07.348 >       ⇨ Characteristic ChargingState(0):  IID=15, UUID="8F", Perms=PR EV, Range=[0,2]
20:13:07.357 >       ⇨ Characteristic StatusLowBattery(1):  IID=16, UUID="79", Perms=PR EV, Range=[0,1]
20:13:07.365 > ➤ Accessory:  AID=6
20:13:07.368 >    ➟ Service AccessoryInformation:  IID=1, UUID="3E"
20:13:07.370 >       ⇨ Characteristic Identify(0):  IID=2, UUID="14", Perms=PW
20:13:07.376 >       ⇨ Characteristic Name("box 5 sensors"):  IID=3, UUID="23", Perms=PR
20:13:07.384 >       ⇨ Characteristic SerialNumber("1A:01:01:01:01:05"):  IID=4, UUID="30", Perms=PR
20:13:07.390 >       ⇨ Characteristic FirmwareRevision(""):  IID=5, UUID="52", Perms=PR EV
20:13:07.398 >    ➟ Service TemperatureSensor:  IID=6, UUID="8A"
20:13:07.404 >       ⇨ Characteristic CurrentTemperature(0):  IID=7, UUID="11", Perms=PR EV, Custom-Range=[-50,150]
20:13:07.412 >       ⇨ Characteristic StatusFault(0):  IID=8, UUID="77", Perms=PR EV, Range=[0,1]
20:13:07.418 >    ➟ Service HumiditySensor:  IID=9, UUID="82"
20:13:07.423 >       ⇨ Characteristic CurrentRelativeHumidity(0):  IID=10, UUID="10", Perms=PR EV, Custom-Range=[0,100]
20:13:07.431 >       ⇨ Characteristic StatusFault(0):  IID=11, UUID="77", Perms=PR EV, Range=[0,1]
20:13:07.440 >    ➟ Service LightSensor:  IID=12, UUID="84"
20:13:07.443 >       ⇨ Characteristic CurrentAmbientLightLevel(0.1):  IID=13, UUID="6B", Perms=PR EV, Range=[0.0001,100000]
20:13:07.454 >       ⇨ Characteristic StatusFault(0):  IID=14, UUID="77", Perms=PR EV, Range=[0,1]
20:13:07.462 >    ➟ Service BatteryService:  IID=15, UUID="96"
20:13:07.465 >       ⇨ Characteristic Name("Battery sensor"):  IID=16, UUID="23", Perms=PR
20:13:07.473 >       ⇨ Characteristic BatteryLevel(0):  IID=17, UUID="68", Perms=PR EV, Range=[0,100]
20:13:07.479 >       ⇨ Characteristic ChargingState(0):  IID=18, UUID="8F", Perms=PR EV, Range=[0,2]
20:13:07.487 >       ⇨ Characteristic StatusLowBattery(1):  IID=19, UUID="79", Perms=PR EV, Range=[0,1]
20:13:07.495 > ➤ Accessory:  AID=7
20:13:07.498 >    ➟ Service AccessoryInformation:  IID=1, UUID="3E"
20:13:07.501 >       ⇨ Characteristic Identify(0):  IID=2, UUID="14", Perms=PW
20:13:07.506 >       ⇨ Characteristic Name("box 6 sensors"):  IID=3, UUID="23", Perms=PR
20:13:07.515 >       ⇨ Characteristic SerialNumber("1A:01:01:01:01:06"):  IID=4, UUID="30", Perms=PR
20:13:07.523 >       ⇨ Characteristic FirmwareRevision(""):  IID=5, UUID="52", Perms=PR EV
20:13:07.529 >    ➟ Service TemperatureSensor:  IID=6, UUID="8A"
20:13:07.534 >       ⇨ Characteristic CurrentTemperature(0):  IID=7, UUID="11", Perms=PR EV, Custom-Range=[-50,150]
20:13:07.543 >       ⇨ Characteristic StatusFault(0):  IID=8, UUID="77", Perms=PR EV, Range=[0,1]
20:13:07.551 >    ➟ Service HumiditySensor:  IID=9, UUID="82"
20:13:07.554 >       ⇨ Characteristic CurrentRelativeHumidity(0):  IID=10, UUID="10", Perms=PR EV, Custom-Range=[0,100]
20:13:07.562 >       ⇨ Characteristic StatusFault(0):  IID=11, UUID="77", Perms=PR EV, Range=[0,1]
20:13:07.570 >    ➟ Service LightSensor:  IID=12, UUID="84"
20:13:07.576 >       ⇨ Characteristic CurrentAmbientLightLevel(0.1):  IID=13, UUID="6B", Perms=PR EV, Range=[0.0001,100000]
20:13:07.584 >       ⇨ Characteristic StatusFault(0):  IID=14, UUID="77", Perms=PR EV, Range=[0,1]
20:13:07.593 >    ➟ Service BatteryService:  IID=15, UUID="96"
20:13:07.595 >       ⇨ Characteristic Name("Battery sensor"):  IID=16, UUID="23", Perms=PR
20:13:07.604 >       ⇨ Characteristic BatteryLevel(0):  IID=17, UUID="68", Perms=PR EV, Range=[0,100]
20:13:07.609 >       ⇨ Characteristic ChargingState(0):  IID=18, UUID="8F", Perms=PR EV, Range=[0,2]
20:13:07.618 >       ⇨ Characteristic StatusLowBattery(1):  IID=19, UUID="79", Perms=PR EV, Range=[0,1]
20:13:07.626 > ➤ Accessory:  AID=8
20:13:07.629 >    ➟ Service AccessoryInformation:  IID=1, UUID="3E"
20:13:07.631 >       ⇨ Characteristic Identify(0):  IID=2, UUID="14", Perms=PW
20:13:07.640 >       ⇨ Characteristic Name("box 7 sensors"):  IID=3, UUID="23", Perms=PR
20:13:07.645 >       ⇨ Characteristic SerialNumber("1A:01:01:01:01:07"):  IID=4, UUID="30", Perms=PR
20:13:07.653 >       ⇨ Characteristic FirmwareRevision(""):  IID=5, UUID="52", Perms=PR EV
20:13:07.659 >    ➟ Service TemperatureSensor:  IID=6, UUID="8A"
20:13:07.665 >       ⇨ Characteristic CurrentTemperature(0):  IID=7, UUID="11", Perms=PR EV, Custom-Range=[-50,150]
20:13:07.673 >       ⇨ Characteristic StatusFault(0):  IID=8, UUID="77", Perms=PR EV, Range=[0,1]
20:13:07.681 >    ➟ Service HumiditySensor:  IID=9, UUID="82"
20:13:07.684 >       ⇨ Characteristic CurrentRelativeHumidity(0):  IID=10, UUID="10", Perms=PR EV, Custom-Range=[0,100]
20:13:07.693 >       ⇨ Characteristic StatusFault(0):  IID=11, UUID="77", Perms=PR EV, Range=[0,1]
20:13:07.701 >    ➟ Service LightSensor:  IID=12, UUID="84"
20:13:07.706 >       ⇨ Characteristic CurrentAmbientLightLevel(0.1):  IID=13, UUID="6B", Perms=PR EV, Range=[0.0001,100000]
20:13:07.715 >       ⇨ Characteristic StatusFault(0):  IID=14, UUID="77", Perms=PR EV, Range=[0,1]
20:13:07.723 >    ➟ Service BatteryService:  IID=15, UUID="96"
20:13:07.726 >       ⇨ Characteristic Name("Battery sensor"):  IID=16, UUID="23", Perms=PR
20:13:07.734 >       ⇨ Characteristic BatteryLevel(0):  IID=17, UUID="68", Perms=PR EV, Range=[0,100]
20:13:07.743 >       ⇨ Characteristic ChargingState(0):  IID=18, UUID="8F", Perms=PR EV, Range=[0,2]
20:13:07.748 >       ⇨ Characteristic StatusLowBattery(1):  IID=19, UUID="79", Perms=PR EV, Range=[0,1]
20:13:07.756 > ➤ Accessory:  AID=9
20:13:07.759 >    ➟ Service AccessoryInformation:  IID=1, UUID="3E"
20:13:07.765 >       ⇨ Characteristic Identify(0):  IID=2, UUID="14", Perms=PW
20:13:07.770 >       ⇨ Characteristic Name("box 8 sensors"):  IID=3, UUID="23", Perms=PR
20:13:07.776 >       ⇨ Characteristic SerialNumber("1A:01:01:01:01:08"):  IID=4, UUID="30", Perms=PR
20:13:07.784 >       ⇨ Characteristic FirmwareRevision(""):  IID=5, UUID="52", Perms=PR EV
20:13:07.790 >    ➟ Service TemperatureSensor:  IID=6, UUID="8A"
20:13:07.795 >       ⇨ Characteristic CurrentTemperature(0):  IID=7, UUID="11", Perms=PR EV, Custom-Range=[-50,150]
20:13:07.804 >       ⇨ Characteristic StatusFault(0):  IID=8, UUID="77", Perms=PR EV, Range=[0,1]
20:13:07.812 >    ➟ Service HumiditySensor:  IID=9, UUID="82"
20:13:07.815 >       ⇨ Characteristic CurrentRelativeHumidity(0):  IID=10, UUID="10", Perms=PR EV, Custom-Range=[0,100]
20:13:07.826 >       ⇨ Characteristic StatusFault(0):  IID=11, UUID="77", Perms=PR EV, Range=[0,1]
20:13:07.831 >    ➟ Service LightSensor:  IID=12, UUID="84"
20:13:07.837 >       ⇨ Characteristic CurrentAmbientLightLevel(0.1):  IID=13, UUID="6B", Perms=PR EV, Range=[0.0001,100000]
20:13:07.845 >       ⇨ Characteristic StatusFault(0):  IID=14, UUID="77", Perms=PR EV, Range=[0,1]
20:13:07.854 >    ➟ Service BatteryService:  IID=15, UUID="96"
20:13:07.857 >       ⇨ Characteristic Name("Battery sensor"):  IID=16, UUID="23", Perms=PR
20:13:07.865 >       ⇨ Characteristic BatteryLevel(0):  IID=17, UUID="68", Perms=PR EV, Range=[0,100]
20:13:07.873 >       ⇨ Characteristic ChargingState(0):  IID=18, UUID="8F", Perms=PR EV, Range=[0,2]
20:13:07.879 >       ⇨ Characteristic StatusLowBattery(1):  IID=19, UUID="79", Perms=PR EV, Range=[0,1]
20:13:07.887 > 
20:13:07.887 > Configured as Bridge: NO
20:13:07.890 > 
20:13:07.890 > Database Validation:  Warnings=0, Errors=0
20:13:07.893 > 
20:13:07.893 > Service                             UUID         AID  IID  Update  Loop  Button  Linked Services
20:13:07.903 > ------------------------------  --------  ----------  ---  ------  ----  ------  ---------------
20:13:07.912 > AccessoryInformation                  3E           1    1     YES    NO      NO  -
20:13:07.918 > BatteryService                        96           1    8      NO   YES      NO  -
20:13:07.926 > AccessoryInformation                  3E           2    1      NO   YES      NO  -
20:13:07.931 > TemperatureSensor                     8A           2    6      NO   YES      NO  -
20:13:07.940 > HumiditySensor                        82           2    9      NO   YES      NO  -
20:13:07.948 > LightSensor                           84           2   12      NO   YES      NO  -
20:13:07.954 > BatteryService                        96           2   15      NO   YES      NO  -
20:13:07.962 > AccessoryInformation                  3E           3    1      NO   YES      NO  -
20:13:07.968 > TemperatureSensor                     8A           3    6      NO   YES      NO  -
20:13:07.976 > HumiditySensor                        82           3    9      NO   YES      NO  -
20:13:07.981 > LightSensor                           84           3   12      NO   YES      NO  -
20:13:07.990 > BatteryService                        96           3   15      NO   YES      NO  -
20:13:07.998 > AccessoryInformation                  3E           4    1      NO   YES      NO  -
20:13:08.004 > TemperatureSensor                     8A           4    6      NO   YES      NO  -
20:13:08.012 > HumiditySensor                        82           4    9      NO   YES      NO  -
20:13:08.018 > LightSensor                           84           4   12      NO   YES      NO  -
20:13:08.026 > BatteryService                        96           4   15      NO   YES      NO  -
20:13:08.034 > AccessoryInformation                  3E           5    1      NO   YES      NO  -
20:13:08.040 > TemperatureSensor                     8A           5    6      NO   YES      NO  -
20:13:08.048 > HumiditySensor                        82           5    9      NO   YES      NO  -
20:13:08.054 > BatteryService                        96           5   12      NO   YES      NO  -
20:13:08.062 > AccessoryInformation                  3E           6    1      NO   YES      NO  -
20:13:08.070 > TemperatureSensor                     8A           6    6      NO   YES      NO  -
20:13:08.076 > HumiditySensor                        82           6    9      NO   YES      NO  -
20:13:08.084 > LightSensor                           84           6   12      NO   YES      NO  -
20:13:08.090 > BatteryService                        96           6   15      NO   YES      NO  -
20:13:08.098 > AccessoryInformation                  3E           7    1      NO   YES      NO  -
20:13:08.106 > TemperatureSensor                     8A           7    6      NO   YES      NO  -
20:13:08.112 > HumiditySensor                        82           7    9      NO   YES      NO  -
20:13:08.120 > LightSensor                           84           7   12      NO   YES      NO  -
20:13:08.126 > BatteryService                        96           7   15      NO   YES      NO  -
20:13:08.134 > AccessoryInformation                  3E           8    1      NO   YES      NO  -
20:13:08.142 > TemperatureSensor                     8A           8    6      NO   YES      NO  -
20:13:08.148 > HumiditySensor                        82           8    9      NO   YES      NO  -
20:13:08.156 > LightSensor                           84           8   12      NO   YES      NO  -
20:13:08.162 > BatteryService                        96           8   15      NO   YES      NO  -
20:13:08.170 > AccessoryInformation                  3E           9    1      NO   YES      NO  -
20:13:08.179 > TemperatureSensor                     8A           9    6      NO   YES      NO  -
20:13:08.184 > HumiditySensor                        82           9    9      NO   YES      NO  -
20:13:08.192 > LightSensor                           84           9   12      NO   YES      NO  -
20:13:08.198 > BatteryService                        96           9   15      NO   YES      NO  -
20:13:08.206 > 
20:13:08.206 > Found 8 SpanPoint Links:
20:13:08.209 > 
20:13:08.209 > Local MAC Address  Remote MAC Address     Send  Receive    Depth
20:13:08.215 > -----------------  ------------------  -------  -------  -------
20:13:08.220 > 1A:FF:01:01:01:01   1A:01:01:01:01:01        0       36        1
20:13:08.226 > 1A:FF:01:01:01:01   1A:01:01:01:01:02        0       36        1
20:13:08.231 > 1A:FF:01:01:01:01   1A:01:01:01:01:03        0       36        1
20:13:08.237 > 1A:FF:01:01:01:01   1A:01:01:01:01:04        0       36        1
20:13:08.243 > 1A:FF:01:01:01:01   1A:01:01:01:01:05        0       36        1
20:13:08.248 > 1A:FF:01:01:01:01   1A:01:01:01:01:06        0       36        1
20:13:08.254 > 1A:FF:01:01:01:01   1A:01:01:01:01:07        0       36        1
20:13:08.259 > 1A:FF:01:01:01:01   1A:01:01:01:01:08        0       36        1
20:13:08.265 > 
20:13:08.265 > SpanPoint using WiFi Channel 1 (subject to change once WiFi connection established)
20:13:08.273 > 
20:13:24.858 > Starting HAP Server on port 80 supporting 11 simultaneous HomeKit Controller Connections...
20:13:24.866 > 
20:13:24.866 > 
20:13:24.866 > DEVICE NOT YET PAIRED -- PLEASE PAIR WITH HOMEKIT APP
20:13:24.872 > 

and the always the same error:

20:13:39.109 > E (42254) wifi:CCMP replay detected: A1=1a:ff:01:01:01:01 A2=1a:01:01:01:01:08 PN=1, RSC=6 seq=16
20:13:49.255 > E (52400) wifi:CCMP replay detected: A1=1a:ff:01:01:01:01 A2=1a:01:01:01:01:08 PN=1, RSC=6 seq=16
20:13:59.422 > E (62567) wifi:CCMP replay detected: A1=1a:ff:01:01:01:01 A2=1a:01:01:01:01:08 PN=1, RSC=6 seq=16
20:14:09.570 > E (72716) wifi:CCMP replay detected: A1=1a:ff:01:01:01:01 A2=1a:01:01:01:01:08 PN=1, RSC=6 seq=16
20:14:19.720 > E (82865) wifi:CCMP replay detected: A1=1a:ff:01:01:01:01 A2=1a:01:01:01:01:08 PN=1, RSC=6 seq=16
20:14:29.871 > E (93017) wifi:CCMP replay detected: A1=1a:ff:01:01:01:01 A2=1a:01:01:01:01:08 PN=1, RSC=6 seq=16
20:14:40.023 > E (103170) wifi:CCMP replay detected: A1=1a:ff:01:01:01:01 A2=1a:01:01:01:01:08 PN=1, RSC=6 seq=16
20:14:50.172 > E (113318) wifi:CCMP replay detected: A1=1a:ff:01:01:01:01 A2=1a:01:01:01:01:08 PN=1, RSC=6 seq=16

that is the received message from device number 8.

If I delete any device (1 to 8) there is no more problems (initially I thought device 8 is wrongly configured - but no, when I delete device 7, then device 8 is properly reporting).

Thank you for info.

@frankonski
Copy link
Contributor

There is major memory improvement done in the 1.8.1-dev branch, done as part of #684.
Can you test with this non-prod branch?

@homonto
Copy link
Author

homonto commented Dec 18, 2023

I will try and let you know, thank you @frankonski

@homonto
Copy link
Author

homonto commented Dec 19, 2023

so I tested both: 1.8.0 (current) and 1.8.1-dev
The difference of the free memory just after start is about 10kB
Unfortunately I tested with only 1 remote client, I am yet to test with 8 like before (problem is: I have only 1 with me now)
but lets see:

dev version 1.8.1:
Screenshot 2023-12-19 at 04 29 13

stable version 1.8.0:
Screenshot 2023-12-19 at 04 33 24

@homonto
Copy link
Author

homonto commented Dec 19, 2023

ok, apparently I don't need the physical devices to see the errors - I created again 10 remote devices and the outcome is:

05:45:50.383 > ======= S T A R T =======
05:45:50.503 > [change_mac]: OLD MAC: 0c:b8:15:cd:4d:3c
05:45:50.506 > [change_mac]: changing MAC...SUCCESSFULL
05:45:50.509 > [change_mac]: NEW MAC: 1a:ff:01:01:01:01
05:45:50.512 > [setup]: HOSTNAME: test-bridge-11
05:45:50.514 > [setup]: FW VERSION: 1.6.1
05:45:50.517 > [setup]: COMPILATION TIME: Dec 19 2023 05:44:13
05:45:50.523 > [setup]: BOARD TYPE: ESP32
05:45:50.526 > [setup]: Free heap=221224 bytes
05:45:50.528 > [setup]: BRIDGE_FW on HomeKit: 161.231219.0544
05:45:50.531 > [setup]: SERIAL NUMBER: 0cb815cd4d3c_010101
05:45:50.656 > E (426) ESPNOW: Peer is full
05:45:50.657 > E (428) ESPNOW: Peer is full
05:45:50.659 > E (430) ESPNOW: Peer is full
05:45:50.662 > E (432) ESPNOW: Peer is full
05:45:52.671 > 
05:45:52.671 > ************************************************************
05:45:52.673 > Welcome to HomeSpan!
05:45:52.676 > Apple HomeKit for the Espressif ESP-32 WROOM and Arduino IDE
05:45:52.682 > ************************************************************

...

05:45:54.512 > Found 10 SpanPoint Links:
05:45:54.515 > 
05:45:54.515 > Local MAC Address  Remote MAC Address     Send  Receive    Depth
05:45:54.520 > -----------------  ------------------  -------  -------  -------
05:45:54.526 > 1A:FF:01:01:01:01   1A:01:01:01:01:01        0       36        1
05:45:54.532 > 1A:FF:01:01:01:01   1A:01:01:01:01:02        0       36        1
05:45:54.537 > 1A:FF:01:01:01:01   1A:01:01:01:01:03        0       36        1
05:45:54.543 > 1A:FF:01:01:01:01   1A:01:01:01:01:04        0       36        1
05:45:54.548 > 1A:FF:01:01:01:01   1A:01:01:01:01:05        0       36        1
05:45:54.554 > 1A:FF:01:01:01:01   1A:01:01:01:01:06        0       36        1
05:45:54.559 > 1A:FF:01:01:01:01   1A:01:01:01:01:07        0       36        1
05:45:54.565 > 1A:FF:01:01:01:01   1A:01:01:01:01:08        0       36        1
05:45:54.571 > 1A:FF:01:01:01:01   1A:01:01:01:01:09        0       36        1
05:45:54.576 > 1A:FF:01:01:01:01   1A:01:01:01:01:44        0       36        1

so I expect the missing data again on the bridge, right?
if I get 4 errors having 10 remote sensors, it mean: only 6 remote are ok
and btw today only 6 boxes are reporting - not even 7 anymore.
Where is the catch?
What should I decrease (memory?) to have more boxes reporting?
Or maybe I should change ESP32 to ESP32-S3?
I will test with S3 also to see if there is any difference

@homonto
Copy link
Author

homonto commented Dec 19, 2023

unfortunately ESP32-S3 with 8MB did not help at all - same errors - any remote device above 6 is not working even though free heap is 268564 bytes:

06:16:44.629 > ======= S T A R T =======
06:16:44.629 > [change_mac]: OLD MAC: f4:12:fa:40:de:ac
06:16:44.629 > [change_mac]: changing MAC...SUCCESSFULL
06:16:44.629 > [change_mac]: NEW MAC: 1a:ff:01:01:01:01
06:16:44.629 > [setup]: HOSTNAME: test-bridge-12
06:16:44.629 > [setup]: FW VERSION: 1.6.2
06:16:44.629 > [setup]: COMPILATION TIME: Dec 19 2023 06:16:04
06:16:44.629 > [setup]: BOARD TYPE: ESP32S3
06:16:44.629 > [setup]: Free heap=268564 bytes
06:16:44.629 > [setup]: BRIDGE_FW on HomeKit: 162.231219.0616
06:16:44.629 > [setup]: SERIAL NUMBER: f412fa40deac_010101
06:16:44.629 > E (275) ESPNOW: Peer is full
06:16:44.629 > E (276) ESPNOW: Peer is full
06:16:44.629 > E (277) ESPNOW: Peer is full
06:16:44.629 > E (279) ESPNOW: Peer is full
06:16:46.062 > 
06:16:46.062 > ************************************************************
06:16:46.065 > Welcome to HomeSpan!
06:16:46.068 > Apple HomeKit for the Espressif ESP-32 WROOM and Arduino IDE
06:16:46.073 > ************************************************************
06:16:46.079 > 
06:16:46.079 > ** Please ensure serial monitor is set to transmit <newlines>
06:16:46.084 > 
06:16:46.084 > Message Logs:     Level 0
06:16:46.087 > Status LED:       Pin 1
06:16:46.087 > Device Control:   Pin 3
06:16:46.090 > Sketch Version:   162.231219.0616
06:16:46.093 > HomeSpan Version: 1.8.1
06:16:46.096 > Arduino-ESP Ver.: 2.0.6
06:16:46.098 > ESP-IDF Version:  4.4.3
06:16:46.101 > ESP32 Chip:       ESP32-S3 Rev 0 dual-core 8MB Flash
06:16:46.104 > ESP32 Board:      esp32s3
06:16:46.107 > PWM Resources:    8 channels, 4 timers, max 14-bit duty resolution
06:16:46.112 > Sodium Version:   1.0.12-idf  Lib 9.4
06:16:46.115 > MbedTLS Version:  mbed TLS 2.28.1
06:16:46.118 > Sketch Compiled:  Dec 19 2023 06:14:11
06:16:46.123 > Partition:        app0
06:16:46.123 > MAC Address:      1A:FF:01:01:01:01
06:16:46.126 > 
06:16:46.126 > Device Name:      test-bridge-12

@HomeSpan
Copy link
Owner

Can you type 'm' into the serial monitor when using the new 1.8.1-dev branch. This will report the free heap as well as the status of the NVS. Want to check that the NVS is not filling up to capacity.

@homonto
Copy link
Author

homonto commented Dec 19, 2023

07:46:21.914 > Free Heap Internal RAM :  144424 bytes.  Low:   97336
07:46:21.917 > Lowest stack level     :    2756 bytes
07:46:21.920 > NVS Flash Partition    :     179 of 504 records used

@HomeSpan
Copy link
Owner

Thanks. It does not seem to be a problem with the NVS (plenty of room), but the stack size seems low. Can you run this with different cases for the number of SpanPoints to see how the numbers vary?

@HomeSpan
Copy link
Owner

I just reviewed the ESP-NOW documents from Espressif and it seems that the IDF limits the number of encrypted peers that can be added. This is hardcoded into the IDF and cannot be changed in the Arduino-Esp32 library without it being recompiled (which can't be done via just using HomeSpan).

@homonto
Copy link
Author

homonto commented Dec 19, 2023

6 devices and all is OK:

07:59:33.142 > ======= S T A R T =======
07:59:33.260 > [change_mac]: OLD MAC: 0c:b8:15:cd:4d:3c
07:59:33.263 > [change_mac]: changing MAC...SUCCESSFULL
07:59:33.266 > [change_mac]: NEW MAC: 1a:ff:01:01:01:01
07:59:33.269 > [setup]: HOSTNAME: test-bridge-11
07:59:33.271 > [setup]: FW VERSION: 1.6.1
07:59:33.274 > [setup]: COMPILATION TIME: Dec 19 2023 07:58:31
07:59:33.280 > [setup]: BOARD TYPE: ESP32
07:59:33.282 > [setup]: Free heap=221224 bytes
07:59:33.285 > [setup]: BRIDGE_FW on HomeKit: 161.231219.0758
07:59:33.288 > [setup]: SERIAL NUMBER: 0cb815cd4d3c_010101
07:59:35.419 > 
07:59:35.419 > ************************************************************
07:59:35.422 > Welcome to HomeSpan!
07:59:35.425 > Apple HomeKit for the Espressif ESP-32 WROOM and Arduino IDE
07:59:35.430 > ************************************************************
07:59:35.436 > 
07:59:35.436 > ** Please ensure serial monitor is set to transmit <newlines>
07:59:35.441 > 
07:59:35.441 > Message Logs:     Level 0
07:59:35.444 > Status LED:       Pin 33
07:59:35.447 > Device Control:   Pin 23
07:59:35.447 > Sketch Version:   161.231219.0758
07:59:35.450 > HomeSpan Version: 1.8.1
07:59:35.453 > Arduino-ESP Ver.: 2.0.6
07:59:35.455 > ESP-IDF Version:  4.4.3
07:59:35.458 > ESP32 Chip:       ESP32-D0WDQ6 Rev 1 dual-core 4MB Flash
07:59:35.461 > ESP32 Board:      esp32
07:59:35.464 > PWM Resources:    16 channels, 8 timers, max 20-bit duty resolution
07:59:35.469 > Sodium Version:   1.0.12-idf  Lib 9.4
07:59:35.472 > MbedTLS Version:  mbed TLS 2.28.1
07:59:35.477 > Sketch Compiled:  Dec 19 2023 07:58:44
07:59:35.480 > Partition:        app0
07:59:35.480 > MAC Address:      1A:FF:01:01:01:01
07:59:35.486 > 
07:59:35.486 > Device Name:      test-bridge-11
07:59:35.489 > 
07:59:35.494 > [setup]: ========== Setup finished ==========
07:59:35.500 > 
07:59:35.500 > 
07:59:35.500 > *** HomeSpan Info ***

07:59:40.426 > 
07:59:40.428 > Starting HAP Server on port 80 supporting 13 simultaneous HomeKit Controller Connections...
07:59:40.436 > 
07:59:40.436 > 
07:59:58.014 > Free Heap Internal RAM :  168424 bytes.  Low:  121884
07:59:58.016 > Lowest stack level     :    5140 bytes
07:59:58.019 > NVS Flash Partition    :     184 of 504 records used

7 devices and the last device is NOT OK:

08:01:16.119 > ======= S T A R T =======
08:01:16.240 > [change_mac]: OLD MAC: 0c:b8:15:cd:4d:3c
08:01:16.243 > [change_mac]: changing MAC...SUCCESSFULL
08:01:16.245 > [change_mac]: NEW MAC: 1a:ff:01:01:01:01
08:01:16.248 > [setup]: HOSTNAME: test-bridge-11
08:01:16.251 > [setup]: FW VERSION: 1.6.1
08:01:16.254 > [setup]: COMPILATION TIME: Dec 19 2023 08:00:30
08:01:16.259 > [setup]: BOARD TYPE: ESP32
08:01:16.262 > [setup]: Free heap=221224 bytes
08:01:16.265 > [setup]: BRIDGE_FW on HomeKit: 161.231219.0800
08:01:16.268 > [setup]: SERIAL NUMBER: 0cb815cd4d3c_010101
08:01:16.394 > E (358) ESPNOW: Peer is full
08:01:18.400 > 
08:01:18.401 > ************************************************************
08:01:18.403 > Welcome to HomeSpan!
08:01:18.406 > Apple HomeKit for the Espressif ESP-32 WROOM and Arduino IDE
08:01:18.411 > ************************************************************
08:01:18.417 > 
08:01:18.417 > ** Please ensure serial monitor is set to transmit <newlines>
08:01:18.423 > 
08:01:18.423 > Message Logs:     Level 0
08:01:18.425 > Status LED:       Pin 33
08:01:18.428 > Device Control:   Pin 23
08:01:18.428 > Sketch Version:   161.231219.0800
08:01:18.431 > HomeSpan Version: 1.8.1
08:01:18.434 > Arduino-ESP Ver.: 2.0.6
08:01:18.437 > ESP-IDF Version:  4.4.3
08:01:18.439 > ESP32 Chip:       ESP32-D0WDQ6 Rev 1 dual-core 4MB Flash
08:01:18.442 > ESP32 Board:      esp32
08:01:18.445 > PWM Resources:    16 channels, 8 timers, max 20-bit duty resolution
08:01:18.450 > Sodium Version:   1.0.12-idf  Lib 9.4
08:01:18.453 > MbedTLS Version:  mbed TLS 2.28.1
08:01:18.459 > Sketch Compiled:  Dec 19 2023 07:58:44
08:01:18.461 > Partition:        app0
08:01:18.461 > MAC Address:      1A:FF:01:01:01:01
08:01:18.467 > 
08:01:18.467 > Device Name:      test-bridge-11
08:01:18.470 > 
08:01:18.475 > [setup]: ========== Setup finished ==========
08:01:18.481 > 
08:01:18.481 > 
08:01:18.481 > *** HomeSpan Info ***

08:01:23.627 > Starting HAP Server on port 80 supporting 13 simultaneous HomeKit Controller Connections...
08:01:23.634 > 
08:01:23.634 > 
08:02:03.121 > Free Heap Internal RAM :  164440 bytes.  Low:  119600
08:02:03.124 > Lowest stack level     :    5108 bytes
08:02:03.126 > NVS Flash Partition    :     184 of 504 records used

8 devices (and so on... - NOT ok):

08:03:39.835 > ======= S T A R T =======
08:03:39.956 > [change_mac]: OLD MAC: 0c:b8:15:cd:4d:3c
08:03:39.959 > [change_mac]: changing MAC...SUCCESSFULL
08:03:39.961 > [change_mac]: NEW MAC: 1a:ff:01:01:01:01
08:03:39.964 > [setup]: HOSTNAME: test-bridge-11
08:03:39.967 > [setup]: FW VERSION: 1.6.1
08:03:39.970 > [setup]: COMPILATION TIME: Dec 19 2023 08:02:56
08:03:39.975 > [setup]: BOARD TYPE: ESP32
08:03:39.978 > [setup]: Free heap=221232 bytes
08:03:39.981 > [setup]: BRIDGE_FW on HomeKit: 161.231219.0802
08:03:39.984 > [setup]: SERIAL NUMBER: 0cb815cd4d3c_010101
08:03:40.109 > E (359) ESPNOW: Peer is full
08:03:40.109 > E (362) ESPNOW: Peer is full
08:03:42.120 > 
08:03:42.120 > ************************************************************
08:03:42.123 > Welcome to HomeSpan!
08:03:42.126 > Apple HomeKit for the Espressif ESP-32 WROOM and Arduino IDE
08:03:42.131 > ************************************************************
08:03:42.137 > 
08:03:42.137 > ** Please ensure serial monitor is set to transmit <newlines>
08:03:42.142 > 
08:03:42.142 > Message Logs:     Level 0
08:03:42.145 > Status LED:       Pin 33
08:03:42.148 > Device Control:   Pin 23
08:03:42.148 > Sketch Version:   161.231219.0802
08:03:42.151 > HomeSpan Version: 1.8.1
08:03:42.153 > Arduino-ESP Ver.: 2.0.6
08:03:42.156 > ESP-IDF Version:  4.4.3
08:03:42.159 > ESP32 Chip:       ESP32-D0WDQ6 Rev 1 dual-core 4MB Flash
08:03:42.162 > ESP32 Board:      esp32
08:03:42.164 > PWM Resources:    16 channels, 8 timers, max 20-bit duty resolution
08:03:42.170 > Sodium Version:   1.0.12-idf  Lib 9.4
08:03:42.173 > MbedTLS Version:  mbed TLS 2.28.1
08:03:42.178 > Sketch Compiled:  Dec 19 2023 07:58:44
08:03:42.181 > Partition:        app0
08:03:42.181 > MAC Address:      1A:FF:01:01:01:01
08:03:42.187 > 
08:03:42.187 > Device Name:      test-bridge-11
08:03:42.189 > 
08:03:42.195 > [setup]: ========== Setup finished ==========
08:03:42.201 > 
08:03:42.201 > 
08:03:42.201 > *** HomeSpan Info ***

08:03:47.558 > Starting HAP Server on port 80 supporting 13 simultaneous HomeKit Controller Connections...
08:03:47.568 > 
08:03:47.568 > 
08:04:02.502 > Free Heap Internal RAM :  160604 bytes.  Low:  111968
08:04:02.504 > Lowest stack level     :    5188 bytes
08:04:02.507 > NVS Flash Partition    :     184 of 504 records used

@homonto
Copy link
Author

homonto commented Dec 19, 2023

just found it out:
If ESP-NOW encrypted mode is used, up to 6 devices can be paired and controlled at the same time

@homonto
Copy link
Author

homonto commented Dec 19, 2023

so, we are practically done here...
but I have some doubts because, as per their documentation:
If unicast packets are used, up to 20 devices can be paired and controlled at the same time. If ESP-NOW encrypted mode is used, up to 6 devices can be paired and controlled at the same time.

and I have also another project, that is NOT for HomeKit, just ESPnow to MQTT and I have more than 50 devices working.
But I am NOT pairing them permanently but temporarily - so each one at 1 time is the only one.
So maybe it can be done the same way in HomeSpan?

@HomeSpan
Copy link
Owner

Unfortunately I don't think there is an easy workaround for this.

@homonto
Copy link
Author

homonto commented Dec 19, 2023

or another approach: do we NEED encryption between the bridge and the remote device?
I can live without it, knowing that.. someone will read my temperature ;-)

@HomeSpan
Copy link
Owner

It's something I can explore in a future release, but probably not in the short term.

@homonto
Copy link
Author

homonto commented Dec 19, 2023

with your permission I will try to do it in your code - if I am not mistaken it is just one parameter in the ESP function:

peerInfo.encrypt = true;

here:
HomeSpan-release-1.8.1-dev/src/HomeSpan.cpp: peerInfo.encrypt=true;

@HomeSpan
Copy link
Owner

Yes, feel free to experiment.

@homonto
Copy link
Author

homonto commented Dec 19, 2023

it seems to work without encryption turned ON but let me test it further - at least there is no initial error: ESP NOW is full

08:18:24.424 > ======= S T A R T =======
08:18:24.544 > [change_mac]: OLD MAC: 0c:b8:15:cd:4d:3c
08:18:24.547 > [change_mac]: changing MAC...SUCCESSFULL
08:18:24.550 > [change_mac]: NEW MAC: 1a:ff:01:01:01:01
08:18:24.552 > [setup]: HOSTNAME: test-bridge-11
08:18:24.555 > [setup]: FW VERSION: 1.6.1
08:18:24.558 > [setup]: COMPILATION TIME: Dec 19 2023 08:17:32
08:18:24.564 > [setup]: BOARD TYPE: ESP32
08:18:24.566 > [setup]: Free heap=221224 bytes
08:18:24.569 > [setup]: BRIDGE_FW on HomeKit: 161.231219.0817
08:18:24.572 > [setup]: SERIAL NUMBER: 0cb815cd4d3c_010101
08:18:26.709 > 
08:18:26.709 > ************************************************************
08:18:26.712 > Welcome to HomeSpan!
08:18:26.715 > Apple HomeKit for the Espressif ESP-32 WROOM and Arduino IDE
08:18:26.720 > ************************************************************
08:18:26.726 > 
08:18:26.726 > ** Please ensure serial monitor is set to transmit <newlines>
08:18:26.731 > 
08:18:26.731 > Message Logs:     Level 0
08:18:26.734 > Status LED:       Pin 33
08:18:26.737 > Device Control:   Pin 23
08:18:26.737 > Sketch Version:   161.231219.0817
08:18:26.740 > HomeSpan Version: 1.8.1
08:18:26.743 > Arduino-ESP Ver.: 2.0.6
08:18:26.745 > ESP-IDF Version:  4.4.3
08:18:26.748 > ESP32 Chip:       ESP32-D0WDQ6 Rev 1 dual-core 4MB Flash
08:18:26.751 > ESP32 Board:      esp32
08:18:26.754 > PWM Resources:    16 channels, 8 timers, max 20-bit duty resolution
08:18:26.759 > Sodium Version:   1.0.12-idf  Lib 9.4
08:18:26.762 > MbedTLS Version:  mbed TLS 2.28.1
08:18:26.767 > Sketch Compiled:  Dec 19 2023 08:16:02
08:18:26.770 > Partition:        app0
08:18:26.770 > MAC Address:      1A:FF:01:01:01:01
08:18:26.776 > 
08:18:26.776 > Device Name:      test-bridge-11
08:18:26.779 > 
08:18:26.784 > [setup]: ========== Setup finished ==========
08:18:26.790 > 
08:18:26.790 > 
08:18:26.790 > *** HomeSpan Info ***


08:18:28.551 > Found 10 SpanPoint Links:
08:18:28.554 > 
08:18:28.554 > Local MAC Address  Remote MAC Address     Send  Receive    Depth
08:18:28.559 > -----------------  ------------------  -------  -------  -------
08:18:28.565 > 1A:FF:01:01:01:01   1A:01:01:01:01:01        0       36        1
08:18:28.570 > 1A:FF:01:01:01:01   1A:01:01:01:01:02        0       36        1
08:18:28.576 > 1A:FF:01:01:01:01   1A:01:01:01:01:03        0       36        1
08:18:28.581 > 1A:FF:01:01:01:01   1A:01:01:01:01:04        0       36        1
08:18:28.587 > 1A:FF:01:01:01:01   1A:01:01:01:01:05        0       36        1
08:18:28.592 > 1A:FF:01:01:01:01   1A:01:01:01:01:06        0       36        1
08:18:28.598 > 1A:FF:01:01:01:01   1A:01:01:01:01:07        0       36        1
08:18:28.604 > 1A:FF:01:01:01:01   1A:01:01:01:01:08        0       36        1
08:18:28.609 > 1A:FF:01:01:01:01   1A:01:01:01:01:09        0       36        1
08:18:28.615 > 1A:FF:01:01:01:01   1A:01:01:01:01:44        0       36        1
08:18:28.620 > 



08:18:32.199 > Starting HAP Server on port 80 supporting 13 simultaneous HomeKit Controller Connections...
08:18:32.209 > 
08:18:32.209 > 
08:19:22.429 > Free Heap Internal RAM :  152016 bytes.  Low:  109328
08:19:22.432 > Lowest stack level     :    3700 bytes
08:19:22.435 > NVS Flash Partition    :     184 of 504 records used

@homonto
Copy link
Author

homonto commented Dec 19, 2023

no luck still:

08:35:05.066 > E (85958) wifi:CCMP replay detected: A1=1a:ff:01:01:01:01 A2=1a:01:01:01:01:44 PN=1, RSC=6 seq=16

but maybe it requires recompile on the sensor as well?

@homonto
Copy link
Author

homonto commented Dec 19, 2023

YES YES YES!!!!!! after recompilation of the remote device with encryption off it seems to work:

08:38:23.463 > [loop]: Raw data from device test-44-c3 just arrived: temp=-99.90C, hum=-99.90%, light=-99.90lx, bat_value_pct=0%, charging=0, model=4 (ESP32-C3), version=120.231219.0837

@homonto
Copy link
Author

homonto commented Dec 19, 2023

I am yet to check in my friend's house, where I deployed 7 devices, and 7th is not working now - all above tests are from my house, with just 1 device working and 1 bridge (testing only).

And if that works (I am very positive it will work with both sides):

peerInfo.encrypt = false;

I would suggest, as the fastest workaround to bring some configuration parameter in your library to be controlled by the end user, i.e.:

#define ENCRYPT_ESPNOW 1

and then in HomeSpan.cpp

  #if (ENCRYPT_ESPNOW == 1)
    peerInfo.encrypt=true;             
  #else 
    peerInfo.encrypt=false;
  #endif 

this way you give the end user possibility to go up to 20 end devices without really redoing your library - also, my change in the HomeSpan.cpp will only survive until I pull the update from your github ;)

@HomeSpan
Copy link
Owner

Unfortunately, #defines don't pass through to libraries (they appear to do so in VSCode, but that's only because VSCode recompiles all of HomeSpan each time - it's not really being accessed as if were a true C library).

Instead, to be consistent with other SpanPoint methods, I created a new class-level method SpanPoint::setEncryption(boolean encrypt). Call this method BEFORE creating any SpanPoint instances with encrypt set to false to turn off encryption (the default is for it to be on).

I also added logic to the Serial Monitor output that lets you know if SpanPoint encryption is on or off, as well as provides a warning message if any of the SpanPoint instances exceed the maximum allowed. Rather than hardcode limits, HomeSpan checks each SpanPoint to see if was properly stored after creation. With encryption turned on, the limit is 7 peers. Without encryption the limit is 20. These limits are consistent with the ESP-NOW documentation.

These features have been checked into the 1.8.1-dev branch. Please give it a try and let me know how it works. If successful, I'll update the SpanPoint documentation to reflect the new SpanPoint::setEncryption(boolean encrypt) method, as well as provide info on the maximum peer limitations of ESP-NOW.

@homonto
Copy link
Author

homonto commented Dec 19, 2023

I was 100% you would implement it different way - your way ;-)
I will download the new branch, recompile and let you know.
thank you

@homonto
Copy link
Author

homonto commented Dec 21, 2023

so I am testing and I found kind of strange things:
1- my bridge and remotes were compiled with encryption OFF (since yesterday)
2- I recompiled ONLY bridge, with your new updated 1.8.1 version and I initially turned OFF encryption:

#define ENCRYPT_ESPNOW            0
 #if (ENCRYPT_ESPNOW == 0)
      SpanPoint::setEncryption(false);
    #else
      SpanPoint::setEncryption(true);
    #endif
    remoteData    = new SpanPoint(macAddress,0,sizeof(myData)); 

outcome (as expected):

18:48:47.098 > Found 11 unencrypted SpanPoint Links:
18:48:47.101 > 
18:48:47.101 > Local MAC Address  Remote MAC Address     Send  Receive    Depth
18:48:47.106 > -----------------  ------------------  -------  -------  -------
18:48:47.112 > 1A:FF:01:01:01:01   1A:01:01:01:01:01        0       44        1  
18:48:47.117 > 1A:FF:01:01:01:01   1A:01:01:01:01:02        0       44        1  
18:48:47.123 > 1A:FF:01:01:01:01   1A:01:01:01:01:03        0       44        1  
18:48:47.131 > 1A:FF:01:01:01:01   1A:01:01:01:01:04        0       44        1  
18:48:47.137 > 1A:FF:01:01:01:01   1A:01:01:01:01:05        0       44        1  
18:48:47.142 > 1A:FF:01:01:01:01   1A:01:01:01:01:06        0       44        1  
18:48:47.148 > 1A:FF:01:01:01:01   1A:01:01:01:01:07        0       44        1  
18:48:47.153 > 1A:FF:01:01:01:01   1A:01:01:01:01:08        0       44        1  
18:48:47.159 > 1A:FF:01:01:01:01   1A:01:01:01:01:09        0       44        1  
18:48:47.164 > 1A:FF:01:01:01:01   1A:01:01:01:01:44        0       44        1  
18:48:47.170 > 1A:FF:01:01:01:01   1A:01:01:01:01:42        0       44        1  

and then, when remote sends data, bridge is showing it:
18:49:24.705 > [loop]: Raw data from device test-42-s2 just arrived: temp=-99.90C, hum=-99.90%, light=-99.90lx, bat_value_pct=0%, charging=0, model=2 (ESP32-S2), version=144.231221.1803

so far so good - both bridge and remote have encryption OFF so they talk and understand each other.

3- next test: turned encryption ON ONLY on bridge - expected behaviour:

  • limited devices to 7 (as you said)
  • devices DON'T understand each other (because my bridge using encryption while remote is still unencrypted)

however outcome is different a bit - this part below shows: all are encrypted but we exceeded the number, right?

18:55:09.605 > Found 11 encrypted SpanPoint Links:
18:55:09.607 > 
18:55:09.607 > Local MAC Address  Remote MAC Address     Send  Receive    Depth
18:55:09.613 > -----------------  ------------------  -------  -------  -------
18:55:09.618 > 1A:FF:01:01:01:01   1A:01:01:01:01:01        0       44        1  
18:55:09.624 > 1A:FF:01:01:01:01   1A:01:01:01:01:02        0       44        1  
18:55:09.630 > 1A:FF:01:01:01:01   1A:01:01:01:01:03        0       44        1  
18:55:09.635 > 1A:FF:01:01:01:01   1A:01:01:01:01:04        0       44        1  
18:55:09.644 > 1A:FF:01:01:01:01   1A:01:01:01:01:05        0       44        1  
18:55:09.649 > 1A:FF:01:01:01:01   1A:01:01:01:01:06        0       44        1  
18:55:09.655 > 1A:FF:01:01:01:01   1A:01:01:01:01:07        0       44        1  
18:55:09.660 > 1A:FF:01:01:01:01   1A:01:01:01:01:08        0       44        1  (max connections exceeded!)
18:55:09.669 > 1A:FF:01:01:01:01   1A:01:01:01:01:09        0       44        1  (max connections exceeded!)
18:55:09.677 > 1A:FF:01:01:01:01   1A:01:01:01:01:44        0       44        1  (max connections exceeded!)
18:55:09.685 > 1A:FF:01:01:01:01   1A:01:01:01:01:42        0       44        0  (max connections exceeded!)

but then, the last sensor - with MAC = 1A:01:01:01:01:42 - is still being received and understood by the bridge!
18:55:16.845 > [loop]: Raw data from device test-42-s2 just arrived: temp=-99.90C, hum=-99.90%, light=-99.90lx, bat_value_pct=0%, charging=0, model=2 (ESP32-S2), version=144.231221.1803

but when I move the same sensor to be 1st in the list (or in the first 7), the bridge does not even print anything - no error no nothing.

So for me it looks like this:
1- with encryption: first 7 are encrypted
2- the rest is still unencrypted
3- my summary: when you encrypt, you still can have 20 remotes, but only first 7 will be encrypted - the rest 13 unencrypted (but still working)

Do I get it right?
I am yet to test what happens when I turn ON encryption on the remote...

@homonto
Copy link
Author

homonto commented Dec 21, 2023

next scenario:
4- bridge using encryption but the test remote is the LAST position on the list - so on the position number 11

  • remote has encryption ON
  • bridge can NOT decrypt (as anticipated, because only first 7 can be encrypted)
    19:13:35.513 > E (1118367) wifi:CCMP replay detected: A1=1a:ff:01:01:01:01 A2=1a:01:01:01:01:42 PN=1, RSC=6 seq=16

5- bridge using encryption but the test remote is the FIRST position on the list - so on the position number 1

  • remote encrypted
  • bridge CAN decrypt (as anticipated, because the remote is within first 7, that can be decrypted)
    19:19:44.745 > [loop]: Raw data from device test-42-s2 just arrived: temp=-99.90C, hum=-99.90%, light=-99.90lx, bat_value_pct=0%, charging=0, model=2 (ESP32-S2), version=150.231221.1912

@homonto
Copy link
Author

homonto commented Dec 21, 2023

So my summary now:

  • Espressif made a mess
  • I did not test all possible scenarios (probably) but the final outcome is:
  • with encryption ON:
    1- you can use up to 20 remote devices but:
    2- only first 7 will be encrypted and they MUST use encryption on remote side
    3- remaining 13 must NOT use encryption on the remote side
  • with encryption OFF:
    1- you can use up 20 remotes
    2- both sides must have encryption OFF

@homonto
Copy link
Author

homonto commented Dec 21, 2023

For me the topic is closed, unless you want me to test more, I would appreciate if you merge the dev into the main branch - right now I have your code on my lib folder (I am using PlatformIO of course)

@homonto
Copy link
Author

homonto commented Dec 21, 2023

one more thing: as I mentioned before one can use unlimited amount of remotes in ESPnow, if you consider every connection to be temporary and then delete the peers - this way I have it done in my project (the "non HomeKit" one).

@homonto
Copy link
Author

homonto commented Dec 23, 2023

I have tested with more devices and the outcome (if you wanted to know) is (all unencrypted) - on top of your part of the library I have also bridge connecting to InfluxDB and pushing the data for Grafana (HomeKit is seriously limited with historical data):

  • 25 devices: rebooting due to no connection to InfluxDB (my mechanism), also complaining: ESPNow FULL
  • 20 devices:
    **** WARNING! Low Internal RAM Watermark of 77748 bytes is less than Low Threshold of 80000 bytes. Device *may* run out of memory.
  • 18 devices: still InfluxDB connection failed: connection refused
  • 15 devices: ALL is OK

So all in all it would probably work well with 20 devices if not my addition of InfluxDB connector

I shall test now with MQTT (instead of InfluxDB)

@homonto
Copy link
Author

homonto commented Dec 28, 2023

it seems it can be 17 encrypted devices as per https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/network/esp_now.html - just that default is 7:

The maximum number of paired devices is 20, and the paired encryption devices are no more than 17, the default is 7. If you want to change the number of paired encryption devices, set [CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/kconfig.html#config-esp-wifi-espnow-max-encrypt-num) in the Wi-Fi component configuration menu.

@HomeSpan
Copy link
Owner

Yes, but it's not possible to change this default unless you re-compile the Arduino-ESP32 library directly from the IDF using the IDF tool chain. There are many such variables like this where the folks at Espressif hardcoded a value or process into the Arduino-ESP32 library that is more flexible when using the full Espressif IDF.

It is possible to create an Arduino-style library directly from the IDF, but I have not yet tried since the results are chip-specific, and I would need to create multiple versions of HomeSpan.

@homonto homonto closed this as completed Jan 7, 2024
@YouCanNotBeSerious
Copy link

I am very interested in this, as I have a contact sensor hub with only 2 devices at the moment under test for battery life, and eventually want to have humidity/temp and contact sensors all on this hub. So the device number limit is important to me.

Would you guys @homonto and @HomeSpan agree with this summary below?

Without considerations of extras like external databases, just a plain HomeKit device, you can have up to up to 20 spanpoint remote devices, but encryption must be off at both ends, and you need 1.8.1 or later codebase with the SpanPoint::setEncryption(boolean encrypt) method to do it the "easy" or HomeSpan centric way.

@homonto
Copy link
Author

homonto commented Jan 28, 2024

@YouCanNotBeSerious I am doing nearly 20 now with encryption OFF
and I am not using influxdb anymore - I am using mqtt now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants