Socket documentation



  • Hello All,
    I have a question : I can't find anywhere the documentation about Socket, particularly the meaning of the constants (SO_CONFIRMED...). I searched a lot before writing here and I don't understand how to use LoRa without this kind of information. Where can I find it ?
    Thanks !
    Luc



  • @jmarcelino said in Socket documentation:

    @bmarkus
    Do you know if Loriot supports confirmed uplinks in the free community tier? Just wondering what happens because according to the docs downlinks are not supported.

    Yes it works as well as OTAA since the latest Network Server update. In the free community tier you can't send download messages to the device but sending and receiving MAC layer messages (commands and responses) works in both directions. You can use ADR also of course and Battery Level is also handled.



  • @lucdioc

    I tested a LoPy with a LORIOT server, sending acknowledged uplink messages from LoPy to network server works as expected. Go to Sample Websocket Application on the LORIOT server, you will see the (enqued data sent) which is the ACK sent back to LoPy:

    0_1503810245359_upload-9a01cd26-c4f1-4334-8ebf-6511a1431620

    You can check the Application Log also on the server:

    0_1503810333273_upload-2869176d-29a3-4158-bfa8-535b9ce45401

    It shows the sent DOWNLINK ACK messages.

    On the LoPy side you can use lora.callback() which returns different event code for successful and unsuccessful uplinks:

    0_1503810546013_upload-ba5ece01-2bef-40e2-92b8-7aa4a4420970

    Send messages in a loop (keep 5-10s between them depending on data rate) than turn off gateway or disconnect LoPy antenna and you will see TX_FAILED_EVENT. You can send without antenna safely, it will not damage your LoPy.

    It looks that ACK status is not displayed properly in the GUI and JSON output of the network server even if it works properly. We will investigate it, thanks for reporting!



  • @bmarkus
    Hello,
    It's the basic lora node code found in the doc :

    lora.join(activation=LoRa.OTAA, auth=(app_eui, app_key), timeout=0)
    s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
    s.setsockopt(socket.SOL_LORA, socket.SO_DR, 0)
    s.setsockopt(socket.SOL_LORA, socket.SO_CONFIRMED, True)
    s.setblocking(True)
    s.send(bytes([0x01, 0x02, 0x03]))
    s.setblocking(False)

    get any data received (if any...)

    data = s.recv(64)
    print(data)

    I have this :
    0_1503739662447_upload-72fb51da-7ffa-4890-a7ba-4b8f50ce17cc

    I have a "proof of concept" account on Loriot (meaning that it is not a free account so I should receive downlinks).

    Any clue why the SO_CONFIRMED set to True still "arrives" as "ack:false" on Loriot ?

    Thanks a lot,
    Luc



  • @bmarkus
    Do you know if Loriot supports confirmed uplinks in the free community tier? Just wondering what happens because according to the docs downlinks are not supported.



  • @lucdioc

    Please share your code.



  • Dear JMarcelino,
    Thanks for the quick answer !
    I'm trying to set SO_CONFIRMED to True, but the messages are still received by Loriot as "ack:False" (I read this using Node-RED).
    Any clue of what the SO_CONFIRMED has no effect ?
    Sincerely yours,
    Luc



  • @lucdioc
    The documentation on Socket, or usocket - for micro-socket - as used here, is at https://docs.pycom.io/chapter/firmwareapi/micropython/usocket.html

    But true there's not a lot about the meaning of those options, that's in the LoRa side of the documentation kind of hidden as comments in an example

    # configuring the data rate
    s.setsockopt(socket.SOL_LORA, socket.SO_DR, 5)
    
    # selecting non-confirmed type of messages
    s.setsockopt(socket.SOL_LORA, socket.SO_CONFIRMED, False)
    
    # selecting confirmed type of messages
    s.setsockopt(socket.SOL_LORA, socket.SO_CONFIRMED, True)
    

    That's all there is for LoRaWAN options



Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.