File tree Expand file tree Collapse file tree 4 files changed +13
-13
lines changed Expand file tree Collapse file tree 4 files changed +13
-13
lines changed Original file line number Diff line number Diff line change 1
- function Converter ( decoded ) {
1
+ function Converter ( decoded , port ) {
2
2
// Merge, split or otherwise
3
3
// mutate decoded fields.
4
4
var converted = decoded ;
5
5
6
- if ( converted . led === 0 ) {
7
- converted . led = false ;
8
- }
9
-
10
- if ( converted . led === 1 ) {
11
- converted . led = true ;
6
+ if ( port === 1 && ( converted . led === 0 || converted . led === 1 ) ) {
7
+ converted . led = Boolean ( converted . led ) ;
12
8
}
13
9
14
10
return converted ;
Original file line number Diff line number Diff line change 1
- function Decoder ( bytes ) {
1
+ function Decoder ( bytes , port ) {
2
2
// Decode an uplink message from a buffer
3
3
// (array) of bytes to an object of fields.
4
4
var decoded = { } ;
5
5
6
- decoded . led = bytes [ 0 ] ;
6
+ if ( port === 1 ) {
7
+ decoded . led = bytes [ 0 ] ;
8
+ }
7
9
8
10
return decoded ;
9
11
}
Original file line number Diff line number Diff line change 1
- function Encoder ( object ) {
1
+ function Encoder ( object , port ) {
2
2
// Encode downlink messages sent as
3
3
// object to an array or buffer of bytes.
4
4
var bytes = [ ] ;
5
5
6
- bytes [ 0 ] = object . led ? 1 : 0 ;
6
+ if ( port === 1 ) {
7
+ bytes [ 0 ] = object . led ? 1 : 0 ;
8
+ }
7
9
8
10
return bytes ;
9
11
}
Original file line number Diff line number Diff line change 1
- function Validator ( converted ) {
1
+ function Validator ( converted , port ) {
2
2
// Return false if the decoded, converted
3
3
// message is invalid and should be dropped.
4
4
5
- if ( converted . led !== true && converted . led !== false ) {
5
+ if ( port === 1 && typeof converted . led !== 'boolean' ) {
6
6
return false ;
7
7
}
8
8
You can’t perform that action at this time.
0 commit comments