HomeSmartMesh/sdk-hsm-sensortag

RGB LED Usage

Closed this issue ยท 3 comments

The new Hardware has a RGB LED but it is currently not used. We need to implement some easy Szenarios to use the RGB LED

Szenarios:

  • No Thread connection :: blinks red shortly every 3s
  • Thread connected :: Green for 3s

The leds are already declared as leds and pwm leds, we can start with a simpler first blink on power on

I have an example on how to use leds with Zephyr from the HW repo with the old Zephyr platformio examples

https://github.com/HomeSmartMesh/nrf52_thread_sensortag/blob/a2b7dd8189ce723744c1acf6d6d30e3de5593727/firmware/04_dongle_pio_zephyr_blink/src/main.c#L45

indeed, this is a vital feature for the Tag usability, after some experimentation with Thread Stack, here how we can take advantage of the led.

  • as few states as possible not to confuse users
  • use different colors but also different blink frequencies (color blind friendly)
  • be low power friendly, think how long will the tag las if it is left blinking for weeks, e.g. slow down blinking, make the pulse shorter

It is also important for the development to be able to identify the state:
(note, I'm using Nordic's fork of Zephyr and openthread)
The roles are defined here : https://github.com/nrfconnect/sdk-openthread/blob/edc1a3fe2325428e7ff304ea3e92dba9da652c92/include/openthread/thread.h#L74

For the sensor tag, only those two roles are relevant

  • disabled : after factory reset, when no network was joined (no response obtained for "Discovery Request")
  • detached : after having authenticated in a network but not yet joined, e.g. after restart out of network
  • child : normal and expected operating modes

Now the led, might be needed to indicate other things like low battery, but I'll keep it out for the moment as we still don't know the range color mapping including temperature fluctuations

Normal operation

child ๐ŸŸข <- 30 sec sleep - >๐ŸŸข <- 30 sec sleep - >๐ŸŸข

Startup

in normal operation when commissioned on first startup and wake up with available credentials

๐Ÿ”ด ๐ŸŸข ๐Ÿ”ต <- 3sec -> ๐Ÿ”ด ๐ŸŸข ๐Ÿ”ต => detached ๐Ÿ”ต๐Ÿ”ต => child ๐ŸŸข <- 30 sec sleep - >๐ŸŸข <- 30 sec sleep - >๐ŸŸข

No Network

=> detached ๐Ÿ”ต๐Ÿ”ต <- sleep 40 sec - > => detached ๐Ÿ”ต๐Ÿ”ต <- sleep 40 sec - > => detached ๐Ÿ”ต๐Ÿ”ต

No Network after factory reset

=> Disabled ๐Ÿ”ต๐Ÿ”ต <- sleep 40 sec - > => Disabled ๐Ÿ”ด๐Ÿ”ด๐Ÿ”ด reboot

Factory reset

  • press both buttons after first hello signal and before second (within 3 seconds) for a quick reboot
  • repeat quick reboot x2 times

press -> reboot ๐Ÿ”ด๐ŸŸข๐Ÿ”ต quick-reboot ๐Ÿ”ด๐ŸŸข๐Ÿ”ต quick-reboot ...๐Ÿ”ต...๐Ÿ”ต...๐Ÿ”ต factory reset => reboot

without colors

โšซโšซโšซ ... โšซโšซโšซ => Startup

when running
โšซ => Child - OK
โšซโšซ => Detached
โšซโšซโšซ => Disabled