<commit_before>#REST API Specification

###List of the connected devices 
```
http://IP:PORT/list/
```
response json
```
{
	"list":
	[
		{
			"board_code":"boardID",
			"session_id":"null",
			"status":"Disconnected/Connected",
			"altitude":"alt",
			"longitude":"long",
			"latitude":"lat"
		},
		...
	]
}

```

###Export Local Services
```
http://IP:PORT/command/?board={boardID}&command={service_name}&op={start|stop}
```

response json:
```
{
	"ip":"IP",
	"port":"TUNNELED_PORT",
	"service":"ServiceName",
	"status":"start|stop"
}
```

###Set PIN mode
```
http://IP:PORT/command/?board={boardID}&command=mode&pin={pinName}&mode={input|output|pwm}
```
response json:
```
{
	"mesage": "Set Mode",
	"result": "0| ERROR DESCRIPTION"
}
```
### Digital or PWM Write
```
http://IP:PORT/command/?board={boardID}&command={analog|digital}&pin={pinName}&val={0,1 | 0,1...1024}
```
*in this REST call analog is used per PWM PIN*

response json:
```
{
	"message": "Digital Write | Analog Write",
	"result": "0 | ERROR DESCRIPTION"
}
```

### Digital or Analog read
```
http://IP:PORT/command/?board={boardID}&command={analog|digital}&pin={pinName}
```
response json:
```
{
	"message" : "Digital Read | Analog Read",
	"result": "value of the PIN | ERROR DESCRIPTION"
}
```

### Register board
```
http://IP:PORT/command/?command=reg-board&board={boardID}&board_label={label}&latitude={latitude}&longitude={longitude}&altitude={altitude}&net_enabled={net_enabled_flag}&sensorlist={sensors_list}
```

response json:
```
{
	"result": "Registration successfully completed!"
}
```

### Update board
```
http://IP:PORT/command/?command=update-board&board={boardID}&board_label={label}&latitude={latitude}&longitude={longitude}&altitude={altitude}&net_enabled={net_enabled_flag}&sensorlist={sensors_list}
```

response json:
```
{
	"result": "Updating board successfully completed!"
}
```

### Unregister board
```
http://IP:PORT/command/?command=unreg-board&board={boardID}
```

response json:
```
{
	"result": "Unegistration board successfully completed!"
}
```




### Sensor List
```
http://IP:PORT/sensorlist
```

response json:
```
{
	"message":
	[
		{
			"id":1,
			"type":"temperature",
			"unit":"°C",
			"fabric_name":"Thermistor",
			"model":"TinkerKit"
		},
		{
			"id":2,
			"type":"brightness",
			"unit":"lux",
			"fabric_name":"LDR",
			"model":"TinkerKit"
		},
		{
			"id":3,
			"type":"humidity",
			"unit":"%",
			"fabric_name":"HIH-4030",
			"model":"Honeywell"
		},
		{
			"id":4,
			"type":"sound_detect",
			"unit":"db",
			"fabric_name":"HY-038",
			"model":"Keyes"
		},
		{
			"id":5,
			"type":"gas",
			"unit":"ppm",
			"fabric_name":"MQ9",
			"model":"Grove"
		},
		{
			"id":6,
			"type":"barometer",
			"unit":"hPa",
			"fabric_name":"mpl3115",
			"model":"TinkerKit"
		}
	],
	"result":"SUCCESS"
}
```

### Cloud Plugins
```
http://IP:PORT/pluginlist
```

response json:
```
{
	"message":
		[
			{
				"id":<NUM>,
				"name":"<PLUGINNAME>",
				"category":"async | sync",
				"jsonschema":"./schemas/<PLUGINSCHEMA>.json",
				"code":"./plugins/<PLUGINNAME>.js"
			},
			{ ... },
		],
	"result":"SUCCESS"
}
```

### Board Layout
```
http://IP:PORT/command/?command=board-layout&board={boardID}
```

response json:
```
{
	"message":{
		"sensors":
		[
			{
				"type":"temperature",
				"model":"TinkerKit",
				"id":1
			},
			{
				"type":"brightness",
				"model":"TinkerKit",
				"id":2
			}
			...
		],
		"plugins":
		[
			{
				"name":"prova",
				"id":10,
				"state":"injected"
			}
			...
		]<commit_msg>Update rest.md<commit_after>#REST API Specification

###List of the devices 
```
http://IP:PORT/list/
```
response json
```
{
	"list":
	[
		{
			"board_code":"boardID",
			"session_id":"null",
			"status":"Disconnected/Connected",
			"altitude":"alt",
			"longitude":"long",
			"latitude":"lat"
		},
		...
	]
}

