Send data from server to several pico w connected via uplink

Hi all,

Is it possible to use one common anvil uplink key on several pico w units and then by using a unique identifier (for example an email address) on each pico - let the anvil server module send a specific blinking pattern to the pico led based on a anvil table which contains email address and blinking pattern ?

Any help i can get on this “handshake” procedure will be greatly appreciated.

Regards
Christen

When you connect to an uplink, the functions available are “registered” with the anvil server by name.

You can override this behavior by passing a new function string name into the @...callable() decorator, and this can be done programmatically.

So if you assigned each pico its own ID (or let it pick something of its own like a unique hardware identifier or an email address or hash of some personal info) then you can do something like:

## This is pico 1
UNIQUE_ID = "01"

@anvil.pico.callable_async(f"{ UNIQUE_ID }_blinky_func")
def blinky_func(color, duration):
    # This is pseudo code, 
    # you would make a function for this to work
    pico_blink(color, duration)

anvil.pico.connect("<ALL-THE-SAME-UPLINK-KEY>")

## This is pico 2
UNIQUE_ID = "02"

@anvil.pico.callable_async(f"{ UNIQUE_ID }_blinky_func")
def blinky_func(color, duration):
    # This is pseudo code, 
    # you would make a function for this to work
    pico_blink(color, duration)

anvil.pico.connect("<ALL-THE-SAME-UPLINK-KEY>")

## This is pico 3
UNIQUE_ID = "03"

@anvil.pico.callable_async(f"{ UNIQUE_ID }_blinky_func")
def blinky_func(color, duration):
    # This is pseudo code, 
    # you would make a function for this to work
    pico_blink(color, duration)

anvil.pico.connect("<ALL-THE-SAME-UPLINK-KEY>")

# in the anvil cloud server module

def july_fourth_blink():
   anvil.server.call("01_blinky_func", "red", 0.33)
   anvil.server.call("02_blinky_func", "white", 0.33)
   anvil.server.call("03_blinky_func", "blue", 0.33)

Then when you call july_fourth_blink() from the server module after running the uplink on all three picos correctly, you should get them to blink red, white, then blue within around a second of each other.

2 Likes

Perfect - thanks a lot for your help. This is really appreciated. I will try this method and see if it works.

Ignore me, I just reread your question :slight_smile:

Nurse?