Пример #1
0
    def setup(self):
        # Turn off network services that are not needed
        network.Bluetooth().deinit()
        network.WLAN().deinit()
        network.LTE().deinit()

        self.gnss.setup()
        for communication in self.communications:
            communication.setup()
Пример #2
0
def bt_log_reset(*args):
    global bt_log_readout
    bt_log_readout = 0


def bt_log_read(*args):
    global bt_log_readout
    if bt_log_readout < len(log):
        bt_log_readout += 1
        if bt_log_readout < len(log):
            # Updating the value should cause a notify
            bt_log.value(log[bt_log_readout])


# UUIDs for use in lopychat:
bt = network.Bluetooth()
# BT service   ca9df61a-9251-4bde-baae-6580dffa22ef
s_uuid = b"\xca\x9d\xf6\x1a\x92\x51\x4b\xde\xba\xae\x65\x80\xdf\xfa\x22\xef"
# post message e0683361-b328-4a8d-bb85-961b57d4bbe8
p_uuid = b"\xe0\x68\x33\x61\xb3\x28\x4a\x8d\xbb\x85\x96\x1b\x57\xd4\xbb\xe8"
# message log  4886956d-b295-47a8-9c49-1c256881bf38
l_uuid = b"\x48\x86\x95\x6d\xb2\x95\x47\xa8\x9c\x49\x1c\x25\x68\x81\xbf\x38"
bt.set_advertisement(name="LoPyChat", service_uuid=s_uuid)
btsvc = bt.service(uuid=s_uuid)
post = btsvc.characteristic(uuid=p_uuid)
post.callback(trigger=bt.CHAR_WRITE_EVENT, handler=bt_post_handler)
bt_log = btsvc.characteristic(uuid=l_uuid)
bt_log.callback(trigger=bt.CHAR_WRITE_EVENT, handler=bt_log_reset)
bt_log.callback(trigger=bt.CHAR_READ_EVENT, handler=bt_log_read)
lora_s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
lora_s.setblocking(False)
Пример #3
0
import machine
if machine.Pin("G17", mode=machine.Pin.IN,
               pull=machine.Pin.PULL_UP).value() == 0:
    machine.main("noop.py")

import config
machine.WDT(timeout=config.WATCHDOG_TIMEOUT * 1000)

import pycom
pycom.heartbeat_on_boot(False)
pycom.heartbeat(False)
pycom.wifi_on_boot(False)

import network
network.WLAN().deinit()
network.Bluetooth().deinit()
network.Server().deinit()
Пример #4
0
import gc
import sys
import network as n
import gc
import time
 
b = n.Bluetooth()
 
found = {}
complete = True
 
def bcb(b,e,d,u):
  global complete
  global found
  if e == b.CONNECT:
    print("CONNECT")
    b.ble_settings(adv_man_name = "firebeetle-esp32", adv_dev_name="firebeetle-esp32")
    b.ble_adv_enable(True)
  elif e == b.DISCONNECT:
          print("DISCONNECT")
  else:
    print ('Unknown event', e,d)
 
def cb (cb, event, value, userdata):
  print('charcb ', cb, userdata, ' ', end='')
  if event == b.READ:
    print('Read')
    return 'ABCDEFG'
  elif event == b.WRITE:
    print ('Write', value)
 
Пример #5
0
import gc
import time
import micropython

micropython.alloc_emergency_exception_buf(100)

b = n.Bluetooth().ble_settings(
    int_min = 1280, 
    int_max = 1280,
    adv_type = bluetooth.ADV_TYPE_IND,
    own_addr_type = bluetooth.BLE_ADDR_TYPE_PUBLIC,
    peer_addr = bytes([0] * 6),
    peer_addr_type = bluetooth.BLE_ADDR_TYPE_PUBLIC,
    channel_map = bluetooth.ADV_CHNL_ALL,
    filter_policy = blueooth.ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY,
    adv_is_scan_rsp = False,
    adv_dev_name = None,
    adv_man_name = None,
    adv_inc_tx_power = False,
    adv_int_min = 1280,
    adv_int_max = 1280,
    adv_appearance = 0,
    adv_uuid = None,
    adv_flags = 0
)

found = {}
complete = True

def bcb(b,e,d,u):
    global complete