Particle.function("test", test) returns true, but function isn't registered

I’m trying to register a cloud function. Despite returning true, Particle.function() isn’t actually registering my cloud function - the function list is empty! I’m trying it out with a pretty simple scenario:


void setup() {
    Serial.begin(115200);
    while(!Serial.available()) Particle.process();
    Serial.printf("Booting.\n");
    
    // Configure the transmitter IC.
    Max7060::Options xmit_options;
    xmit_options.attenuation = 0;
    xmit_options.tuning_cap = 15;
    xmit.init(xmit_options);
    
    // Configure the remote control bit-banger.
    Liftmaster::Options remote_options;
    remote.setOptions(remote_options);
    
    // Set up the status pin from the charger IC.
    pinMode(D1, INPUT_PULLUP);
    
    // Configure the LED
    pinMode(D7, OUTPUT);
    
    // Enable listening to the pushbutton.
    pinMode(button, INPUT_PULLUP);
    
    // Register our RPC with the Particle cloud service.
    Particle.function("test", test);
    
    Serial.printf("Booted.\n");
}

I’ve got a pretty simple test function with a definitely-less-than-twelve-characters name:


int test(String command) {
    return 0;
}

Here’s what I get when I query the device:


{
  <blah blah blah>
  "variables": {},
  "functions": [],
  "cc3000_patch_version": "wl0: Nov  7 2014 16:03:45 version 5.90.230.12 FWID 01-559ee6e8"
}

My other - more complicated - app works fine. Surely I’m overlooking something simple, but I have no idea what it might be.

Not sure if it’ll help, but could you try placing the function at the top of the setup?

Through binary-search commenting, I’ve discovered that it’s the line:

while(!Serial.available()) Particle.process();

Even though I use the console and push execution past that point (and registration “works” at the time of the function call), its presence breaks real registration. This seems like a bug in the Particle-provided firmware.

AFAIK there is a (undocumented) timeout till when the functions should be registered.
It’s not documented since this behaviour is not intended :wink: