kike-canaries / canairio_android

Android app of CanAirIO project. This is configuration manager, geo-location tagging and front end of CanAirIO firmware via Bluetooth LE.
https://canair.io
GNU General Public License v3.0
16 stars 10 forks source link

App repeatedly crashes on WiFi fixed station settings #126

Closed Marvin-YYC closed 2 years ago

Marvin-YYC commented 2 years ago

Describe the bug I was able to connect my device to WiFi using the app, but now each time I click on the 'WiFi fixed station settings' the app crashes. I tried an uninstall/reinstall but the problem persist.

CanAirIO v0.7.5 rev594 Phone is an Moto G5 plus running AOS 8.1.0

Marvin-YYC commented 2 years ago

New information: I flashed the sketch to the ESP32 again, and was able to reconnect to wifi.
The app seemed to be working ok after that, until I selected Fixed tag location GeoHash and then clicked set saving location. The app crashed and after this each time I select WiFi fixed station settings the app crashes.

hpsaturn commented 2 years ago

Thanks a lot for your feedback and for wrote this report. I'm going tomorrow to try to find the crash in crashlytics. Meanwhile is possible maybe paste the information about your device, the device info section for example? Thanks.

Marvin-YYC commented 2 years ago

Hello @hpsaturn Thank you for your reply. Here is a screen shot of the device info page.

I also ran into another issue with my Heltec devices. Two of the dev boards are rev.877 and one is rev.841. The 841 doesn't show the wifi icon, but it appears to be enabled. Should I create another bug report for this?

Also; I am not sure which pins on my Heltec ESP32 are enabled for CanAirio sensors. I have a TDH11 sensor that I would like to to connect. Any assistance would be greatly appreciated. I am new to Arduino and ESP32.

Canairo SS01

hpsaturn commented 2 years ago

Hello @hpsaturn Thank you for your reply. Here is a screen shot of the device info page.

Thanks

I also ran into another issue with my Heltec devices. Two of the dev boards are rev.877 and one is rev.841. The 841 doesn't show the wifi icon, but it appears to be enabled. Should I create another bug report for this?

it's weird because sounds like it doesn't has a right wifi connection. Maybe you can paste the log output? For that you can read how to do it here

Also; I am not sure which pins on my Heltec ESP32 are enabled for CanAirio sensors. I have a TDH11 sensor that I would like to to connect. Any assistance would be greatly appreciated. I am new to Arduino and ESP32.

For that, the last wiring documentation is here. There say for Heltec for DHT11 the pin is 23:

https://github.com/kike-canaries/canairio_sensorlib/blob/master/src/Sensors.hpp#L19-L52

Marvin-YYC commented 2 years ago

I installed from your web installer the 'test' version, and that seems to have corrected the issues with the Wi-Fi icon. It is now running rev.879. . . I'm not exactly sure what that means :)

Canario SS02

I have connected my DHT11 sensor to pin23 which appears to be working, however the Temp + Humidity information makes no sense to me. Temp: 610 + Humidity: 420 (variable)

It is also having the same Fixed tag location GeoHash problem. The app crashes each time I select WiFi fixed station setting.

Also; my CanAirio's do not appear on your world map?

Thanks for all your help:)

roberbike commented 2 years ago

I have an Heltec board, and I have not your issues. The app works fine. Update the app to the last version on google store. If the geohash is not saved into the board or there is not wifi, your station can not be see in the world map.

f you want to use the DHT11 sensor, you need a 5kohm resistor betwen data and Vdd. image

hpsaturn commented 2 years ago

Maybe the issue #127 it is relationed with this and location permission. @Marvin-1802 do you have all permissions granted that the app requested?

Marvin-YYC commented 2 years ago

I have flashed the stable version again, and now it is rev.877
It takes a long time to connect to wifi but the icon is present.

All permissions are granted. As soon as I try to save the GeoStash the app crashes!?

Marvin-YYC commented 2 years ago

I just installed the app on another phone, and connected to the device and same thing. App crashes each time I select WiFi fixed station setting?! Maybe they don't like Moto phones :)

hpsaturn commented 2 years ago

Is very weird that, the issue is relationed with your geohash, your location. One question, please doing the next steps:

Thanks

hpsaturn commented 2 years ago

