Message deserialization issues during node initialization
-
Hello there!
First of all, thanks for this project... I'm still in my first steps but that looks pretty cool: simple, feature full, efficient and tightly bound to MySensors (looks better than most of other gateway I could have tested till now).
I face a problem just after having successfully configured my MySensors serial gateway, when I try to make my first node join: I see two rows whereas I expect only one (only one node is up).
The node is a simple
S_BINARY
node, that runs over RFM69HW (moteino, same for gateway).In addition, mycontroller logs several errors:
2018-06-06T20:51:36.187+0000 [Thread-15] ERROR o.m.s.g.s.SerialDataListenerjSerialComm - Exception, org.mycontroller.standalone.exceptions.MessageParserException: Unknown message format:[], gatewayId:1 at org.mycontroller.standalone.provider.mysensors.MessageParserAbstract.update(MessageParserAbstract.java:118) at org.mycontroller.standalone.provider.mysensors.MessageParserSerial.getMessage(MessageParserSerial.java:32) at org.mycontroller.standalone.provider.mysensors.MessageParserSerial.getMessage(MessageParserSerial.java:28) at org.mycontroller.standalone.gateway.serial.SerialDataListenerjSerialComm.serialEvent(SerialDriverJSerialComm.java:146) at com.fazecast.jSerialComm.SerialPort$SerialPortEventListener.waitForSerialEvent(SerialPort.java:937) at com.fazecast.jSerialComm.SerialPort$SerialPortEventListener$1.run(SerialPort.java:885) at java.lang.Thread.run(Thread.java:745) 2018-06-06T20:51:36.206+0000 [Thread-15] ERROR o.m.s.db.dao.BaseAbstractDaoImpl - unable to update item:[GatewayTable(id=1, enabled=true, name=MySensors, networkType=MY_SENSORS, timestamp=1528318294769, state=DOWN, statusMessage=ERROR: Unknown message format:[], gatewayId:1, statusSince=1528318296197, type=SERIAL, properties={br=115200, ackEnabled=true, txDelay=0, ackWaitTime=20, failedRetryCount=1, reconnectDelay=120, dr=Auto, pn=/dev/ttyUSB0})] java.sql.SQLException: Unable to run update stmt on object GatewayTable(id=1, enabled=true, name=MySensors, networkType=MY_SENSORS, timestamp=1528318294769, state=DOWN, statusMessage=ERROR: Unknown message format:[], gatewayId:1, statusSince=1528318296197, type=SERIAL, properties={br=115200, ackEnabled=true, txDelay=0, ackWaitTime=20, failedRetryCount=1, reconnectDelay=120, dr=Auto, pn=/dev/ttyUSB0}): UPDATE "gateway" SET "enabled" = ?, "name" = ?, "networkType" = ?, "timestamp" = ?, "state" = ?, "statusMessage" = ?, "statusSince" = ?, "type" = ?, "properties" = ? WHERE "id" = ? at com.j256.ormlite.misc.SqlExceptionUtil.create(SqlExceptionUtil.java:25) at com.j256.ormlite.stmt.mapped.MappedUpdate.update(MappedUpdate.java:129) at com.j256.ormlite.stmt.StatementExecutor.update(StatementExecutor.java:472) at com.j256.ormlite.dao.BaseDaoImpl.update(BaseDaoImpl.java:409) at org.mycontroller.standalone.db.dao.BaseAbstractDaoImpl.update(BaseAbstractDaoImpl.java:276) at org.mycontroller.standalone.gateway.config.GatewayConfig.setStatus(GatewayConfig.java:109) at org.mycontroller.standalone.gateway.serial.SerialDataListenerjSerialComm.serialEvent(SerialDriverJSerialComm.java:179) at com.fazecast.jSerialComm.SerialPort$SerialPortEventListener.waitForSerialEvent(SerialPort.java:937) at com.fazecast.jSerialComm.SerialPort$SerialPortEventListener$1.run(SerialPort.java:885) at java.lang.Thread.run(Thread.java:745) Caused by: org.postgresql.util.PSQLException: ERROR: invalid byte sequence for encoding "UTF8": 0x00 at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2458) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2158) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:291) at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:432) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:358) at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:171) at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:138) at com.j256.ormlite.jdbc.JdbcDatabaseConnection.update(JdbcDatabaseConnection.java:289) at com.j256.ormlite.jdbc.JdbcDatabaseConnection.update(JdbcDatabaseConnection.java:212) at com.j256.ormlite.stmt.mapped.MappedUpdate.update(MappedUpdate.java:101) ... 8 common frames omitted 2018-06-06T20:51:36.210+0000 [Thread-15] ERROR o.m.s.g.s.SerialDataListenerjSerialComm - Exception, org.mycontroller.standalone.exceptions.MessageParserException: Unknown message format:[], gatewayId:1 at org.mycontroller.standalone.provider.mysensors.MessageParserAbstract.update(MessageParserAbstract.java:118) at org.mycontroller.standalone.provider.mysensors.MessageParserSerial.getMessage(MessageParserSerial.java:32) at org.mycontroller.standalone.provider.mysensors.MessageParserSerial.getMessage(MessageParserSerial.java:28) at org.mycontroller.standalone.gateway.serial.SerialDataListenerjSerialComm.serialEvent(SerialDriverJSerialComm.java:146) at com.fazecast.jSerialComm.SerialPort$SerialPortEventListener.waitForSerialEvent(SerialPort.java:937) at com.fazecast.jSerialComm.SerialPort$SerialPortEventListener$1.run(SerialPort.java:885) at java.lang.Thread.run(Thread.java:745) 2018-06-06T20:51:52.572+0000 [mc-th-pool-0] INFO o.m.s.provider.EngineAbstract - Seems like failed to send this message. There is no ACK received! Retried 1 time(s). MessageImpl(gatewayId=1, nodeEui=1, sensorId=SENSOR_BC, type=Internal, subType=Config, ack=1, payload=M, isTxMessage=true, timestamp=1528318312029, properties=null)
It looks like I receive weird payloads:
Unknown message format:[^@]
or even
java.lang.NumberFormatException: For input string: "^@^@0"
Do you have any idea?
Cheers,
Nicolas -
The
DummyNode
sketch is actually pretty simple and usesMySensors@2.2.0
:#define MY_RADIO_RFM69 #define MY_IS_RFM69HW #define MY_RFM69_FREQUENCY (RFM69_868MHZ) #define MY_DEBUG #include <MySensors.h> #define ID_LED_COMMAND 1 #define LED_PIN 9 void setLed(bool status) { digitalWrite(LED_PIN, status ? HIGH : LOW); } void before() { pinMode(LED_PIN, OUTPUT); setLed(true); } void setup() { } void presentation() { sendSketchInfo("DummyNode", "1.0"); present(ID_LED_COMMAND, S_BINARY, "Set onboard LED on/off"); } void loop() { wait(5000, C_SET, V_STATUS); } void receive(const MyMessage &msg) { switch (msg.type) { case V_STATUS: setLed(msg.getBool()); break; } }
But probably due to the problem above, I see my sensor, but I can't do anything with it (I don't see any call to action to switch the state of my S_BINARY)
For instance, I'd to know where I can find the button described here in the wiki.
Cheers,
Nicolas -
@nicolas Thank you for your interest with MyController.
when I try to make my first node join: I see two rows whereas I expect only one (only one node is up).
Gateway will act as a Node too. Gateway id is
0
. So it is showing two nodes, one is the gateway and another one your node.It looks like I receive weird payloads:
Unknown message format:[^@]
or even
java.lang.NumberFormatException: For input string: "^@^@0"Do you have any idea?
can you post your gateway configuration page? Looks like your gateway sends some weird payloads.
But probably due to the problem above, I see my sensor, but I can't do anything with it (I don't see any call to action to switch the state of my S_BINARY)
You can add the switch in two ways,
- Add it to UI directly. (add a
Status
variable) - Add request payload from your node code(
request(ID_LED_COMMAND, V_STATUS);
)
UI (edit sensor on ui):
Node code:
void presentation() { sendSketchInfo("DummyNode", "1.0"); present(ID_LED_COMMAND, S_BINARY, "Set onboard LED on/off"); request(ID_LED_COMMAND, V_STATUS); }
- Add it to UI directly. (add a
-
Hi @jkandasa and thanks a lot for your answer!
Here is my gateway sketch:
// Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_RFM69 #define MY_IS_RFM69HW #define MY_RFM69_FREQUENCY (RFM69_868MHZ) // Enable serial gateway #define MY_GATEWAY_SERIAL #include <MySensors.h> void setup() { // Setup locally attached sensors } void presentation() { // Present locally attached sensors } void loop() { // Send locally attached sensor data here }
I enabled
MY_DEBUG
but it may be a mistake and the cause of the problem. I'll try without!I got it for the button part, everything looks ok for my dummy node, thanks!