I think it might get confusing for people to understand the process of discovery and connecting to cars when they are first using the library.
It might be easier to split them up, so have a function that performs discovery:
WIRC.discover(function(device){
// called for each device that responds to the broadcast
console.log(device); // {deviceName:…,remoteAddress:…,localAddress:…};
});
Then access the car separately with the remote address.
var car = new Car('192.168.0.5', 'optional-serial-number');
car.takeControl();
car.speed(1);
I think the client code could be simplified if it was dealing with one device too.
I think it might get confusing for people to understand the process of discovery and connecting to cars when they are first using the library.
It might be easier to split them up, so have a function that performs discovery:
Then access the car separately with the remote address.
I think the client code could be simplified if it was dealing with one device too.