pymata_aio v2.6
New Feature Release is Available

Keep Alive Link Detection

To detect when connectivity is lost between the Arduino and pymata_aio, a keep_alive link detection feature has been added.  When activated, a keep_alive message will be sent periodically to the Arduino. If the Arduino does not receive a keep_alive message in the prescribed time, it will reset itself.

Feature Prerequisite

To make use of this feature you will need to upload FirmataPlus, FirmataPlusRB or FirmataPlusLBT to the Arduino. You may still use StandardFirmata if you do not use this feature.

Enabling the Feature

To enable the feature when using one of the FirmataPlus sketches, simply call the keep_alive API method. This method has 2 defaulted parameters.

  • period - this parameter specifies how often the keep alive message is expected to be received by the Arduino. The default value is 1 second, but may be optionally set from 0 to 10 seconds. A value of 0 disables the feature if previously enabled. Once activated, if the Arduino does not receive a keep_alive message within a period time frame, it will reset itself.
  • margin - this parameter assures that the keep alive messages are sent more often than the value specified by period. It has a default value of .3, but may optionally be set to a value of .1 to .9. It is used in a calculation in conjunction with the period parameter to determine how often to send the keep_alive message to the Arduino. The margin parameter allows you to adjust for any propagation delays.

    The formula used is:
    KEEP_ALIVE_SEND_TIME_PERIOD = period - (period * margin)

    So, for example if you use the default values, a keep_alive message will be sent to the Arduino every .7 seconds. If you selected a period of 4 seconds with a margin of .1, then a keep_alive will be sent every 3.6 seconds.