• 0 Votes
    2 Posts
    71 Views
    M
    Hi Fredrik, First of all, CHAR_NOTIFY_EVENT works well on FiPy. Could you tell me which version you are using? I tried my example on different versions and I haven't seen a missing descriptor error. You can try the examples below. Please let me know about your experiment. BR, Meric Subscribe_Event def chr1_handler(chr, data): global battery global update events = chr.events() print("events: ",events) if events & (Bluetooth.CHAR_READ_EVENT | Bluetooth.CHAR_SUBSCRIBE_EVENT): chr.value(battery) print("transmitted :", battery) if (events & Bluetooth.CHAR_SUBSCRIBE_EVENT): update = ~update bluetooth = Bluetooth() bluetooth.set_advertisement(name='FiPy 45', manufacturer_data="Pycom", service_uuid=0xec00) bluetooth.callback(trigger=Bluetooth.CLIENT_CONNECTED | Bluetooth.CLIENT_DISCONNECTED, handler=conn_cb) bluetooth.advertise(True) srv1 = bluetooth.service(uuid=0xec00, isprimary=True,nbr_chars=1) chr1 = srv1.characteristic(uuid=0xec0e, value='read_from_here') #client reads from here chr1.callback(trigger=(Bluetooth.CHAR_READ_EVENT | Bluetooth.CHAR_SUBSCRIBE_EVENT), handler=chr1_handler) def update_handler(update_alarm): global battery global update battery-=1 if battery == 1: battery = 100 if update: chr1.value(battery) update_alarm = Timer.Alarm(update_handler, 1, periodic=True) Notify_Event def char_notify_callback(char, arg): char_value = (char.value()) print("New value: {}".format(char_value)) bt = Bluetooth() bt.start_scan(-1) adv = None while(True): adv = bt.get_adv() if adv: try: if bt.resolve_adv_data(adv.data, Bluetooth.ADV_NAME_CMPL)=="FiPy 45": conn = bt.connect(adv.mac) try: services = conn.services() for service in services: time.sleep(0.50) chars = service.characteristics() for char in chars: c_uuid = char.uuid() if c_uuid == 0xec0e: if (char.properties() & Bluetooth.PROP_NOTIFY): char.callback(trigger=Bluetooth.CHAR_NOTIFY_EVENT, handler=char_notify_callback) print(c_uuid) break except: continue except: continue bt.stop_scan() bt.disconnect_client()
  • lopy sigfox know if message is sent

    LoPy lopy4 sigfox gps callback
    2
    0 Votes
    2 Posts
    339 Views
    E
    @raaden89 Simply you can't. Sigfox as very very low downlink ability ( network to your device as 4*8 bytes limits per day!) . You just can't design this functionnality as is, and you need to think to another way to work. exemple:wait in your device for a downlink coming from sigfox with a sequencial number index, send after that the gps pos with following index and so on. On the next download your device will receive a new index (or the same at the last time if no uplink as been successfull) and your device will restart to send the gps pos following the index recevied.
  • 0 Votes
    5 Posts
    1k Views
    K
    @timh I kind of get what you're going for, but the issue is mostly that when attempting to use any sort of debouncing with multiple buttons (each button with their own callback), the first button pressed is the only button that the callback will run for until the device is reset (even though the device detects the other button is push as confirmed through looking at the pin value). So if I understand you correctly, I could simply provide arguments for each pin's callback function to identify which one was activated. That would work, but when the callback won't even go through for any button other than the first one pressed, that doesn't really work. I just worked around it and made a function to detect sequential long presses. Since I have 3 different status codes, I made it as such 1 long press sends status code 1 2 long presses sends status code 2 3 long presses sends status code 3 A user is notified of what press they are on based on the LED colors, and 3 green blinks represents that the status/data has been sent.
  • 0 Votes
    3 Posts
    1k Views
    DDecoeneD
    Hello, Thank you for pointing that out. I changed the pins to G30 (sleep) and G13 (wakeup) and now the system works fine. So, the new code is: from machine import Pin, Timer from deepsleep import DeepSleep import deepsleep def handler(button): ds.enable_pullups('G31') # can also do ds.enable_pullups(['P17', 'P18']) ds.enable_wake_on_fall('G31') # can also do ds.enable_wake_on_fall(['P17', 'P18']) print("Button pushed") ds.go_to_sleep(20) ds = DeepSleep() # get the wake reason and the value of the pins during wake up wake_s = ds.get_wake_status() print(wake_s) if wake_s['wake'] == deepsleep.PIN_WAKE: print("Pin wake up") elif wake_s['wake'] == deepsleep.TIMER_WAKE: print("Timer wake up") else: # deepsleep.POWER_ON_WAKE: print("Power ON reset") button=Pin("G30",Pin.IN, pull=Pin.PULL_UP) irq=button.callback(trigger=button.IRQ_FALLING, handler=handler) print('booted---')
  • TX callback bug

    LoPy bug lopy callback
    6
    0 Votes
    6 Posts
    2k Views
    bmarkusB
    I have no idea how LoRaWAN stack is implemented by PyCom. I just responded to your opening post that 155 bytes payload is not allowed with SF12 by the LoRaWAN Specification.
  • 0 Votes
    2 Posts
    855 Views
    L
    @ColombianAus Did you tried assigning same procedure to all pins? p_in1.callback(Pin.IRQ_FALLING | Pin.IRQ_RISING, pin_handler) p_in2.callback(Pin.IRQ_FALLING | Pin.IRQ_RISING, pin_handler) p_in3.callback(Pin.IRQ_FALLING | Pin.IRQ_RISING, pin_handler) ... you then can distinguish pins by arg.id() and e.g. Pin.module.P9.id()
  • Type error in Service Routine

    Issues & Bugs irq callback
    1
    0 Votes
    1 Posts
    739 Views
    No one has replied