コード例 #1
0
    def send_string(self, s):
        if not self.is_on:
            raise RuntimeError('Start Wifi before this method')

        hdal = self.__make_dal_header()
        hpxt = self.__make_pxt_header(2)
        dpxt_s = s.encode()
        msg = hdal + hpxt + dpxt_s
        espnow.send(StuduinoBitRadio.BROADCAST_MAC_ADDRESS, msg)
コード例 #2
0
def sendToController(color):
    addLightOnBorad(color)
    msg = {}
    msg['player'] = 1  # number of player
    msg['action'] = {}
    msg['action']['color'] = color
    msg['action']['value'] = 1  # True , False
    espnow.send(UNICAST_CONTROLLER, str(msg))
    print('Send success')
コード例 #3
0
    def send_buffer(self, buf):
        if not self.is_on:
            raise RuntimeError('Start Wifi before this method')

        hdal = self.__make_dal_header()
        hpxt = self.__make_pxt_header(3)
        dpxt_b = buf
        msg = hdal + hpxt + dpxt_b
        espnow.send(StuduinoBitRadio.BROADCAST_MAC_ADDRESS, msg)
コード例 #4
0
    def send_number(self, n):
        if not self.is_on:
            raise RuntimeError('Start Wifi before this method')

        hdal = self.__make_dal_header()
        hpxt = self.__make_pxt_header(0)
        dpxt_n = n.to_bytes(4, 'big')
        msg = hdal + hpxt + dpxt_n
        espnow.send(StuduinoBitRadio.BROADCAST_MAC_ADDRESS, msg)
コード例 #5
0
ファイル: customer.py プロジェクト: thtiiz/cloudkitchen
def button_a_callback(pin):
    global STATE
    if (STATE == 'ORDER'):
        order = {}
        order['table_num'] = TABLE_NUM
        order['chef_num'] = 1
        print("order1")
        msg = json.dumps(order)
        print("Sending:", msg)
        espnow.send(BROADCAST, msg)
        global is_served
        global COUNT
        global PRICE
        global ORDER
        ORDER[1] += 1
        COUNT += 1
        is_served = False
        toggleLED()
コード例 #6
0
from machine import ADC, Pin
import network
from esp import espnow
import time

w = network.WLAN()
w.active(True)

light = ADC(Pin(34))
light.atten(ADC.ATTN_11DB)
light.width(ADC.WIDTH_12BIT)

BROADCAST = b'\xFF' * 6

espnow.init()
espnow.add_peer(BROADCAST)

while True:
    lumen = light.read()
    # 1 = go, 0 = stop
    if (lumen > 20):
        status = 1
    else:
        status = 0
    righthand = {"direction" : status}
    print("Light: ", lumen)
    print("Check: ", str(righthand))
    espnow.send(BROADCAST, str(righthand))
    time.sleep(0.5)
コード例 #7
0
def send_serve_msg(chef_num, table_num):
    msg = {'table_num': table_num, 'chef_num': chef_num}
    espnow.send(BROADCAST, json.dumps(msg))
コード例 #8
0
import network
from esp import espnow
import time

w = network.WLAN()
w.active(True)

BROADCAST = b'\xFF' * 6

espnow.init()
espnow.add_peer(BROADCAST)

count = 0
while True:
    count += 1
    msg = "Count = {}".format(count)
    print("Sending:", msg)
    espnow.send(BROADCAST, msg)
    time.sleep(1)
    
コード例 #9
0
            msg = msg.replace("\"", "$")
            msg = msg.replace("'", "\"")
            msg = msg.replace("$", "'")
            print('new:', msg)
            msg = json.loads(msg)
            msgs = eval(msg['msg'])
            setterOLED(*msgs)


connect = False
start = False

espnow.on_recv(recieveFromController)
setterOLED('connecting...')
while (not connect):

    print('wait for connection...')
    time.sleep(1)
    lb.on()
    time.sleep(1)
    lb.off()
setterOLED('connected')
print('connected')
espnow.send(UNICAST_CONTROLLER, 'connected')
connect = True
setLed()
lb.on()  # connect

while True:
    pass
コード例 #10
0
def sendToDisplay():
    msg = {}
    msg['game'] = selected_game
    msg['data'] = problem_game
    espnow.send(MAC['display'], str(msg))
コード例 #11
0
def sendToPlayer(msg="", player='p1'):
    obj = {}
    obj['msg'] = msg
    espnow.send(MAC[player], str(obj))
コード例 #12
0
def connectDevice(device):
    espnow.add_peer(MAC[device])
    mac = MAC[device]
    while (signal[device] == False):  # bug on staging
        espnow.send(mac, 'connecting')
        time.sleep(1)