RocNet Communications Examples?

Re: RocNet Communications Examples?

Postby Liviu M » 11.11.2016, 16:30

Hi Dagnall,

the only tested and really working version is the TivaC version. The other two are just to see if the library compiles.
The mqtt & wifi configurations for ESP8266 are copied from one example coming with the ESP. I plan to make same test with the board, but I have some business trips ahead and I don't know when I'll find the time.

The myIp & myGw are rests from the TivaC (Ethernet) examples, should be deleted/replaced by the wifi ones.
The warnings (Toys & TivaC) are generated by the library.properties; I'll clean them.

Code: Select all
category=Toys
url=https://github.com/lmmeng/RN
architectures=TivaC LM4C1294


Cheers,
Liviu

LE: I've cleaned the library.properties & README.md files.
LLE: Cleaned a little the ESP8266 version, thanks for reporting.
----------------------------------------------
System: DCC N-Scale
CS: Profiboss (Loconet)
Server: RaspberryPi/OpenSuse
----------------------------------------------
My git repos
----------------------------------------------
Liviu M
 

Re: RocNet Communications Examples?

Postby Dagnall » 11.11.2016, 17:37

I also have some work I should be doing..., but I thought I would have a quick look...
My plan was to see if I could get the code working on my ESP8266 (with the EEPROM..!) and then change my code over to using your library... , but I expect it will take a few weeks...

Enjoy the Business Trips!
We chat later when you get back....and I may have managed to understand your code better by then!... :wink:

Cheers
Dagnall
Dagnall
 

Re: RocNet Communications Examples?

Postby Liviu M » 11.11.2016, 19:50

Hi Dagnall,

the "library" is my first attempt to build one and it is just a beginning. For these reasons, it don't know how well "structured" it is. I've upload it to github just to have it "at hand" if I need it when I'm away from home (in the hotel, for example :)).
And as it was already on the web, I've mentioned it here, maybe someone (you, for example :D ) find in it a useful start and improve it.

Regards,
Liviu
Last edited by Liviu M on 13.11.2016, 19:21, edited 1 time in total.
----------------------------------------------
System: DCC N-Scale
CS: Profiboss (Loconet)
Server: RaspberryPi/OpenSuse
----------------------------------------------
My git repos
----------------------------------------------
Liviu M
 

Re: RocNet Communications Examples?

Postby Liviu M » 12.11.2016, 14:39

Hi Dagnall,

today I've successful tested the communication between Rocrail and an ESP8266 running the (updated) example found on github.

Code: Select all
1478957254: New client connected from 192.168.1.16 as ESP8266_16 (c1, k15).

EEPROM programming seems broken.

Cheers,
Liviu
----------------------------------------------
System: DCC N-Scale
CS: Profiboss (Loconet)
Server: RaspberryPi/OpenSuse
----------------------------------------------
My git repos
----------------------------------------------
Liviu M
 

Re: RocNet Communications Examples?

Postby Liviu M » 12.11.2016, 16:50

Hi Dagnall,

if you downloaded the version mentioned in my previous message, please throw it and download it again. I've reorganized the file structure with (I hope) a better one.

Regards,
Liviu
----------------------------------------------
System: DCC N-Scale
CS: Profiboss (Loconet)
Server: RaspberryPi/OpenSuse
----------------------------------------------
My git repos
----------------------------------------------
Liviu M
 

Re: RocNet Communications Examples?

Postby Liviu M » 14.02.2017, 21:02

Hi Dagnall, all,

because someone on a Romanian forum was interested in it, I developed my "library" a little bit further.
Right now the library allow the communication with Rocrail for programming (Programming -> RocNet -> Setup), sends the sensor messages for the ports defined as inputs and commands the accessories connected to the ports defined as outputs (on/off switching or, since today, servos).
As I said, the ports may be configured as input/outputs (switching or servo) using the RocNet programming menu.

I've tested it (including the servo outputs) on a Launchpad from TI, and the colleague from the Romanian forum has tested (without the servo) on an ESP8266.
The code is, as usual, on the github; the servo version has its own branch. I'll merge it with the master sometime.
I've tried to put some documentation on the wiki, but I'm not sure how useful it is.

Cheers,
Liviu
----------------------------------------------
System: DCC N-Scale
CS: Profiboss (Loconet)
Server: RaspberryPi/OpenSuse
----------------------------------------------
My git repos
----------------------------------------------
Liviu M
 

Re: RocNet Communications Examples?

Postby Dagnall » 15.02.2017, 12:38

Livu, thanks,
I have not tried "meshing" my code with your RN library.. Sorry... The differences in the way our two codes work is too great for me at the moment and because mine is "working adequately", I have not had the drive to try and integrate them.

But I have been doing some small updates to my own code.
The stationary stuff all works, there are servo, pwm or on/off "Outputs". "Blink" and "Invert" also work.
When you do a single channel set/trim in rocrail, the servo now immediately drives to the new set position (which was the correction I just added).
The inputs all have pull up resistors (inside the esp), so just need an external Hall switch to work.
I have left in the RFID code, but do not use it myself.

