home-climate-control / xbee-api-reactive Goto Github PK
View Code? Open in Web Editor NEWThis project forked from andrewrapp/xbee-api
License: GNU General Public License v3.0
This project forked from andrewrapp/xbee-api
License: GNU General Public License v3.0
InputStreamThread
reads from the hardware and uses PacketParser
to parse incoming packets. The implementation is "upside down" - instead of instantiating clean data objects (which can eventually become Java 14 records), classes that include both code and data are "saddled" on top of the input stream and consume it in a manner that makes it impossible to convert to streaming code.
Implementation created that is capable of emitting clean data objects with no code in them.
Depends on: #11
The rest of DIY Zoning ecosystem is already on Gradle, need to bring this one up to speed, too.
XBee
exposes sendPacket()
which is not thread safe and may be called out of order.
The implementation hides the details of sending XBee packets, and enforces thread safety and FIFO order of packets scheduled to send.
Related: #12
Current Gradle build issues this warning:
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.9/userguide/command_line_interface.html#sec:command_line_warnings
When sending a remote request via sendSynchronous()
, the response received is properly matched against the request sent.
The first response received is interpreted as the actual response.
2022-10-03 10:44:52,373 INFO AbstractHvacDriver pool-21-thread-1 [run, setStage] stage=1
2022-10-03 10:44:52,378 INFO XBee pool-21-thread-1 [run, setStage, setState, write(0013A200.402D030D:D2)] Sending request to XBee: apiId=REMOTE_AT_REQUEST (0x17),frameId=1,command=D2,value=0x05,remoteAddr64=0x00,0x13,0xa2,0x00,0x40,0x2d,0x03,0x0d,remoteAddr16=0xff,0xfe,applyChanges=true
2022-10-03 10:44:52,379 INFO XBee pool-21-thread-1 [run, setStage, setState, write(0013A200.402D030D:D2)] Sending packet to XBee 0x7e,0x00,0x10,0x17,0x01,0x00,0x7d,0x33,0xa2,0x00,0x40,0x2d,0x03,0x0d,0xff,0xfe,0x02,0x44,0x32,0x05,0x3b
### Mismatched response: expecting D2, received NT, didn't realize
2022-10-03 10:44:54,558 INFO XBeeSwitch pool-21-thread-1 [run, setStage, setState, write(0013A200.402D030D:D2)] D2 response: command=NT,status=OK,value=0x00,0x3c,apiId=AT_RESPONSE (0x88),length=7,checksum=0x98,error=false,frameId=0x01
2022-10-03 10:44:54,563 DEBUG Marker pool-21-thread-1 [run, setStage, setState, write(0013A200.402D030D:D2)] marker@1e5afc2#c8142c: (write(0013A200.402D030D:D2)) completed in 2185 ms (0:00:02.185)
Adapter initializes and keeps working normally.
(observed on rev. 6198fb7)
On startup with some hardware configurations, the exception trace below is printed onto stdout
, no further communication is happening.
Mismatch between the desired and the actual API state (byte values are escape (0x7D
) and XON (0x11
)), the packet is not properly unescaped, and the checksum is not calculated on correct payload.
The checksum byte is also escaped.
The exception propagates unchecked and kills the reader thread.
Exception in thread "XBeeReader" java.lang.IllegalArgumentException: Checksum mismatch, expected 0x7D, actual 0x11
at com.homeclimatecontrol.xbee.response.ResponseReader.verifyChecksum(ResponseReader.java:116)
at com.homeclimatecontrol.xbee.response.ResponseReader.read(ResponseReader.java:50)
at com.homeclimatecontrol.xbee.HardwareReader.readFrame(HardwareReader.java:90)
at com.homeclimatecontrol.xbee.HardwareReader.processFrame(HardwareReader.java:71)
at com.homeclimatecontrol.xbee.HardwareReader.read(HardwareReader.java:53)
at java.base/java.lang.Thread.run(Thread.java:834)
As an Application Maintainer, I want local and CI/CD builds to produce ErrorProne reports so that they can be available on the spot without jumping through the hoops with IDE plugins.
Acceptance Criteria: Gradle build composes ErrorProne report.
Even though the reactive code (see XBeeReactive
as a starting point) is now functional, there are still pieces of old code present in the project that have not been completely ported, or retired.
At some point into the life of the application using xbee-api, this message starts repeating regardless of the system load. Need to verify whether this message is superfluous, or it is a sign of a bigger problem.
Looks like a missing switch statement break in SerialPortConnection
. Investigating.
Same as #19 , only for reactive code.
Sometimes it's throw new IllegalStateException("not connected");
sometimes it is throw new XBeeNotConnectedException()
. Need to figure out the contract and unify.
As an Application Maintainer, I want to enable test coverage calculation as a build pipeline so that I can have an idea about what code can be (somewhat) trusted.
RxTx shows its age, and is in unknown development state.
In no particular order
IXBee
defines the xbee-api
API, contains methods that probably shouldn't be exposed at this level of abstraction.
An API is created that contains only the methods that comply to these requirements:
PacketParser#parsePacket()
creates stateful instances of XBeeResponse
subclasses, each of which combines the data, and the code.
Data objects and parsers are separated, stateless parsers produce instances of data objects.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.