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

Source class #62

Closed
wants to merge 63 commits into from
Closed

Source class #62

wants to merge 63 commits into from

Conversation

arist0v
Copy link
Collaborator

@arist0v arist0v commented May 16, 2022

created basic source abstract class

@tim-hellhake
Copy link
Member

How to revert complete files with git (for example .gitignore)

git remote add upstream git@github.com:WebThingsIO/android-app.git (Needs to be done only once per repo)

git fetch --all
git checkout upstream/main .gitignore
git commit -m 'Revert .gitignore'
git push

app/build.gradle Outdated Show resolved Hide resolved
@@ -1,7 +1,7 @@
#!/usr/bin/env sh
#!/bin/sh
Copy link
Member

Choose a reason for hiding this comment

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

Please open a separate PR for updating the Gradle wrapper.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

gradle was updated in the previous PR

.gitignore Outdated Show resolved Hide resolved
.gitignore Show resolved Hide resolved
app/src/main/java/io/webthings/app/ui/theme/Color.kt Outdated Show resolved Hide resolved
app/src/main/java/io/webthings/app/ui/theme/Color.kt Outdated Show resolved Hide resolved
app/src/main/res/values/colors.xml Show resolved Hide resolved
Comment on lines +1 to +6
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Webthings" parent="android:Theme.Material.Light.NoActionBar">
<item name="android:statusBarColor">@color/purple_700</item>
</style>
Copy link
Member

Choose a reason for hiding this comment

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

Please revert this

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i didn'T edit this file yet?

app/src/main/java/io/webthings/app/utils/NavigationHost.kt Outdated Show resolved Hide resolved
@tim-hellhake
Copy link
Member

@benfrancis
image
image
image
image

arist0v and others added 6 commits May 16, 2022 20:10
Co-authored-by: Tim Hellhake <tim-hellhake@users.noreply.github.com>
Co-authored-by: Tim Hellhake <tim-hellhake@users.noreply.github.com>
Co-authored-by: Tim Hellhake <tim-hellhake@users.noreply.github.com>
Co-authored-by: Tim Hellhake <tim-hellhake@users.noreply.github.com>
Co-authored-by: Tim Hellhake <tim-hellhake@users.noreply.github.com>
Co-authored-by: Tim Hellhake <tim-hellhake@users.noreply.github.com>
@arist0v
Copy link
Collaborator Author

arist0v commented May 17, 2022

my working way is not optimal yet, i'll delete this branch and PR and did a new cleaner one!

@arist0v arist0v closed this May 17, 2022
@benfrancis
Copy link
Member

Hi @arist0v, before you spend any more time on this I wanted to comment that I don't really agree with a Source abstract class.

I think the base class for the data model of devices should be Thing.

Given the Android App is implementing an existing API specification, the implementation will be a lot simpler if we stick to the existing data model rather than inventing a new one.

I don't expect there to be other sources of devices other than a Thing, and later a ThingDirectory when we implement the W3C WoT Directory Service API for describing the collection of devices exposed by the gateway.

For WebThings Gateway 1.x, the gateway's own data model is a useful guide, though not perfect.

I'm currently working on something very similar for WebThings Cloud and it would be great to keep the data model aligned with the standard across the whole platform.

@benfrancis
Copy link
Member

BTW, another source of inspiration when modelling the internal API for a consumed Thing is the ConsumedThing interface of the WoT Scripting API, but that's just a guideline not a normative standard so you don't have to follow it exactly (and it's really designed for JavaScript, not Kotlin).

@arist0v
Copy link
Collaborator Author

arist0v commented May 17, 2022

@benfrancis no problem, i'll work that way directly creating the correct class. But the source class will still be needed since it represent the gateway itself( is the gateway available, oauth2 login function, things discovery) so except if it have something i didn't properly understand, i'll still need a source for the things

Also did we still allow adding multiple gateway to the same app? if yes it'S another important point for the source since it could have multiple source(multiple gateway)

@arist0v arist0v deleted the source_class branch May 17, 2022 13:15
@benfrancis
Copy link
Member

Basically:

  • gateway = ThingDirectory
  • device = Thing

In the WoT Discovery ontology, a ThingDirectory provides a collection of Things.

Just to make things a bit more confusing, the ThingDirectory class also extends the Thing class, because the directory itself is a Thing with its own Thing Description (that part's not implemented in WebThings Gateway yet, see WebThingsIO/gateway#2927, but it could still be modelled that way in the app for for 1.x gateways).

In pseudo code...

  • class Thing (implements something like the ConsumedThing interface in the Scripting API)

    • function getThingDescription()
    • function readProperty()
    • function writeProperty()
    • invokeAction()
    • subscribeEvent()
    • ...
  • class ThingDirectory extends Thing (implements a client of the Directory Service API)

    • function createThing()
    • function retrieveThing()
    • function updateThing()
    • function deleteThing()
    • function listThings()
    • ...

To add an individual device to the app you would add a Thing. To add a gateway to the device you would add a ThingDirectory (which is a special type of Thing which holds a collection of other Things).

Is that making any sense? I'm in the process of figuring all this out for WebThings Cloud too, so we can figure it out together :)

@arist0v
Copy link
Collaborator Author

arist0v commented May 17, 2022

So if i get it right:
ThingDirectory == gateway

1 so i add a thing directory,
2 i login to the thing directory
3 i retrive Thing from ThingDirectory

if i have multiple gateway, i had multiple ThingDirectory so:

ThingDirectory(url="myname.wetbhings.io", username="bob@gratton.org", password="Toothpaste")
then
for thing in ThingDirectory, listThings:
create things

is it something like that?

@benfrancis
Copy link
Member

@arist0v Yes, exactly.

@arist0v
Copy link
Collaborator Author

arist0v commented May 17, 2022

ok so the next step in my process will be to create the ThingsDirectory class and then create a screen to add the settings (url username etc...)

@benfrancis
Copy link
Member

benfrancis commented May 19, 2022

ok so the next step in my process will be to create the ThingsDirectory class and then create a screen to add the settings (url username etc...)

See #13.

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.

None yet

3 participants