Skip to content

Commit

Permalink
3s: fix persistent connection isssue
Browse files Browse the repository at this point in the history
  • Loading branch information
dentra committed Oct 28, 2022
1 parent 27c9b1c commit a0bebd7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components/tion-api/tion-api-3s.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class TionsApi3s : public TionApiBase<tion3s_state_t> {

uint16_t get_state_type() const;

bool request_dev_status() const { return false; }
bool request_dev_status() const { return true; }

bool pair() const;
bool request_state() const;
Expand Down
10 changes: 8 additions & 2 deletions components/tion_ble_3s/tion_ble_3s.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ class Tion3sBLEVPortBase : public TionBLEVPortBase {
// VPortBLEComponent implementation
void on_ble_ready() override;

bool ble_reg_for_notify() const override { return this->pair_state_ > 0; }
bool ble_reg_for_notify() const override {
// при постоянном подключении требуется попреподключение иначе мы никогде не получим notify
if (this->is_persistent_connection()) {
return true;
}
return this->pair_state_ > 0;
}

bool write_data(const uint8_t *data, size_t size) { return parent_type::write_data(data, size); }
bool read_frame(uint16_t type, const void *data, size_t size) { return parent_type::read_frame(type, data, size); }
Expand All @@ -36,7 +42,7 @@ class Tion3sBLEVPortBase : public TionBLEVPortBase {
ESPPreferenceObject rtc_;
int8_t pair_state_{}; // 0: not paired, >0: paired, <0: pairing
bool experimental_always_pair_{};
dentra::tion::TionsApi3s *api_;
dentra::tion::TionsApi3s *api_{};
};

class VPortTionBle3sProtocol final : public dentra::tion::TionBleProtocol<dentra::tion::TionBle3sProtocol> {
Expand Down

0 comments on commit a0bebd7

Please sign in to comment.