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

[WIP] BLE beacons & Google Physical Web support #880

Closed
wants to merge 30 commits into from

Conversation

Tony080
Copy link

@Tony080 Tony080 commented May 18, 2018

Hello, I'm a student developer enrolled in GSoC 2018. This PR is dedicated to adding BLE beacons(Eddystone, iBeacons, and etc.) and Google Physical Web support to openHAB 2 Android.
Currently, I just merged PR #252 to the newest openHAB 2, and I'm going to move that PR forward. However, I'm still working in progress.

06.19 UI update


06.14 Feature update

Add an activity "Location tracking" for displaying all known Beacon - Frame pairs.

And, to bind beacon with frames, another setting activity is introduced.



06.05 Feature update

Build a BLE scan service to scan BLE beacons in the background. Auto display and update results on "Test BLE Beacons". SwipeRefreshLayout is removed.

05.27 Feature update

From now on, you can detect Eddystone URL & UID beacons, iBeacons from openHAB. Here are the steps:

And then, you enter the activity with the scan result. The scan is lasting for 10 seconds for now. And I'm fixing with the animations as my next step. Finally, you will get the results as shown below:

Please tell me if there is any kind of crash. Thank you!

<string name="app_preferences_name">Settings</string>
<string name="app_notifications">Notifications</string>
<string name="dlg_notification_title">Notification message</string>
<string name="favorites">Favorites</string>
Copy link
Member

Choose a reason for hiding this comment

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

@Tony-hu Looks like something got wrong with your merge. This and many other strings have been removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mueller-ma I assumed he wasn't done yet. There's also a lot of code this PR reintroduces that has been refactored out since the last PR was created.

Copy link
Author

@Tony080 Tony080 May 18, 2018

Choose a reason for hiding this comment

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

@mueller-ma That's true. The basic situations are as @maniac103 said. I kept everything there as the merge result. And I'm currently deleting the unnecessary part to let it fit with the current version of openHAB.

@mueller-ma mueller-ma added the enhancement Indicates new feature requests label May 18, 2018
@mueller-ma mueller-ma changed the title [WIP]BLE beacons & Google Physical Web support [WIP] BLE beacons & Google Physical Web support May 19, 2018
@Tony080 Tony080 closed this May 20, 2018
@stickler-ci
Copy link

Could not review pull request. It may be too large, or contain no reviewable changes.

@Tony080 Tony080 reopened this May 20, 2018
@codecov
Copy link

codecov bot commented May 20, 2018

Codecov Report

Merging #880 into master will decrease coverage by 1.14%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #880      +/-   ##
==========================================
- Coverage   14.37%   13.23%   -1.15%     
==========================================
  Files          56       66      +10     
  Lines        4606     5034     +428     
  Branches      627      672      +45     
==========================================
+ Hits          662      666       +4     
- Misses       3883     4306     +423     
- Partials       61       62       +1
Impacted Files Coverage Δ
...main/java/org/openhab/habdroid/util/Constants.java 0% <ø> (ø) ⬆️
...abdroid/util/bleBeaconUtil/BleBeaconConnector.java 0% <0%> (ø)
...org/openhab/habdroid/ui/OpenHABBeaconActivity.java 0% <0%> (ø)
.../openhab/habdroid/model/OpenHABFrameLabelList.java 0% <0%> (ø)
...ab/habdroid/ui/OpenHABBeaconConfigListAdapter.java 0% <0%> (ø)
...a/org/openhab/habdroid/core/OpenHABBleService.java 0% <0%> (ø)
...enhab/habdroid/ui/OpenHABBeaconConfigActivity.java 0% <0%> (ø)
.../org/openhab/habdroid/ui/OpenHABBeaconAdapter.java 0% <0%> (ø)
...nhab/habdroid/util/bleBeaconUtil/BeaconParser.java 0% <0%> (ø)
...java/org/openhab/habdroid/model/OpenHABBeacon.java 0% <0%> (ø)
... and 21 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3a6a430...f47a399. Read the comment docs.

…rance to the test BLE beacons activity.

Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
Tony080 added 11 commits May 21, 2018 16:54
Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
…essages.

Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
…sidebar menu.

Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
…isplay.

Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
@CasualTriangle
Copy link

CasualTriangle commented Jun 3, 2018

