esp32/mods/modlora.c
static mp_obj_t lora_init_helper(lora_obj_t *self, const mp_arg_val_t *args) {
    lora_cmd_rsp_data_t cmd_rsp_data;

    cmd_rsp_data.cmd_u.info.init.stack_mode = args[0].u_int;
    lora_validate_mode (cmd_rsp_data.cmd_u.info.init.stack_mode);

    cmd_rsp_data.cmd_u.info.init.frequency = args[1].u_int;
    lora_validate_frequency (cmd_rsp_data.cmd_u.info.init.frequency);

    cmd_rsp_data.cmd_u.info.init.tx_power = args[2].u_int;
    lora_validate_power (cmd_rsp_data.cmd_u.info.init.tx_power);

    cmd_rsp_data.cmd_u.info.init.bandwidth = args[3].u_int;
    lora_validate_bandwidth (cmd_rsp_data.cmd_u.info.init.bandwidth);

    cmd_rsp_data.cmd_u.info.init.sf = args[4].u_int;
    lora_validate_sf(cmd_rsp_data.cmd_u.info.init.sf);

    cmd_rsp_data.cmd_u.info.init.preamble = args[5].u_int;

    cmd_rsp_data.cmd_u.info.init.coding_rate = args[6].u_int;
    lora_validate_coding_rate (cmd_rsp_data.cmd_u.info.init.coding_rate);

    cmd_rsp_data.cmd_u.info.init.power_mode = args[7].u_int;
    lora_validate_power_mode (cmd_rsp_data.cmd_u.info.init.power_mode);

    cmd_rsp_data.cmd_u.info.init.txiq = args[8].u_bool;
    cmd_rsp_data.cmd_u.info.init.rxiq = args[9].u_bool;

    cmd_rsp_data.cmd_u.info.init.adr = args[10].u_bool;
    cmd_rsp_data.cmd_u.info.init.public = args[11].u_bool;
    cmd_rsp_data.cmd_u.info.init.tx_retries = args[11].u_int;

    // send message to the lora task
    cmd_rsp_data.cmd_u.cmd = E_LORA_CMD_INIT;
    xQueueSend(xCmdQueue, (void *)&cmd_rsp_data, (TickType_t)portMAX_DELAY);

    // block forever until we receive a response back
    if (xQueueReceive(xRspQueue, &cmd_rsp_data, (TickType_t)portMAX_DELAY)) {
        if (cmd_rsp_data.rsp_u.rsp != E_LORA_CMD_RSP || cmd_rsp_data.rsp_u.info.rsp.result != E_LORA_CMD_OK) {
            nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed));
        }
    }
    return mp_const_none;
}
/// \class LoRa - Semtech SX1272 radio driver
\class LoRa - Semtech SX1272 radio driver
\ class LoRa - Semtech SX1272 radio driver
static mp_obj_t lora_init_helper(lora_obj_t *self, const mp_arg_val_t *args) {
    lora_cmd_rsp_data_t cmd_rsp_data;
    cmd_rsp_data.cmd_u.info.init.stack_mode = args[0].u_int;
    lora_validate_mode (cmd_rsp_data.cmd_u.info.init.stack_mode);
    cmd_rsp_data.cmd_u.info.init.frequency = args[1].u_int;
    lora_validate_frequency (cmd_rsp_data.cmd_u.info.init.frequency);
    cmd_rsp_data.cmd_u.info.init.tx_power = args[2].u_int;
    lora_validate_power (cmd_rsp_data.cmd_u.info.init.tx_power);
    cmd_rsp_data.cmd_u.info.init.bandwidth = args[3].u_int;
    lora_validate_bandwidth (cmd_rsp_data.cmd_u.info.init.bandwidth);
    cmd_rsp_data.cmd_u.info.init.sf = args[4].u_int;
    lora_validate_sf(cmd_rsp_data.cmd_u.info.init.sf);
    cmd_rsp_data.cmd_u.info.init.preamble = args[5].u_int;
    cmd_rsp_data.cmd_u.info.init.coding_rate = args[6].u_int;
    lora_validate_coding_rate (cmd_rsp_data.cmd_u.info.init.coding_rate);
    cmd_rsp_data.cmd_u.info.init.power_mode = args[7].u_int;
    lora_validate_power_mode (cmd_rsp_data.cmd_u.info.init.power_mode);
    cmd_rsp_data.cmd_u.info.init.txiq = args[8].u_bool;
    cmd_rsp_data.cmd_u.info.init.rxiq = args[9].u_bool;
    cmd_rsp_data.cmd_u.info.init.adr = args[10].u_bool;
    cmd_rsp_data.cmd_u.info.init.public = args[11].u_bool;
    cmd_rsp_data.cmd_u.info.init.tx_retries = args[11].u_int;
    cmd_rsp_data.cmd_u.cmd = E_LORA_CMD_INIT;
    xQueueSend(xCmdQueue, (void *)&cmd_rsp_data, (TickType_t)portMAX_DELAY);
    if (xQueueReceive(xRspQueue, &cmd_rsp_data, (TickType_t)portMAX_DELAY)) {
        if (cmd_rsp_data.rsp_u.rsp != E_LORA_CMD_RSP || cmd_rsp_data.rsp_u.info.rsp.result != E_LORA_CMD_OK) {
            nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed));
        }
    }
    return mp_const_none;
}
static mp_obj_t lora_init_helper ( lora_obj_t * self , const mp_arg_val_t * args ) { lora_cmd_rsp_data_t cmd_rsp_data ; cmd_rsp_data . cmd_u . info . init . stack_mode = args [ 0 ] . u_int ; lora_validate_mode ( cmd_rsp_data . cmd_u . info . init . stack_mode ) ; cmd_rsp_data . cmd_u . info . init . frequency = args [ 1 ] . u_int ; lora_validate_frequency ( cmd_rsp_data . cmd_u . info . init . frequency ) ; cmd_rsp_data . cmd_u . info . init . tx_power = args [ 2 ] . u_int ; lora_validate_power ( cmd_rsp_data . cmd_u . info . init . tx_power ) ; cmd_rsp_data . cmd_u . info . init . bandwidth = args [ 3 ] . u_int ; lora_validate_bandwidth ( cmd_rsp_data . cmd_u . info . init . bandwidth ) ; cmd_rsp_data . cmd_u . info . init . sf = args [ 4 ] . u_int ; lora_validate_sf ( cmd_rsp_data . cmd_u . info . init . sf ) ; cmd_rsp_data . cmd_u . info . init . preamble = args [ 5 ] . u_int ; cmd_rsp_data . cmd_u . info . init . coding_rate = args [ 6 ] . u_int ; lora_validate_coding_rate ( cmd_rsp_data . cmd_u . info . init . coding_rate ) ; cmd_rsp_data . cmd_u . info . init . power_mode = args [ 7 ] . u_int ; lora_validate_power_mode ( cmd_rsp_data . cmd_u . info . init . power_mode ) ; cmd_rsp_data . cmd_u . info . init . txiq = args [ 8 ] . u_bool ; cmd_rsp_data . cmd_u . info . init . rxiq = args [ 9 ] . u_bool ; cmd_rsp_data . cmd_u . info . init . adr = args [ 10 ] . u_bool ; cmd_rsp_data . cmd_u . info . init . public = args [ 11 ] . u_bool ; cmd_rsp_data . cmd_u . info . init . tx_retries = args [ 11 ] . u_int ; cmd_rsp_data . cmd_u . cmd = E_LORA_CMD_INIT ; xQueueSend ( xCmdQueue , ( void * ) & cmd_rsp_data , ( TickType_t ) portMAX_DELAY ) ; if ( xQueueReceive ( xRspQueue , & cmd_rsp_data , ( TickType_t ) portMAX_DELAY ) ) { if ( cmd_rsp_data . rsp_u . rsp != E_LORA_CMD_RSP || cmd_rsp_data . rsp_u . info . rsp . result != E_LORA_CMD_OK ) { nlr_raise ( mp_obj_new_exception_msg ( & mp_type_OSError , mpexception_os_operation_failed ) ) ; } } return mp_const_none ; }
\class LoRa - Semtech SX1272 radio driver
\ class LoRa - Semtech SX1272 radio driver
// send message to the lora task // block forever until we receive a response back