def tSendDiscoveryBroadcast(): global paired if paired == False: espnow.broadcast(data=str(espnow.get_mac_addr())) pass else: timerSch.stop('SendDiscoveryBroadcast') pass
tp_f = False # 積算電力量応答の有無フラグ # メインループ while True: if buf.retcomplete(): buf.readline() if buf.retcmd() == 0x6018: u.read('ERXUDP 1 2 3 4 5 6 7 ' + ''.join('{:02X}'.format(int(x)) for x in list(buf.retdata())[27:])) if u.type == 'E7': # [E7]なら受信データは瞬時電力計測値 data_mute = False draw_w() if ESP_NOW_F: # ESP NOW一斉同報発信を使う場合 espnow.broadcast(data=str('NPD=' + str(u.instant_power[0]))) if (utime.time() - am_c) >= am_interval: if (AM_ID_1 is not None) and ( AM_WKEY_1 is not None): # Ambient_1が設定されてる場合 try: # ネットワーク不通発生などで例外エラー終了されない様に try except しとく rn = am_now_power.send({'d1': u.instant_power[0]}) print('Ambient send OK! / ' + str(rn.status_code) + ' / ' + str(Am_err)) Am_err = 0 am_c = utime.time() rn.close() except: print('Ambient send ERR! / ' + str(Am_err)) Am_err = Am_err + 1 elif u.type == 'EA72': # [EA72]なら受信データは積算電力量 tp_f = True
def buttonC_wasPressed(): global send_flag, sender_address, receive_data label0.setText('broadcasting') espnow.broadcast(data=str('Broadcast')) pass
def buttonB_wasPressed(): global send_flag, sender_address, receive_data label0.setText('sending off') espnow.broadcast(data=str('off')) pass