4

I'm writing custom modules for ConfigurableFirmata, I see libraries are using callbacks such as:

void Class::handleCapability(byte pin);
boolean Class::handlePinMode(byte pin, int mode);
...
boolean Class::handleSysex(byte command, byte argc, byte *argv);

Question is, I don't quite get why some of functions are boolean and when to return TRUE or FALSE (and what happens when you return TRUE or FALSE?).

user2226755
  • 12,494
  • 5
  • 50
  • 73
Nika
  • 1,864
  • 3
  • 23
  • 44

2 Answers2

2

Answer lays in FirmataExt.cpp. If extension returns FALSE, it just sends a string to firmata, for debugging purposes.

Nika
  • 1,864
  • 3
  • 23
  • 44
0
boolean FirmataExt::handleSysex(byte command, byte argc, byte* argv)
{
  switch (command) {

    case PIN_STATE_QUERY:
      if (argc > 0) {
        byte pin = argv[0];
        if (pin < TOTAL_PINS) {
          //...
          return true;
        }
      }
      break;
    case CAPABILITY_QUERY:
      //...
      return true;
    default:
      for (byte i = 0; i < numFeatures; i++) {
        if (features[i]->handleSysex(command, argc, argv)) {
          return true;
        }
      }
      break;
  }
  return false;
}

This function return true, if command is valid.

user2226755
  • 12,494
  • 5
  • 50
  • 73