There was a russian user who make a couple of sketches where nodes could talk directly without gateway, but if I remember well they were not using gw at all. I don't think normal nodes can talk directly without a gw or a repeater in the middle.

I'm now using this define MY_TRANSPORT_WAIT_READY_MS to get a "timeout" and I also use isTransportReady() to check if my device needs to work in stand-alone mode or if it is connected to the MySensors network once I exit the setup() fase.

I do not need to do node to node signalling without GW, but the info provided is nice to know

As @gohan mentioned, you need to add the test in the loop. But you can also add it to the setup() function. I did find that sometimes the link with the network is not yet active at the start of setup(). But by the end of the setup() (in my case I need to start several objects), it is usually OK.

The define is just so that a timout is limited. I found 5 seconds a bit long, so I set it to 2 seconds

#define MY_TRANSPORT_WAIT_READY_MS 2000

and then in code I test:

void loop() {
if (isTransportReady())
{
// do stuff with network in place
}
else
{
// do stuff without network in place
}
} // end of loop()

The sketch continues on startup when not able to connect (my BBQ-temp node is working stand alone) but will keep on trying to connect. When the gateway is found it will connect and the data is available on iPhone.

I'm not sure if the current default behaviour of MySensors is to wait for 5 seconds before giving up and moving on. I was under the impression that a node would try to find a network until my hair grows back.

When the define is included in the sketch, it clearly does it's job.

@NeverDie probably meant that we should not need to set the define, unless we want to change the default 5sec wait time, or if we explicitly want to have the node hang until a network is found.

So the question is, is the default behaviour to keep looking for a network, or does the library stop after 5sec and move on with the setup() ?

@gertsanders I see. To me, providing an example that sets the value to its default value would make little sense since setting it would not change anything. But everyone interprets things based on prior experiences, and everyone's experiences are different.

I am unable to find an example that sets MY_TRANSPORT_WAIT_READY_MS in the MySensors git repo. Do you remember where you saw it?

@mfalkvidd
Nope, I probably got this from a forum message somewhere. I’m not sure where I got the suggestion to use the define.
The thing is, it is very nice to have this #define, but as @Neverdie said, it would be nice to avoid that a node “hangs” if the gateway is unavailable. As far as I can see, there is no DEBUG message if the network is not reachable. And for a new MySensors user a hanging node is really confusing (it is sometimes for me as well). So this #define will now be part of me ‘default’ template until the standard behaviour is adapted.

I think it is logical to have sensors try indefinitely since this is the concept of sensors in a network.
Otherwise you would not know (when not debugging) all is ok in your network.
A network sensor not being one in an usual way, just for convenience (like my BBQ-temp sensor), has to be defined otherwise.