esp32/mods/modlora.c
static int lora_socket_socket (mod_network_socket_obj_t *s, int *_errno) {
    if (lora_obj.state == E_LORA_STATE_NOINIT) {
        *_errno = MP_ENETDOWN;
        return -1;
    }
    s->sock_base.u.sd = 1;
    uint32_t dr = DR_0;
    switch (lora_obj.region) {
    case LORAMAC_REGION_AS923:
    case LORAMAC_REGION_EU868:
        dr = DR_5;
        break;
    case LORAMAC_REGION_AU915:
    case LORAMAC_REGION_US915:
    case LORAMAC_REGION_US915_HYBRID:
        dr = DR_4;
        break;
    default:
        break;
    }
    LORAWAN_SOCKET_SET_DR(s->sock_base.u.sd, dr);

    // port number 2 is the default one
    LORAWAN_SOCKET_SET_PORT(s->sock_base.u.sd, 2);
    return 0;
}
///******************************************************************************/
//// Micro Python bindings; LoRa socket
Micro Python bindings; LoRa socket
Micro Python bindings ; LoRa socket
static int lora_socket_socket (mod_network_socket_obj_t *s, int *_errno) {
    if (lora_obj.state == E_LORA_STATE_NOINIT) {
        *_errno = MP_ENETDOWN;
        return -1;
    }
    s->sock_base.u.sd = 1;
    uint32_t dr = DR_0;
    switch (lora_obj.region) {
    case LORAMAC_REGION_AS923:
    case LORAMAC_REGION_EU868:
        dr = DR_5;
        break;
    case LORAMAC_REGION_AU915:
    case LORAMAC_REGION_US915:
    case LORAMAC_REGION_US915_HYBRID:
        dr = DR_4;
        break;
    default:
        break;
    }
    LORAWAN_SOCKET_SET_DR(s->sock_base.u.sd, dr);
    LORAWAN_SOCKET_SET_PORT(s->sock_base.u.sd, 2);
    return 0;
}
static int lora_socket_socket ( mod_network_socket_obj_t * s , int * _errno ) { if ( lora_obj . state == E_LORA_STATE_NOINIT ) { * _errno = MP_ENETDOWN ; return -1 ; } s -> sock_base . u . sd = 1 ; uint32_t dr = DR_0 ; switch ( lora_obj . region ) { case LORAMAC_REGION_AS923 : case LORAMAC_REGION_EU868 : dr = DR_5 ; break ; case LORAMAC_REGION_AU915 : case LORAMAC_REGION_US915 : case LORAMAC_REGION_US915_HYBRID : dr = DR_4 ; break ; default : break ; } LORAWAN_SOCKET_SET_DR ( s -> sock_base . u . sd , dr ) ; LORAWAN_SOCKET_SET_PORT ( s -> sock_base . u . sd , 2 ) ; return 0 ; }
Micro Python bindings; LoRa socket
Micro Python bindings ; LoRa socket
// port number 2 is the default one