diff --git a/backend.py b/backend.py index 33afb90c1c77904ff5fda36a698ef42f3b288350..b72cc48f58d514b6b4ad310f21624c7aa6e5f5e2 100644 --- a/backend.py +++ b/backend.py @@ -390,11 +390,11 @@ class Backend_with_sensors(Backend): - def set_basic_nodes_configuration(self, Grp_interval, Grp_reports, Wakeup_interval): + def set_basic_sensor_nodes_configuration(self, Grp_interval, Grp_reports, Wakeup_interval): #### COMPLETE THIS METHOD ############## - return "this method configures the nodes whit a specific configuration" + return "this method configures the sensor nodes with a specific configuration" @@ -424,19 +424,22 @@ class Backend_with_dimmers(Backend): - def set_dimmer_level(self, n, level): + def get_dimmer_level(self, n): #### COMPLETE THIS METHOD ############## - return "this method sets a dimmer's brightness level of a specific node" + return "this method gets a dimmer's brightness level of a specific node" - def get_dimmer_level(self, n): + def set_dimmer_level(self, n, level): #### COMPLETE THIS METHOD ############## - return "this method gets a dimmer's brightness level of a specific node" + return "this method sets a dimmer's brightness level of a specific node" + + + diff --git a/flask-main.py b/flask-main.py index 410f9602f2f18d44623ef52fa0f414c5d03e4eff..0c229125a03ed13e731a5c1ea6cbb7857c57655f 100644 --- a/flask-main.py +++ b/flask-main.py @@ -62,9 +62,9 @@ def index(): @apiSuccess {String} Product_name Node's product name -@apiSuccess {String} Query_stage Query Stage +@apiSuccess {String} Query_stage Node object's readiness stage. Once it's at "Complete" stage, the Node object is ready to be used. -@apiSuccess {Number} Query_stage_(%) Query Stage (percentage) +@apiSuccess {Number} Query_stage_(%) Node object's readiness stage (pourcentage). Once it's at 100%, the Node object is ready to be used. @@ -108,8 +108,8 @@ def network_info(): """ -@api {post} /network/set_nodes_basic_configuration set_nodes_basic_configuration -@apiName set_nodes_basic_configuration +@api {post} /network/set_sensor_nodes_basic_configuration set_sensor_nodes_basic_configuration +@apiName set_sensor_nodes_basic_configuration @apiGroup Network @apiParam {Number} Group_Interval Number of seconds between two successive transfers of measures @@ -123,12 +123,12 @@ def network_info(): 'Wake-up_Interval' : '480' } -@apiSuccess {String} Message Description of the new nodes' configuration. +@apiSuccess {String} Message Description of the new sensor nodes' configuration. -@apiDescription Configure all nodes of the network with a predefined configuration. This methods configures only Group 1. All measurements (temperature, luminosity, motion and humidity) must be retrieved from the sensors after a given period of time (Group_Interval Number). +@apiDescription Configure all sensor nodes of the network with a predefined configuration. This methods configures only Group 1. All measurements (temperature, luminosity, motion and humidity) must be retrieved from the sensors after a given period of time (Group_Interval Number). """ -@app.route('/network/set_nodes_basic_configuration', methods=['GET','POST'], strict_slashes=False) -def network_configureNodes(): +@app.route('/network/set_sensor_nodes_basic_configuration', methods=['GET','POST'], strict_slashes=False) +def network_configure_sensor_Nodes(): # configure all the nodes of the network with a specific configuration if request.method=='POST': content = request.get_json() @@ -136,7 +136,7 @@ def network_configureNodes(): Grp_interval = int(content['Group_Interval']) Grp_reports = int(content['Group_Reports']) Wakeup_interval = int(content['Wake-up_Interval']) - return backend.set_basic_nodes_configuration(Grp_interval,Grp_reports,Wakeup_interval) + return backend.set_basic_sensor_nodes_configuration(Grp_interval,Grp_reports,Wakeup_interval) return 'wrong input' return 'use POST method' @@ -278,7 +278,14 @@ def reset(): @apiSuccess {String[]} JSON List of all nodes in the network in a JSON format -@apiDescription Lists all nodes in the network +@apiSuccessExample {json} Example of result in case of success: +{ + "1": "Z-Stick Gen5", + "2": "MultiSensor 6", + "3": "ZE27" +} + +@apiDescription Lists IDs and product names of all nodes in the network """ @@ -297,7 +304,7 @@ def nodes(): @apiSuccess {String} Message Node added successfully -@apiDescription Adds Node to the network by getting the controller into inclusion mode for 20 seconds. The node can not be a controller. +@apiDescription Adds Node to the network by getting the controller into inclusion mode for 20 seconds. It's the equivalent of the pressing of the controller's button. The node can not be a controller. """ @@ -315,7 +322,7 @@ def add_node(): @apiSuccess {String} Message Node removed successfully -@apiDescription Removes Node from the network by getting the controller into exclusion mode for 20 seconds +@apiDescription Removes Node from the network by getting the controller into exclusion mode for 20 seconds. It's the equivalent of the persistent pressing of the controller's button. """ @@ -563,7 +570,13 @@ def get_neighbours_list(node): @apiSuccess {String[]} JSON List of all sensor nodes in the network i a JSON format -@apiDescription Lists all sensors nodes in the network. The controller is excluded. +@apiSuccessExample {json} Example of result in case of success: +{ + "2": "MultiSensor 6", + "3": "MultiSensor 6" +} + +@apiDescription Lists IDs and product names of all sensors nodes in the network. The controller is excluded. """ @@ -767,7 +780,13 @@ def get_motion(node): @apiSuccess {String[]} JSON List of all dimmer nodes in the network i a JSON format -@apiDescription Lists all dimmer nodes in the network. The controller is excluded. +@apiSuccessExample {json} Example of result in case of success: +{ + "4": "ZE27", + "6": "ZE27" +} + +@apiDescription Lists IDs and product names of all dimmer nodes in the network. The controller is excluded. """ @@ -812,8 +831,8 @@ def get_dimmer_level(node_id): """ -@api {post} /dimmers/set_level get_dimmer_level -@apiName get_dimmer_level +@api {post} /dimmers/set_level set_dimmer_level +@apiName set_dimmer_level @apiGroup Actuators @apiParam {Number} node_id Dimmer's unique ID diff --git a/post_client.py b/post_client.py index e475c516451a23c7901c377b4514f876df5a8158..99c37174bd43ebf17b89e562ca4e936bfd19ac4f 100644 --- a/post_client.py +++ b/post_client.py @@ -12,7 +12,7 @@ import json #### Configuration of nodes -#req = requests.post('http://192.168.1.2:5000/network/set_nodes_basic_configuration',headers={'Content-Type': 'application/json'}, data=json.dumps({'Group_Interval': '240','Group_Reports':'240', 'Wake-up_Interval': '480'})) +req = requests.post('http://192.168.1.2:5000/network/set_sensor_nodes_basic_configuration',headers={'Content-Type': 'application/json'}, data=json.dumps({'Group_Interval': '240','Group_Reports':'240', 'Wake-up_Interval': '480'})) #### Config a specific parameter @@ -31,7 +31,7 @@ import json #req = requests.post('http://192.168.1.2:5000/switches/send_command',headers={'Content-Type': 'application/json'}, data=json.dumps({'node_id': '3','value':'on'})) #### Send command to dimmer -req = requests.post('http://192.168.1.2:5000/dimmers/set_level',headers={'Content-Type': 'application/json'}, data=json.dumps({'node_id': '6','value':'120'})) +#req = requests.post('http://192.168.1.2:5000/dimmers/set_level',headers={'Content-Type': 'application/json'}, data=json.dumps({'node_id': '6','value':'120'})) #### Put controller in inclusion mode #req = requests.post('http://192.168.1.2:5000/nodes/add_node') diff --git a/templates/index.html b/templates/index.html index c781514501dfa5b3f601769d2a3716814c42c3b1..08539329a4b9221bed9ee83b3f3c8dfb654c9f74 100644 --- a/templates/index.html +++ b/templates/index.html @@ -86,8 +86,8 @@ </tr> <tr> <td style="color: red;">POST</td> - <td><b>/network/set_nodes_basic_configuration</b><br/> - <td>Configure all nodes of the network with a predefined configuration. This methods configures only Group 1. All measurements (temperature, luminosity, motion and humidity) must be retrieved from the sensors after a given period of time (Group_Interval Number).</td> + <td><b>/network/set_sensor_nodes_basic_configuration</b><br/> + <td>Configure all sensor nodes of the network with a predefined configuration. This methods configures only Group 1. All measurements (temperature, luminosity, motion and humidity) must be retrieved from the sensors after a given period of time (Group_Interval Number).</td> </tr> <tr> <td>GET</td>