I'm going to assume you have Arduino setup on the board? Assuming this, you can build an API server in Python that exposes some methods (see mock below), and the Android application will call it. Alternatively, bluetooth can work, but you're limited by the surrounding area (be within X distance of bluetooth device).
Let's assume you have four tasks:
Turn on fan for X minutes
Turn off fan
Turn on light attached to fan
Turn off light attached to fan
I would personally sketch the UI with giant buttons for each (Turn on Fan w/ selector, turn off, etc...), next I would mock the API as follows:
GET ROUTES:
'/api/{version}/uptime' controller: UptimeController
'/api/{version}/getstatus/{module}.json', controller: StatusController
'/api/{version}/authenticate', controller: AuthenticationController (optional only if you don't intend to expose this aside over Bluetooth)
POST ROUTES:
'/api/{version}/set/{module}/{keyindex}', controller: 'Update{Module}StatusController'
Throughout the POST route, I would create an individual controller for each module, and have three action, for example:
python
class UpdateFanController
def getStatus(handler):
return handler(self.online)
def setOn(handler, for_time = 6400):
status = FanModule.turnOnStatus(true, for_time)
return handler(status)
def setOff(handler, for_time = 6400):
status = FanModule.turnOffStatus(true, for_time)
return handler(status)
``
(apologies for the rough draft, on mobile device)
Then you just invoke it accordingly. If you're using bluetooth I recommend [this module](https://github.com/pybluez/pybluez) for it in Python, and using Android's native methods to communicate with the Bluetooth. Otherwise, if you want to do HTTPS API, I'd say use Flask since it's lightweight enough for this task. If it gets bigger, consider Django, or some other framework.
I appreciate your answer but I strictly have to use Bluetooth protocol for the communication and not WiFi. Also, my problem and lack of knowledge is more in the android app side and not on how to design the python API.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I'm going to assume you have Arduino setup on the board? Assuming this, you can build an API server in Python that exposes some methods (see mock below), and the Android application will call it. Alternatively, bluetooth can work, but you're limited by the surrounding area (be within X distance of bluetooth device).
Let's assume you have four tasks:
I would personally sketch the UI with giant buttons for each (Turn on Fan w/ selector, turn off, etc...), next I would mock the API as follows:
Throughout the POST route, I would create an individual controller for each module, and have three action, for example:
I appreciate your answer but I strictly have to use Bluetooth protocol for the communication and not WiFi. Also, my problem and lack of knowledge is more in the android app side and not on how to design the python API.