Meanwhile, the issue is here:

    private void updateLocationSummary() {
        if (lastLocation != null) {
            SwitchPreference ifxdbSwitch = getInfluxDbSwitch();
            String summary = "";
            if (currentGeoHash.length() == 0 ) {
                summary = summary+"none.";
                ifxdbSwitch.setSummary(R.string.summary_ifx_nogeohash);
            }
            else {
                summary = summary + currentGeoHash;
                ifxdbSwitch.setSummary(R.string.key_enable_ifx_summary_ready);
                EasyPreference.Builder prefBuilder = AppData.getPrefBuilder(getContext());
                String name = currentGeoHash.substring(0,3);
                name = name + prefBuilder.getString(Keys.DEVICE_FLAVOR,"").substring(0,7);
                name = name + prefBuilder.getString(Keys.DEVICE_ADDRESS,"").substring(10);
                name = name.replace("_","");
                name = name.replace(":","");
                name = name.toUpperCase();
                name = getString(R.string.fixed_stations_map_summary)+"\nYour station: "+name;
                updateSummary(R.string.key_fixed_stations_map,name);
            }
            String geo = " (new: " + GeoHash.fromLocation(lastLocation, Config.GEOHASHACCU).toString()+")";
            summary = summary + geo;
            updateSummary(R.string.key_setting_enable_location,summary);
        }

In this line: https://github.com/kike-canaries/canairio_android/blob/master/app/src/main/java/hpsaturn/pollutionreporter/view/SettingsFixedStation.java#L331

But it is impossible, because the validation of a geohash with size 0 is there. If the geohash for example is the size 1, and HELTEC is 6 chars is impossible the issue reported:

Caused by java.lang.StringIndexOutOfBoundsException: length=6; index=7

I don't know what happens here.

Marvin-YYC commented 2 years ago

I recorded a track as you suggested, but the app crashes when I go to Fixed Station.

I should have mentioned this before, but didn't think it would matter.
One phone I am using does not have a SIM card, I only get data via wifi and the other phone I am using has a SIM card but data via wifi only as well. Perhaps this is the problem?

Should I reinstall the sketch again to get past the crash?

hpsaturn commented 2 years ago

Ok, thanks for your feedback. Nop, you don't need re-flash again the firmware. @roberbike already replicate your issue, and I'm going to free a new release for test a possible fix. Please wait some minutes and I will post the apk here.

hpsaturn commented 2 years ago

Ok, I don't have all things for replicate the issue in my environment, but maybe the next apk fix the issue:

http://influxdb.canair.io:8080/tmp/rev596v0.7.6_signed20220106.apk

Please let me know if it is right, and also @roberbike

Thanks a lot guys for the help.

roberbike commented 2 years ago

After first test, it is working. It is fixed.

Marvin-YYC commented 2 years ago

I installed the new APK v0.7.6 That has corrected the crashing problem, but now when I click Geohash toggle and then click set, the Geohash toggle turns off each time?

roberbike commented 2 years ago

I installed the new APK v0.7.6 That has corrected the crashing problem, but now when I click Geohash toggle and then click set, the Geohash toggle turns off each time?

Yes, it is normal. The geohash has been saved and on left side the word none changued to geohash code.

Marvin-YYC commented 2 years ago

Thanks for all your help! :) I will see if I can sort out my temp/humi sensor and order other sensors. I think that there must be something wrong with this particular ESP32, it takes forever to load and connect with wifi?! I still don't see station on map, but I guess it could take sometime.

I don't know if you want/need more Canadian stations, but I will share your website with others to see if I can get others interested in your project.

hpsaturn commented 2 years ago

Thanks for all your help! :)

Thanks for report it and your feedback and tests.

I will see if I can sort out my temp/humi sensor and order other sensors.

Yes, please review the CanAirIO docs and CanAirIO sensorlib for the possible sensors supported. For example DHT11 is a very old sensor and it is very slow. We have supported others better than it.

I think that there must be something wrong with this particular ESP32, it takes forever to load and connect with wifi?! I still don't see station on map, but I guess it could take sometime.

well, maybe is a problem with the antenna? also do you have the data icons blinking in your OLED screen? On the other hand, if you click in CanAirIO Anaire item in settins, this launch the browser with Temperature and Humidity widgets and the respective historics, and if you have a CO2 sensor, also for it:

CanAirIO CO2 easy Setup

(more short videos in releases)

For the CanAirIO Worldmap you need a PM2.5 or CO2 sensor.

I don't know if you want/need more Canadian stations, but I will share your website with others to see if I can get others interested in your project.

We need more help and more users, the Air Quality is a big problem in many countries. We need reach more founds, donations, documentation, activist, academics, etc all for improve the initiative.