How to disable default node registration to the GW?



  • I want to create a node where the logic works independently (even if the GW is disabled). once GW begin to work I can have additional functionality for that node (communicate between both of them). How to disable default node registration to GW feature?


  • Contest Winner

    @Guest as far as I know, that's not possible. The question is what's the use case for that. In other words what do you want to accomplish? Since your gateway is always and up and running, I don't see the need for that.



  • For example, there is a wall switch which connected to a device which actually switch the light. Using MySensor library we can add additional functionality (some kind of wrapper around the device) which allows us remotely control the light. If something went wrong with my GW my device will not work.


  • Contest Winner

    @kskud My rule of thumb for designing devices like that, is to always add some kind of switch. So that you're always able to operate the device manually when MySensors isn't working.

    I just don't think you can start your sketch and then at a certain moment just initialize MySensors. There should be no need for that. MySensors handles all the communication and communication failures.



  • As for me it can be achieved by these parameters:
    #define MY_NODE_ID 7
    #define MY_PARENT_NODE_ID 0
    #define MY_PARENT_NODE_IS_STATIC

    In this case we have all what we need to initialize any node. But it doesn't work for me.


  • Plugin Developer

    Don't define MY_REGISTRATION_FEATURE, then the node doesn't have to be registered.



  • @martinhjelmare
    So I added to my node sketch:
    #define MY_NODE_ID 7
    #define MY_PARENT_NODE_ID 0
    #define MY_PARENT_NODE_IS_STATIC

    and commented out line in MyConfig.h file:
    //#define MY_REGISTRATION_FEATURE

    but it still tries to connect to the parent node (

    Starting sensor (RNNNA-, 2.0.1-beta)
    TSM:INIT
    TSM:INIT:TSP OK
    TSM:INIT:STATID,ID=10
    TSF:ASID:OK,ID=10
    TSM:FPAR
    TSM:FPAR:STATP=0
    TSM:ID
    TSM:ID:OK,ID=10
    TSM:UPL
    TSF:PING:SEND,TO=0
    !TSF:MSG:SEND,10-10-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=NACK:1
    TSF:CHKUPL:FAIL
    !TSM:UPL:FAIL


  • Plugin Developer

    @kskud

    Sorry I thought the question was how to disable node registration to gateway.

    It might be possible to have comms working without a gateway if you define the whole network with node ids and parents and make sure that all nodes can talk to their parents. But I'm more or less guessing here, since I don't know all of the transport machinery. @tekka would know best.

    For the uplink (UPL) check to return ok, the parent has to reply the PING from the node with a PONG. You have defined the node's parent to be 0, which is reserved for the gateway. So without a gateway, the UPL will fail. You could try assigning the neighbour node id, that you want your node to talk to, to the parent id of the node.

    Looking again, it seems the PING is hardcoded to the gateway address. So I don't think it's possible.



  • @martinhjelmare

    Yes. You are right.
    0_1470064751331_upload-d1a03bcb-9b27-4594-a1fb-e3374784d0f4

    And it's strange that disabling registration (MY_REGISTRATION_FEATURE) still process another kind of "registration"


  • Contest Winner

    @kskud I've given a lot of thoughts about your question. And my conclusion is as posted fist. A MySensor node should let MySensors handle all the transport of message, doing retransmits an reconnects. Therefore it needs to connect to the gateway during initialization.

    If communication fails MySensors should handle it. If for some case you are making an actuator, then it's you responsibility to add a mechanism for manually controlling the actuator. That way it can still be controlled, whenever MySensors is not available. It is just as how I designed my gesture controlled lamp. I can control it through a Gesture sensor. Being be able to control it through MySensors is just a bonus. So just add a cheap tactile switch for doing the manual control. It almost takes no programming skills nor does it take a lot of knowledge about electronics.

    My 50 cents is, that it's way easier to do as I suggest than to stay on the road you're traveling. You're trying to change the MySensors core functionality. Will you be able to achieve your goal? Perhaps, but the road might be very long and most likely only the core members are able to answer the questions you will come across. Since they spend their free time on MySensors I doubt if they have to time to answer them.

    But as stated that's my 50 cents. Good luck with your journey.



  • Probably it will help someone. I found how to do what I want without big changes. So you have to:

    1. commented out in MyConfig.h this line:
      #define MY_REGISTRATION_FEATURE

    2. add changes to MyTransport.cpp (add marked lines of code)
      bool transportCheckUplink(bool force) {
      #if !defined(MY_PARENT_NODE_IS_STATIC) and !defined(MY_REGISTRATION_FEATURE)
      if (!force && (hwMillis() - _transportSM.lastUplinkCheck) < CHKUPL_INTERVAL) {
      TRANSPORT_DEBUG(PSTR("TSF:CHKUPL:OK,FCTRL\n")); // flood control
      return true;
      }
      // ping GW
      uint8_t hopsCount = transportPingNode(GATEWAY_ADDRESS);
      // verify hops
      if (hopsCount != INVALID_HOPS) {
      // update
      _transportSM.lastUplinkCheck = hwMillis();
      TRANSPORT_DEBUG(PSTR("TSF:CHKUPL:OK\n"));
      // did distance to GW change upstream, eg. re-routing of uplink nodes
      if (hopsCount != _nc.distance) {
      TRANSPORT_DEBUG(PSTR("TSF:CHKUPL:DGWC,O=%d,N=%d\n"), _nc.distance, hopsCount); // distance to GW changed
      _nc.distance = hopsCount;
      }
      return true;
      }
      else {
      TRANSPORT_DEBUG(PSTR("TSF:CHKUPL:FAIL\n"));
      return false;
      }
      #else
      return true;
      #endif
      }

    3. add to your node's sketch:
      #define MY_NODE_ID 7
      #define MY_PARENT_NODE_ID 0
      #define MY_PARENT_NODE_IS_STATIC

    After that you will be able to start your device, send data even if the parent node is disabled (the request just fail). Once you enable GW you will be able to get presentation, heartbeat status, do standard requests to the node.


  • Contest Winner

    @kskud You know that if a new MySensors release comes available you have to make this adjustments again, right?



  • I implemented all what kskud recommended but it didn't help, the node excutes only "before" procudure and nothign else (no setup, presentation, loop, receive). Any ideas?


  • Hardware Contributor

    @TheoL said:

    If communication fails MySensors should handle it. If for some case you are making an actuator, then it's you responsibility to add a mechanism for manually controlling the actuator. That way it can still be controlled, whenever MySensors is not available. It is just as how I designed my gesture controlled lamp. I can control it through a Gesture sensor. Being be able to control it through MySensors is just a bonus. So just add a cheap tactile switch for doing the manual control. It almost takes no programming skills nor does it take a lot of knowledge about electronics.

    But what will happen if you have a power outage (happens a lot where I live) and after that the gateway doesn't restart ? Node will not be able to start, and loop forever inside the initialization of MySensors library, the behavior related to the manual control will never be called ?


  • Contest Winner

    @Nca78 If there's a power outage MySensors handles restoring communication. What you could do is install a watch dog during initialization. And give at the longest time as possible, or some kind of random. That helps overloading the gateway when everything is turned back on again.

    If a device should operate even without gateway communication, then you've got several options. Just add an extra arduino to your project. Make the MySensors node an i2c slave and handle everything else in the other Arduino. This is just one solution, which I'd only use for delicate devices,

    But none of them will keep the node operating without an UPS kind of solution. There are nowadays powerful capacitors than can store a lot ow power, this is something that can help you keep the node up and running during power outage for at least a couple of minutes.


  • Hardware Contributor

    @TheoL what I meant is in case the gateway dies, but that's very unlikely, not worth duplicating the arduino. I didn't have any wired devices until today to test the result of power outage, but a random delay in the before() sounds like an interesting solution to test in case I have problems after I install 10-20 wired modules.

    Power outages here last hours, they are doing selective power cuts as they can't keep up with the growth of the city. I would need really big capacitors 😄 I think a better option for me would be a big and good quality power bank.



  • @TheoL said:

    @kskud My rule of thumb for designing devices like that, is to always add some kind of switch. So that you're always able to operate the device manually when MySensors isn't working.

    At the moments my node halts after before() procedure.
    @kskud, how to achieve that, how to make void loop() working even if MySensensors doesn't work?


  • Contest Winner

    @Nca78 A powerbank would also be a good solution. The problem with electronic devices is that they are all designed to have a continuous flow of power 😉

    You could also investigate solar power and storing that in batteries. But for me that's too far fetched. Lucky I haven't experienced a power outage in more then 15 years.


  • Contest Winner

    So since no one has accomplished the goal of bypassing MySensors bootup function. I suggest I'll leave this topic open for a little while. But will be closing it. You can contact each other through the chat function. And if you succeed in your quest, you can start a new topic.


Log in to reply
 

Suggested Topics

  • 3
  • 3
  • 2
  • 4
  • 15
  • 24

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts