Extended BLE configuration for the rest of the user properties and added scale status notify #22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request enhances the firmware by adding more BLE configuration capabilities for the user-defined configurations. This enables configuration with the latest Companion App code.
Key Changes
EEPROM Refactoring:
EEPROM_SIZE
from 2 bytes to 9 bytes to store additional configuration parameters.SIGNATURE_ADDR
(with value0xAA
) to detect if EEPROM has been initialized.WEIGHT_ADDR
: Goal weight (unchanged).OFFSET_ADDR
: Weight offset (unchanged).MOMENTARY_ADDR
,REEDSWITCH_ADDR
,AUTOTARE_ADDR
,MIN_SHOT_DURATION_S_ADDR
,MAX_SHOT_DURATION_S_ADDR
,DRIP_DELAY_S_ADDR
.loadOrInitEEPROM()
to initialize EEPROM with defaults if uninitialized or load existing values.Dynamic Configuration and Logic Updates:
#define
constants (e.g.,MOMENTARY
,REEDSWITCH
,AUTOTARE
,MIN_SHOT_DURATION_S
,MAX_SHOT_DURATION_S
,DRIP_DELAY_S
) with runtime variables (momentary
,reedSwitch
,autoTare
,minShotDurationS
,maxShotDurationS
,dripDelayS
).loop()
and related functions to use these dynamic variables instead of static defines.BLE Enhancements:
reedSwitchCharacteristic
,momentaryCharacteristic
,autoTareCharacteristic
: Switch and tare settings.minShotDurationSCharacteristic
,maxShotDurationSCharacteristic
,dripDelaySCharacteristic
: Shot timing parameters.firmwareVersionCharacteristic
: Read-only firmware version.scaleStatusCharacteristic
: Notifies scale connection status (STATUS_DISCONNECTED
orSTATUS_CONNECTED
).initializeBLE()
to set up services and characteristics with initial values.pollAndReadBLE()
to handle runtime updates from BLE writes, persisting changes to EEPROM.Scale Connection Logic:
while(!scale.isConnected())
loop with anif(!scale.isConnected())
condition inloop()
.pollAndReadBLE()
) to execute after every connection attempt, even when the scale is disconnected.updateScaleStatus()
to track and notify scale connection state changes.IMPORTANT: I have tested this with the ESP-WROOM-32 board, which is similar to the shotStopper board, but not the same.