Hey @Tony-hu :)
are you planing on adding a feature to have the app update an item in openHAB to represent the state of the reachability of a beacon or just the switching of sitemaps for now ?
If you do, maybe it whould be a good idear to have a new activity or something to let the user define some items which states get changed when something like a beacon gets in range of the phone or a geofence (#914) gets entered ?

@Tony080
Copy link
Author

Tony080 commented Jun 3, 2018

Hello @CasualTriangle ,

are you planing on adding a feature to have the app update an item in openHAB to represent the state of the reachability of a beacon or just the switching of sitemaps for now ?

Basically, I plan to do both of them.
I'm currently working on switching frames within sitemaps from an Android service. It's about binding a beacon(y) with a specified frame(z) from the sitemap. And then, display that frame(y) on MainActivity once a user(x) comes within range of beacon(y).
And, I'll move on the server side to make it recognize beacons as a certain kind of trigger of the rules later.
As you can see, the screenshots I have made are the new configuration activity entrance for beacons. Also, I'm working on this activity to do the binding, presence calibrating there.

states get changed when something like a beacon gets in range of the phone or a geofence (#914) gets entered ?

Yes, I agree with this point. Our topics are quite related. Perhaps we can share the same service to do the state change notifications to the openHAB server once the certain location changes? Or Google Location API has their own background service? I'm not familiar with Location API. Please correct me if I'm wrong. Thank you!

…ove unnecessary SwipeRefreshLayout.

Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
… nearest beacon with name now.

Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
…articular beacon.

Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
…lar beacon.

Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
…awer.

Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
@mueller-ma
Copy link
Member

@Tony-hu What ble beacon can you recommend for testing this PR?

@Tony080
Copy link
Author

Tony080 commented Jun 19, 2018

@mueller-ma I'm using the Blue Charm beacons. Here is the link I purchased on
Amazon US
.
It can be switched between Eddystone URL, Eddystone UID, and iBeacon. So I guess that's a good choice to avoid purchasing many beacons.

Signed-off-by: Chengzhi Hu <tony.hu1213@gmail.com>
@mueller-ma
Copy link
Member

Amazon isn't shipping this beacon to Germany, so I bought a different one (only iBeacon).

I granted the location permisson, but when I open "Test BLE Beacon" and click on the fab, I only see an empty page. Log:

07-16 17:44:08.626 30857-30857/org.openhab.habdroid.beta D/OpenHABMainActivity: Server returned sitemaps: [OpenHABSitemap{name=demo, label=Main Menu, link=https://demo.openhab.org:8443/rest/sitemaps/demo, icon=null, iconPath=icon/null, homepageLink=https://demo.openhab.org:8443/rest/sitemaps/demo/demo}]
07-16 17:44:09.113 30857-30857/org.openhab.habdroid.beta D/OpenHABMainActivity: beacons hit!
07-16 17:44:09.151 30857-30857/org.openhab.habdroid.beta D/OpenHABWidgetListFragment: onPause() https://demo.openhab.org:8443/rest/sitemaps/demo/demo
    isAdded = true
07-16 17:44:09.173 30857-30857/org.openhab.habdroid.beta W/ResourceType: Failure getting entry for 0x7f0d0002 (t=12 e=2) (error -75)
07-16 17:44:09.186 30857-30857/org.openhab.habdroid.beta I/AppCompatViewInflater: app:theme is now deprecated. Please move to using android:theme instead.
07-16 17:44:09.450 30857-30857/org.openhab.habdroid.beta D/OpenHABMainActivity: onSaveInstanceState
07-16 17:44:09.453 30857-30857/org.openhab.habdroid.beta D/OpenHABMainActivity: onStop()
07-16 17:44:09.453 30857-30857/org.openhab.habdroid.beta D/PageConnectionHolderFragment: onStop()
    Canceling connection for URL https://demo.openhab.org:8443/rest/sitemaps/demo/demo
07-16 17:44:09.454 30857-30857/org.openhab.habdroid.beta D/OpenHABWidgetListFragment: onStop
07-16 17:44:11.760 30857-30857/org.openhab.habdroid.beta W/ResourceType: Failure getting entry for 0x7f0d0002 (t=12 e=2) (error -75)
07-16 17:44:11.774 30857-30857/org.openhab.habdroid.beta I/AppCompatViewInflater: app:theme is now deprecated. Please move to using android:theme instead.
07-16 17:44:11.854 30857-30901/org.openhab.habdroid.beta D/OpenGLRenderer: endAllActiveAnimators on 0x8293c900 (RippleDrawable) with handle 0xb0bff5c0
07-16 17:44:15.625 30857-30924/org.openhab.habdroid.beta D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=5 mClientIf=0

The last message is repeated over and over.

I can see the beacon in the Android Bluetooth settings under "Available devices" (not paired).

I have also noticed that the app crashes when I revoke the location permission and the app should only ask for it when the user wants to add a beacon.

@Tony080
Copy link
Author

Tony080 commented Jul 22, 2018

@mueller-ma Thanks for the feedback. I'll take a look at the problem.

@mueller-ma
Copy link
Member

Hey @Tony-hu,
any update on this?

@Tony080
Copy link
Author

Tony080 commented Oct 1, 2018

@mueller-ma Thanks for reaching out! I'm currently busying in seeking jobs, and I'm going to graduate in December. So, I just suspend the development process.
However, I'll head back as long as I find a job.

@Jochen1980
Copy link
Contributor

What are the next steps to push this idea?

@mueller-ma mueller-ma closed this Nov 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Indicates new feature requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants