Swan wake up reason

Is there a way to get the reason for Swan wake up? If I am reading command

{“req”: “card.attn”, “start”: true }

correctly, it says that in the “files” response member “will include keywords to signify the occurrence of other attention mode triggers:” env and motion (are the ones I use). I also use “usb”, but that one is not in the list.

I’ve tried to use this but I am not receiving anything in the list. More specifically, the “files” member does not appear in the response.

I am arming with

{“req”: “card.attn”,
“mode”: “arm,motion,env,usb,sleep”, ”seconds”: 3600*wake_up_hours}

I also use -motion depending on if I have tracking disabled. I also tried adding in “files”: [“motion”, “env”, “usb”], but that didn’t seem right since those are not files.

I’m probably doing something wrong.

Thanks,

Joe

Hi Joe,

You are correctly using {“req”: “card.attn” “start”: true} to retrieve the trigger events.

If you want to use files to observe changes to Notes, you’ll need to use it as follows:

Watch specific files:
{“req”: “card.attn”, “mode”: “arm”, “files”: [“data.qo”, “settings.db”], “seconds”: 1800}

Watch all file modifications:
{“req”: “card.attn”, “mode”: “arm,files”, “seconds”: 1800}

Check what files triggered attention:
{“req”: “card.attn”, “start”: true}
// Response might include: {“files”: [“data.qo”, “modified”]}

Where “modified” is the reason.

See what files you’re currently watching:
{“req”: “card.attn”, “verify”: true}
// Response might include: {“files”: [“data.qo”, “settings.db”]}

Have you been able to confirm which modes have been enabled using verify? Can I also ask which Notecarrier you are using?

Thanks,

Alex

Alex,

I am using a Notecard-F and have the Feather_en dip switch set to N_ATTN. I have not confirmed settings, I guess, because I’m not sure how to set it up. I understand the setup if I was monitoring files. but I just want to get “env” or “motion” according to the docs (if I understand what the docs are stating).

The docs for the card.attn request’s “files” response member states “…In addition {to files}, this field will include keywords to signify the occurrence of other attention mode triggers:“, where “env” and “motion” appear in the list. So my question is, how to set it up and look for these keywords?

The full list of keywords in the docs is:

"connected"

"env"

"files"

"location"

"motion"

"timeout"

"watchdog"

Thanks,

Joe

Hi Joe,

I doubled-checked as I believe what is mentioned in the documentation isn’t clear enough (I’ve got a ticket open to fix it). You shouldn’t need to specify file monitoring to get the “env” and “motion” keywords—just arm attention for those specific triggers:

Setup:
{“req”: “card.attn”, “mode”: “arm,env,motion”, “seconds”: 3600}

Check what triggered attention:
{“req”: “card.attn”, “start”: true}

Example responses:

  • Motion detected: {“files”: [“motion”]}
  • Environment variable change: {“files”: [“env”]}
  • Both triggers: {“files”: [“motion”, “env”]}
  • Timeout (after 3600 seconds with no other events): {“files”: [“timeout”]}

The keywords appear in the same files array whether you’re monitoring actual files or not. Then “start”: true is used to see why attention fired (this clears the events, so
it’s a one-time read). You can also add usb to your mode string if you want to monitor USB connection changes.

From your initial message, it looks like your first arming request should be successful. You’re not seeing the modes in the response “files”property?

Perhaps it might help for you to share exactly which requests you are performing, and I’ll try to replicate them. Can I also ask for how you are attempting to test the wake-up triggers?

Setting the Notecarrier-F FEATHER_EN dip switch to N_ATTN will remove power to the swan when you arm the Notecard with card.attn, so the sleepmode isn’t necessary unless you want to use the payloadfeature.

I apologise for having to confirm this, card.attn quite a complex request!

Thanks,

Alex

1 Like

Alex,

I’m doing the arm (“mode”: “arm,motion,env,usb”), then upon wakeup, I run some setup code to set up the notecard (some settings are based on environment variables), then I try to retrieve what triggered the attention ({“req”: “card.attn”, “start”: true}). And I am not seeing the “files” response member.

The Swan is waking up on all of the triggers just fine. Edit: I have the response JSON sent to a Blynk datastream which shows up on the app. The only response members I’m getting is “crc” and “set”: “True”.

You mention that the files response member is a one shot deal. Can any of the following requests alter the {“req”: “card.attn”, “start”: true} results?

Thanks,

Joe

{“req”: “hub.set”,
“product”: product_id,
“version”: VERSION,
“inbound”: 1,
“outbound”: 0,
“mode”: “continuous”,
“sync”: True,
“duration”: -1}

{“req”:“card.voltage”,
“mode”:“lipo”}

{“req”: “card.aux.serial”,
“mode”: “gps”}

{“req”: “card.location.mode”,
“mode”: “continuous”}

{“req”: “card.time”}

{“req”: “card.motion.mode”,
“seconds”: 15,
“motion”: 1,
“start”: True}

Hi Joe,

None of those requests should alter the response from {“req”: “card.attn”, “start”: true}.

Could you please share the responses you are seeing? Are you using note-arduino?

I think it may be easiest for me to see the code that you are using to handle the wakeup event. If you prefer, you can send this to me via a direct message or share it here, and I’ll take a look.

Thanks,

Alex

Alex,

I’m using CircuitPython and note-python. I’ll have to whittle down the code a bit unless you want to see all 600+ lines of code. I’m working more than one issue and will get back to you as soon as I can.

Thanks,

Joe

1 Like

Alex,

I just realized that you asked for code used to handle the wakeup event. With CircuitPython and note-python, the swan wakes up and the code runs from the beginning. The notecard commads listed above is what I issue when the code begins. Then, I issue the request listed in the first post to retrieve the wake up trigger event(s). And the result is always

{‘crc’: ’0008:87CEAA27’,’set’: True}

Thanks,

Joe