One thing I would very much like to have is a Iphone or Android app that can connect to the MQTT and send the Single Channel trim settings. This would make it much easier to go around the garden and set up the points servos positions. Perhaps Rob could add a single channel write "trim" tab into rocweb?? :coding:


The Loco stuff works quite well, and using a servo as the motor drive means you only use one ESP pin. There has been some interest n this.
The Loco code also accepts loco CV's, so you can alter the way it responds. As "standard" it has front and back lights and the motor.
Because I also have PWM ability on the "outputs" It is quite simple to change to PWM motor drive and I know one person has tried this out.

Another thing I have added is an interface with WifiManager, which really improves the initial setup. You do not need to have a secrets file, as it sets up an AP and scans for wifi if it cannot connect to the last known wifi..
I am looking at adapting this to add MQTT setup as well, but right now my code (once it has got onto wifi) scans for (open) MQTT servers automatically (but slowly) . This should make it much easier to transport to new locations.

my code is still at https://github.com/dagnall53/ESPWIFIROCNET

Dagnall
Dagnall
 

Re: RocNet Communications Examples?

Postby Liviu M » 15.02.2017, 17:23

Hi Dagnall,

Posting here doesn't mean I'm expecting you to use my project, :) it means I'm still hijacking your topic. :mrgreen:
I just wanted to keep you (all) informed about my project's stand and I don't knew a better place to post it.

Best regards,
Liviu

PS Your project is way ahead of mine, but I'm approaching :mrgreen:
:beer:
----------------------------------------------
System: DCC N-Scale
CS: Profiboss (Loconet)
Server: RaspberryPi/OpenSuse
----------------------------------------------
My git repos
----------------------------------------------
Liviu M
 

Re: RocNet Communications Examples?

Postby Dagnall » 18.02.2017, 16:43

Liviu , Thanks for the update.. I was VERY surprised to see Rob has added a link to my project in a very short list of examples.. I would have thought he would have included your code first!.

The weather here is now nearly at the point where I might actually put my circuits out in the garden, instead of playing with them next to the desk.... :coding: (Rob, we need a smily with a train running!!!! :wink: )
I have been distracted by trying to upgrade my 3d printer to dual extrusion so I can print lamps and points indicators with transparent AND black materials...

Also I have an idea for an improvement to rocweb, so will post that in a separate topic so Rob and others can perhaps answer it.

Dagnall :beer:
Dagnall
 

Re: RocNet Communications Examples?

Postby Liviu M » 18.02.2017, 18:51

Hi Dagnall,
Dagnall wrote: in a very short list of examples.. I would have thought he would have included your code first!.

No idea what you mean, but I think Rob has right. Apart from hijacking your & Ellard's threads, I never made a proper presentation of my project.
So, when no project is presented, no project can be cited.

But the important part of the post is that today I had first success with qos1 messages and have a question to you and Rob: how large should be the waiting time before retransmission?
To implement the qos1, I've done some minor changes to the PubSubClient, I'm curious if I'll have more success than you with the pull request. :mrgreen: My approach is a little different than yours - I've changed the library just to allow creating qos1 headers and to propagate the PUBACK to my sketch.
If the pull request will be refused, I'll distribute my own version, but I don't like the idea.

Best regards,
Liviu
----------------------------------------------
System: DCC N-Scale
CS: Profiboss (Loconet)
Server: RaspberryPi/OpenSuse
----------------------------------------------
My git repos
----------------------------------------------
Liviu M
 

Re: RocNet Communications Examples?

Postby Dagnall » 25.02.2017, 15:49

I may be wrong, but pubsubclient supports qos1 as standard, so does not need modification. ?

The Publish function returns false if it fails to send, or if the connection is lost..so you can check this and simply resend if false...
So you should not need to add anything to pubsubclient ?
In my tests I did not have any issues with the sensors not sending.
I did have issues with the loco losing connection.. So I added code that stops the loco instantly if it loses connection. This is where the persistence setting rob added is so important. If the trains misses a stop or other command, it is retransmitted when the unit (loco) next manages to connect. This only works for the last command, but provided messages are not too frequent, it works ok.

I discussed adding qos2 service with the guy who wrote pubsubclient, but it would add a lot of problems.

I did try a sort of qos2 service in my code but found it was unnecessary as the QoS 1 works well in practice. The code is still there, just not used..

Dagnall
Dagnall
 

Re: RocNet Communications Examples?

Postby Liviu M » 25.02.2017, 16:06

Hi Dagnall,

Your pull request: :mrgreen:
Add QOS 1 Publish capability #206
Open
dagnall53 wants to merge 6 commits into knolleary:master from dagnall53:master


Unchanged, PubSubClient acknowledges qos1 messages, but publishes only qos0 messages.
With unchanged library Rocrail complains about qos0 not recommended at each sensor message. With my changes, the complains are gone.

Regards,
Liviu

LE Actually someone on a Romanian forum asked me to implement qos1 messages.
----------------------------------------------
System: DCC N-Scale
CS: Profiboss (Loconet)
Server: RaspberryPi/OpenSuse
----------------------------------------------
My git repos
----------------------------------------------
Liviu M
 

Previous

Return to RocNet