```

###Export Local Services
```
http://IP:PORT/command/?board={boardID}&command={service_name}&op={start|stop}
```

response json:
```
{
	"ip":"IP",
	"port":"TUNNELED_PORT",
	"service":"ServiceName",
	"status":"start|stop"
}
```

###Set PIN mode
```
http://IP:PORT/command/?board={boardID}&command=mode&pin={pinName}&mode={input|output|pwm}
```
response json:
```
{
	"mesage": "Set Mode",
	"result": "0| ERROR DESCRIPTION"
}
```
### Digital or Analog Write
```
http://IP:PORT/command/?board={boardID}&command={analog|digital}&pin={pinName}&val={0,1 | 0,1...1024}
```
*in this REST call analog is used per PWM PIN*

response json:
```
{
	"message": "Digital Write | Analog Write",
	"result": "0 | ERROR DESCRIPTION"
}
```

### Digital or Analog Read
```
http://IP:PORT/command/?board={boardID}&command={analog|digital}&pin={pinName}
```
response json:
```
{
	"message" : "Digital Read | Analog Read",
	"result": "value of the PIN | ERROR DESCRIPTION"
}
```

### Register a board
```
http://IP:PORT/command/?command=reg-board&board={boardID}&board_label={label}&latitude={latitude}&longitude={longitude}&altitude={altitude}&net_enabled={net_enabled_flag}&sensorlist={sensors_list}
```

response json:
```
{
	"result": "Registration successfully completed!"
}
```

### Update a board
```
http://IP:PORT/command/?command=update-board&board={boardID}&board_label={label}&latitude={latitude}&longitude={longitude}&altitude={altitude}&net_enabled={net_enabled_flag}&sensorlist={sensors_list}
```

response json:
```
{
	"result": "Updating board successfully completed!"
}
```

### Unregister a board
```
http://IP:PORT/command/?command=unreg-board&board={boardID}
```

response json:
```
{
	"result": "Unegistration board successfully completed!"
}
```




### Board Sensors List
```
http://IP:PORT/sensorlist
```

response json:
```
{
	"message":
	[
		{
			"id":1,
			"type":"temperature",
			"unit":"°C",
			"fabric_name":"Thermistor",
			"model":"TinkerKit"
		},
		{
			"id":2,
			"type":"brightness",
			"unit":"lux",
			"fabric_name":"LDR",
			"model":"TinkerKit"
		},
		{
			"id":3,
			"type":"humidity",
			"unit":"%",
			"fabric_name":"HIH-4030",
			"model":"Honeywell"
		},
		{
			"id":4,
			"type":"sound_detect",
			"unit":"db",
			"fabric_name":"HY-038",
			"model":"Keyes"
		},
		{
			"id":5,
			"type":"gas",
			"unit":"ppm",
			"fabric_name":"MQ9",
			"model":"Grove"
		},
		{
			"id":6,
			"type":"barometer",
			"unit":"hPa",
			"fabric_name":"mpl3115",
			"model":"TinkerKit"
		}
	],
	"result":"SUCCESS"
}
```

### Iotronic Plugins list
```
http://IP:PORT/pluginlist
```

response json:
```
{
	"message":
		[
			{
				"id":<NUM>,
				"name":"<PLUGINNAME>",
				"category":"async | sync",
				"jsonschema":"./schemas/<PLUGINSCHEMA>.json",
				"code":"./plugins/<PLUGINNAME>.js"
			},
			{ ... },
		],
	"result":"SUCCESS"
}
```

### Show Board Layout
```
http://IP:PORT/command/?command=board-layout&board={boardID}
```

response json:
```
{
	"message":{
		"sensors":
		[
			{
				"type":"temperature",
				"model":"TinkerKit",
				"id":1
			},
			{
				"type":"brightness",
				"model":"TinkerKit",
				"id":2
			}
			...
		],
		"plugins":
		[
			{
				"name":"prova",
				"id":10,
				"state":"injected"
			}
			...
		]
{'fraction_non_alphanumeric': 0.24405772495755518, 'fraction_numerical': 0.009054895302773062, 'mean_word_length': 4.323042168674699, 'pattern_counts': {'":': 140, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1395363', 'n_tokens_mistral': 3200, 'n_tokens_neox': 2660, 'n_words': 372}