Skip to content

Fix ClearGlass CGG1 and CGP1W sensors recognition#849

Merged
1technophile merged 5 commits into1technophile:developmentfrom
Nikolay-Ch:ClearGlass-Patch
Jan 29, 2021
Merged

Fix ClearGlass CGG1 and CGP1W sensors recognition#849
1technophile merged 5 commits into1technophile:developmentfrom
Nikolay-Ch:ClearGlass-Patch

Conversation

@Nikolay-Ch
Copy link
Contributor

@Nikolay-Ch Nikolay-Ch commented Jan 22, 2021

Fix #845 issue

Copy link
Owner

@1technophile 1technophile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR,
Would it be possible to merge also these 2 blocks:

      Log.trace(F("Is it a CGG1" CR));
      if (strstr(service_data, "080774") != NULL) {
        Log.trace(F("CGG1 method 2" CR));
        BLEdata.set("model", "CGG1");
        if (device->sensorModel == -1)
          createOrUpdateDevice(mac, device_flags_init, CGG1);
        return process_cleargrass(BLEdata, false);
      }
      Log.trace(F("Is it a CGG1" CR));
      if (strncmp(service_data, "8816", 4) == 0) {
        Log.trace(F("CGG1 method 3" CR));
        BLEdata.set("model", "CGG1");
        if (device->sensorModel == -1)
          createOrUpdateDevice(mac, device_flags_init, CGG1);
        return process_cleargrass(BLEdata, false);
      }

and use

(strncmp(service_data, "080774", 6) == 0)

@1technophile 1technophile added this to the v0.9.6 milestone Jan 26, 2021
@Nikolay-Ch
Copy link
Contributor Author

Nikolay-Ch commented Jan 27, 2021

Thanks for the PR,
Would it be possible to merge also these 2 blocks:

      Log.trace(F("Is it a CGG1" CR));
      if (strstr(service_data, "080774") != NULL) {
        Log.trace(F("CGG1 method 2" CR));
        BLEdata.set("model", "CGG1");
        if (device->sensorModel == -1)
          createOrUpdateDevice(mac, device_flags_init, CGG1);
        return process_cleargrass(BLEdata, false);
      }
      Log.trace(F("Is it a CGG1" CR));
      if (strncmp(service_data, "8816", 4) == 0) {
        Log.trace(F("CGG1 method 3" CR));
        BLEdata.set("model", "CGG1");
        if (device->sensorModel == -1)
          createOrUpdateDevice(mac, device_flags_init, CGG1);
        return process_cleargrass(BLEdata, false);
      }

and use

(strncmp(service_data, "080774", 6) == 0)

I will do it... I found in old code in your repo, that 080774 seqience taked from this service data: 0807743e10342d580104c3002c0202012a. Third byte 74 is the last byte of the MAC-address of the sensor 743e10342d58. So I think, it not needed in comparision.

@Nikolay-Ch
Copy link
Contributor Author

Nikolay-Ch commented Jan 27, 2021

Also, I found this information about another Advertising packet for the CGG1 device:
atc1441/ATC_MiThermometer#3

I will refactor all three checks...

@1technophile
Copy link
Owner

0807743e10342d580104c3002c0202012a. Third byte 74 is the last byte of the MAC-address of the sensor 743e10342d58. So I think, it not needed in comparison.

Good catch, thanks for the PR

@1technophile 1technophile merged commit 3884630 into 1technophile:development Jan 29, 2021
JeroenWiersma pushed a commit to JeroenWiersma/OpenMQTTGateway that referenced this pull request Oct 18, 2025
* Fix ClearGlass CGG1 and CGP1W sensors recognition

* CGG1 parsing refactoring
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

Successfully merging this pull request may close these issues.

Current version of the Gateway from develop branch does not support ClearGrass CGG1 and CGP1W sensors

2 participants