Expose Pygate events with the forwarder payload
-
Hi everyone,
I'm building a very quick POC that involves Pygate (with WIPY). The goal is to capture the payload (the diagram JSON built by packet forwarder) and provide it to a higher level, so I can access it withing Python environment. This data will be passed over to another hardware component of the POC.
I can not fully digest the architecture so may miss some essential bits, but here's what's done so far:
I've added another method to set machine status to include more
void machine_pygate_set_status_args(machine_pygate_states_t status, void* data) { bool trig = false; pygate_status = status; switch (pygate_status) { case PYGATE_LORA_PCKT_IN: if(machine_obj.trigger & PYGATE_LORA_EVENT) { trig = true; machine_obj.events |= PYGATE_LORA_EVENT; machine_obj.handler_arg = data; } break; default: break; } if(trig) { mp_irq_queue_interrupt(machine_callback_handler, &machine_obj); } }and call it once the diagram sent to the server like this:
machine_pygate_set_status_args(PYGATE_LORA_PCKT_IN, (char *)(buff_up + 12));I can see the event is triggered if I include it in main.py like this
elif (evt & machine.PYGATE_LORA_EVT): print('LoRa Event\n')However, I'm not sure how do I access the payload, ie the
machine_obj.handler_arg. Might be something trivial, but having very little familiarity with backend architecture doesn't help much.Also, is the approach is right or there's a better solution I've overlooked?
Many thanks in advance!
P.S. I did omit some details of the firmware code for brevity
-
The Payload is handled and parsed around this line in the sourcecode: https://github.com/pycom/pycom-micropython-sigfox/blob/Dev/esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.c#L1526, which Im not sure how to couple with your function..
Interesting to see you were able to make the callback work!
-
@Gijs thanks! Do you think I posted in the wrong forum - there are very few views. I'm really after architectural hint as it's not documented anywhere.
-
The Pygate LoRaWAN stack is very similar to the loranet/packet forwarder repository on github: https://github.com/Lora-net/packet_forwarder/tree/master/lora_pkt_fwd/src. Maybe they can provide you some answers. I sort of have an idea of what you are trying to achieve, but Im not sure how to accomplish it in combination with the micropython layer
-
@Gijs I managed to get the event payload to the higher level, thanks for the hint! I can see the whole diagram sent which is built by the packet forwarder, ie the full PUSH_DATA packet as per Semtech specs.
Basically, I can do this now:
elif (evt & machine.PYGATE_LORA_EVT): print('LoRa Event') print(arg, end='\n') print('\n')and get normal Python byte string with PUSH_DATA packet in
arg -
This post is deleted!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login