v10.0.0 release
This release is dedidcated to various functionalities updates and code improvements/restructuring.
Connection
Settings
The connection settings object has been updated:
- The 'ip' property has been renamed to 'hostname',
- A new property named 'resolved' is dedicated to store resolved address as ip, if any.
In parallel, "high-level" factories (createPoppy, createRequestHandler, createDescriptor) has been updated in order to automatically try to resolve hostname and store result in the 'resolved' property.
Note the resolved property will be set to the hostname in case of failure.
const connect = {
hostname: 'poppy.local' // instead of ip: 'poppy.local'
}
const reqHandler = createRequesHandler(connect)
const resolved = reqHandler.settings.resolved // resolved will be set to the resolved ip if resolved, with the hostname otherwise
Resolving hostname
Resolving hostname has been extended to any (only applied to .local ones before)
Misc.
Default timeout for request is now set to 500ms instead of 1000ms.
New Object Factories
New factories have been added to create PoppyRequestHandler and Descriptor.
const { createRequestHandler, createDescriptor } = require('poppy-robot-core')
createRequestHandler({ hostname: 'poppy1.home' }).then(reqHandler => {
// Get compliant state of motor m1
const speed = await reqHandler.get('/motor/m1/register/compliant/value.json')
... // Other nice stuff
})
// Discover the structure/configuration of a poppy using default connection settings
// aka poppy.local and 8080 as hostname and port
createDescriptor().then(descriptor => {
console.log(descriptor)
})
Performing Request with PoppyRequestHandler
Perform Function Update
Arguments of the perfom function has been updated and kind of method must be provided. (see jsdoc).
Performing Post or Get Request
Two functions named 'post' and 'get' have been added:
const { createRequestHandler, createDescriptor } = require('poppy-robot-core')
// RequestHandler to robot located at poppy.local with rest api served on port8080
createRequestHandler().then(reqHandler => {
let response = await reqHandler.get('/motor/alias/list.json')
console.log('aliases', response.data)
// Set motor m1 to stiff state
reqHandler.post('/motor/m1/register/compliant/value.json', false)
// Get logs
response = await reqHandler.post('/api/raw_logs', 'id=0', { baseURL: 'http://poppy.local' })
console.log(response.data)
})
Code Improvements
Various internal changes have been performed (see #38 #40 #42) without any changes in the use of this module excepted the point below
Use of Getter
A bunch of getXXX functions have been replaced with getter (see #40) introducing breaking changes
object | old function | new property |
---|---|---|
Poppy | getDescriptor() | descriptor |
getAllMotorIds() | allMotorIds | |
PoppyRequestHandler | getSettings() | settings |
Raw/ExtMotor | getName() | name |