Commit e5468c0b authored by Peter Müller's avatar Peter Müller

Added isInitDone method

parent 514796a3
Pipeline #288 passed with stages
in 1 minute and 15 seconds
## v4.1.1 2019-07-25
- Added method `isInitDone()`
## v4.1.0 2019-07-25
- Added new constructor call with a single object as argument
- Added option to not init the manager/serial port on instance creation
......
......@@ -241,6 +241,12 @@ init():Promise<{}>;
Initializes the manager and the serial port if options.autoInit was false on construction of the class.
Returns a promise which will be resolved if the serial port is opened and the manager is initialized or rejected in case of an error.
### rhs.isInitDone()
```ts
isInitDone():boolean;
```
Returns if the init is done (`true`) or not (`false`).
### rhs.close()
```ts
close():Promise<{}>;
......
{
"name": "radiohead-serial",
"version": "4.1.0",
"version": "4.1.1",
"description": "Bindings for the serial driver of the RadioHead library, useful to build reliable networks based on e.g. RS485 or radio.",
"keywords": [
"radiohead",
......
......@@ -25,7 +25,7 @@ import {RHReliableDatagram, RH_FLAGS_ACK, RH_DEFAULT_TIMEOUT,
RH_DEFAULT_RETRIES} from './RHReliableDatagram';
// export the current version of this module
export const version = '4.1.0';
export const version = '4.1.1';
// export some imports to allow an custom usage
export {
......@@ -233,6 +233,14 @@ export class RadioHeadSerial extends EventEmitter {
});
}
/**
* Returns if the init is done.
* @return If the init is done (true) or not (false).
*/
public isInitDone (): boolean {
return this._initDone;
}
/**
* Closes the Serialport.
* After close() is called, no messages can be received.
......
......@@ -116,7 +116,12 @@ let rhs2:RadioHeadSerial = null;
})
.catch((err) => {
// this is expected
done();
if (rhs.isInitDone()) {
// should not happen
done(new Error('isInitDone() reported true but should be false'));
}else {
done();
}
});
}
......@@ -343,6 +348,14 @@ let rhs2:RadioHeadSerial = null;
}
@suite('test functions') class TestFunctions {
@test 'isInitDone()' (done){
if (rhs2.isInitDone()) {
done();
} else {
done(new Error('isInitDone() is false but should be true'));
}
}
@test 'setAddress(0x05)' (){
rhs2.setAddress(0x05);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment