Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cloud sleep - waits for all outgoing confirmable UDP messages to be sent #909

Closed
wants to merge 5 commits into from

Conversation

@m-mcgowan
Copy link
Contributor

commented Mar 15, 2016

protocol sleep/wake commands which allow the caller to wait for all coap confirmable requests to be acknowledged, and allows the comms layer to take action when waking up after sleep.

This is used as part of system sleep to ensure confirmable messages are confirmed before entering sleep.

@m-mcgowan m-mcgowan added this to the 0.5.x milestone Mar 15, 2016

protocol sleep/wake commands which allow the caller to wait for all c…
…oap confirmable requests to be acknowledged, and allows the comms layer to take action when waking up after sleep.

@m-mcgowan m-mcgowan force-pushed the feature/cloud_sleep branch from 494f135 to 3e88705 Mar 15, 2016

When in a managed automatic mode (semi or full auto) and not threaded…
…, then wait for the cloud to reconnect for up to 1 minute. This gives the typically expected behavior that the state of the system before stop mode sleep is the same after waking up. So code like:

```
System.sleep(D1, RISING, 60*20);
Particle.publish("yo!","I woke up");
```
Functions as expected in single threaded automatic mode.

move DTLSProtocol::sleep into CPP file - this seems to cause an unexpected crash otherwise.
@m-mcgowan

This comment has been minimized.

Copy link
Contributor Author

commented Mar 15, 2016

3014dd5 addresses issue #894 - the system will reconnect to the cloud before returning control back to the application loop after waking up.

fixes build on PLATFORM=gcc
```
Undefined symbols for architecture x86_64:
  "typeinfo for particle::protocol::Protocol", referenced from:
      typeinfo for particle::protocol::DTLSProtocol in libcommunication.a(dtls_protocol.o)
      typeinfo for particle::protocol::LightSSLProtocol in libcommunication.a(lightssl_protocol.o)
ld: symbol(s) not found for architecture x86_64
```
The main fix is declaring `Protocol::command()` to be pure virtual.

@m-mcgowan m-mcgowan force-pushed the feature/cloud_sleep branch from dd1eb7d to 40b7359 Mar 15, 2016

m-mcgowan added 2 commits Mar 17, 2016
make System.sleep(pin, change, delay) a synchronous operation when mu…
…ltithreaded, since it disconnects/conncts the cloud, which should happen on the system thread.
@m-mcgowan

This comment has been minimized.

Copy link
Contributor Author

commented Mar 17, 2016

Test app:

void setup()
{
    Particle.publish("started","",PRIVATE);
}
int count = 0;
void loop()
{
    Serial.print("loop "); Serial.println(count);
    Particle.publish(Particle.deviceID(), String("sleeping ")+String(count),PRIVATE);
    Serial.println("sleeping.");
    Serial.flush();
    System.sleep(D3, RISING, 30);
    waitUntil(Particle.connected);

    Particle.publish(Particle.deviceID(), String("wakeup ")+String(count),PRIVATE);
    count++;
    delay(1000);
}

Expected output:
loop 0
sleeping 0
... device sleeps
wakeup 0
loop 1
sleeping 1
... device sleeps
wakeup 1


The test can then be changed to sleep for (30*60) seconds to test long term sleep.

I have completed these tests and verified success. 
@technobly

This comment has been minimized.

Copy link
Member

commented Mar 19, 2016

Closing so we don't try to merge, see PR #918 for replacement to this one.

@technobly technobly closed this Mar 19, 2016

@technobly technobly removed their assignment Mar 19, 2016

@m-mcgowan m-mcgowan deleted the feature/cloud_sleep branch Oct 16, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.