Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start_cmux function not working #7

Open
Noushadalik opened this issue Dec 3, 2022 · 0 comments
Open

start_cmux function not working #7

Noushadalik opened this issue Dec 3, 2022 · 0 comments

Comments

@Noushadalik
Copy link

I wrote the following portion of code to start cmux function

void app_main(void)
{
gpio_pad_select_gpio(gsm_reset_pin);
 gpio_set_direction(gsm_reset_pin,GPIO_MODE_OUTPUT);
#if CONFIG_LWIP_PPP_PAP_SUPPORT
    esp_netif_auth_type_t auth_type = NETIF_PPP_AUTHTYPE_PAP;
#elif CONFIG_LWIP_PPP_CHAP_SUPPORT
    esp_netif_auth_type_t auth_type = NETIF_PPP_AUTHTYPE_CHAP;
#elif !defined(CONFIG_EXAMPLE_MODEM_PPP_AUTH_NONE)
#error "Unsupported AUTH Negotiation"
#endif
    ESP_ERROR_CHECK(esp_netif_init());
    ESP_ERROR_CHECK(esp_event_loop_create_default());
    ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, ESP_EVENT_ANY_ID, &on_ip_event, NULL));
    ESP_ERROR_CHECK(esp_event_handler_register(NETIF_PPP_STATUS, ESP_EVENT_ANY_ID, &on_ppp_changed, NULL));

    event_group = xEventGroupCreate();

    /* create dte object */
    esp_modem_dte_config_t config = ESP_MODEM_DTE_DEFAULT_CONFIG();
    /* setup UART specific configuration based on kconfig options */
    /* setup UART specific configuration based on kconfig options */
    config.tx_io_num = CONFIG_EXAMPLE_MODEM_UART_TX_PIN;
    config.rx_io_num = CONFIG_EXAMPLE_MODEM_UART_RX_PIN;
    config.rts_io_num = CONFIG_EXAMPLE_MODEM_UART_RTS_PIN;
    config.cts_io_num = CONFIG_EXAMPLE_MODEM_UART_CTS_PIN;
    config.rx_buffer_size = CONFIG_EXAMPLE_MODEM_UART_RX_BUFFER_SIZE;
    config.tx_buffer_size = CONFIG_EXAMPLE_MODEM_UART_TX_BUFFER_SIZE;
    config.event_queue_size = CONFIG_EXAMPLE_MODEM_UART_EVENT_QUEUE_SIZE;
    config.event_task_stack_size = CONFIG_EXAMPLE_MODEM_UART_EVENT_TASK_STACK_SIZE;
    config.event_task_priority = CONFIG_EXAMPLE_MODEM_UART_EVENT_TASK_PRIORITY;
    config.line_buffer_size = CONFIG_EXAMPLE_MODEM_UART_RX_BUFFER_SIZE * 2;

  
    ESP_LOGI("GSM","setting reset pin high");
    gpio_set_level(gsm_reset_pin, 1);
    vTaskDelay(pdMS_TO_TICKS(100));
    ESP_LOGI("GSM","setting reset pin low");
    gpio_set_level(gsm_reset_pin, 0);
    vTaskDelay(pdMS_TO_TICKS(20000));
    ESP_LOGI("GSM","Waiting for modem to sync..");


   modem_dte_t *dte = esp_modem_dte_init(&config);

    /* Register event handler */
    ESP_ERROR_CHECK(esp_modem_set_event_handler(dte, modem_event_handler, ESP_EVENT_ANY_ID, NULL));

    /*Init netif object*/
    esp_netif_config_t cfg = ESP_NETIF_DEFAULT_PPP();
    esp_netif_t *esp_netif = esp_netif_new(&cfg);
    assert(esp_netif);
    void *modem_netif_adapter = esp_modem_netif_setup(dte);
    esp_modem_netif_set_default_handlers(modem_netif_adapter, esp_netif);
    
   


       esp_modem_start_cmux(dte);
        dce = sim7600_init(dte);
        vTaskDelay(pdMS_TO_TICKS(5000));
         ESP_ERROR_CHECK(dce->set_flow_ctrl(dce, MODEM_FLOW_CONTROL_NONE));
        ESP_ERROR_CHECK(dce->store_profile(dce));
        /* Print Module ID, Operator, IMEI, IMSI */
        ESP_LOGI(TAG, "Module: %s", dce->name);
        ESP_LOGI(TAG, "Operator: %s", dce->oper);
        ESP_LOGI(TAG, "IMEI: %s", dce->imei);
        ESP_LOGI(TAG, "IMSI: %s", dce->imsi);
        /* Get signal quality */
        uint32_t rssi = 0, ber = 0;
        ESP_ERROR_CHECK(dce->get_signal_quality(dce, &rssi, &ber));
        ESP_LOGI(TAG, "rssi: %d, ber: %d", rssi, ber);
         GPS_location();
        //ESP_LOGI("GPS","GPS Got location");
         cord_cal();
        /* Get battery voltage */
        //uint32_t voltage = 0, bcs = 0, bcl = 0;
       // ESP_ERROR_CHECK(dce->get_battery_status(dce, &bcs, &bcl, &voltage));
       // ESP_LOGI(TAG, "Battery voltage: %d mV", voltage);
        /* setup PPPoS network parameters */
//#if !defined(CONFIG_EXAMPLE_MODEM_PPP_AUTH_NONE) && (defined(CONFIG_LWIP_PPP_PAP_SUPPORT) || defined(CONFIG_LWIP_PPP_CHAP_SUPPORT))
///        esp_netif_ppp_set_auth(esp_netif, auth_type, CONFIG_EXAMPLE_MODEM_PPP_AUTH_USERNAME, CONFIG_EXAMPLE_MODEM_PPP_AUTH_PASSWORD);
//#endif
        /* attach the modem to the network interface */
        esp_netif_attach(esp_netif, modem_netif_adapter);
        /* Wait for IP address */
        xEventGroupWaitBits(event_group, CONNECT_BIT, pdTRUE, pdTRUE, portMAX_DELAY);

}

But it is not working:)

debug log

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS C:\Users\rhmna\esp_lte_modem-main> set IDF_PATH=C:\Users\rhmna\esp\esp-idf
PS C:\Users\rhmna\esp_lte_modem-main> C:\Users\rhmna\.espressif\python_env\idf4.4_py3.8_env\Scripts\python.exe C:\Users\rhmna\esp\esp-idf\tools\idf_monitor.py -p COM5 -b 115200 --toolchain-prefix xtensa-esp32-elf- --target esp32 c:\Users\rhmna\esp_lte_modem-main\build\pppos_client.elf
--- WARNING: GDB cannot open serial ports accessed as COMx
--- Using \\.\COM5 instead...
--- idf_monitor on \\.\COM5 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
I (12) boot: ESP-IDF v4.4.1-dirty 2nd stage bootloader
I (13) boot: compile time 11:13:03
I (13) boot: chip revision: 1
I (15) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (22) boot.esp32: SPI Speed      : 40MHz
I (27) boot.esp32: SPI Mode       : DIO
I (31) boot.esp32: SPI Flash Size : 16MB
I (36) boot: Enabling RNG early entropy source...
I (41) boot: Partition Table:
I (45) boot: ## Label            Usage          Type ST Offset   Length
I (52) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (59) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (67) boot:  2 factory          factory app      00 00 00010000 00100000
I (74) boot: End of partition table
I (79) boot_comm: chip revision: 1, min. application chip revision: 0
I (86) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=11584h ( 71044) map
I (120) esp_image: segment 1: paddr=000215ac vaddr=3ffb0000 size=023a4h (  9124) load
I (124) esp_image: segment 2: paddr=00023958 vaddr=40080000 size=0c6c0h ( 50880) load
I (147) esp_image: segment 3: paddr=00030020 vaddr=400d0020 size=3ec88h (257160) map
I (240) esp_image: segment 4: paddr=0006ecb0 vaddr=4008c6c0 size=00338h (   824) load
I (241) esp_image: segment 5: paddr=0006eff0 vaddr=50000000 size=00010h (    16) load
I (252) boot: Loaded app from partition at offset 0x10000
I (252) boot: Disabling RNG early entropy source...
I (269) cpu_start: Pro cpu up.
I (269) cpu_start: Starting app cpu, entry point is 0x400811dc
0x400811dc: call_start_cpu1 at C:/Users/rhmna/esp/esp-idf/components/esp_system/port/cpu_start.c:160

I (0) cpu_start: App cpu up.
I (283) cpu_start: Pro cpu start user code
I (283) cpu_start: cpu freq: 160000000
I (283) cpu_start: Application information:
I (287) cpu_start: Project name:     pppos_client
I (293) cpu_start: App version:      1
I (297) cpu_start: Compile time:     Dec  1 2022 11:35:33
I (303) cpu_start: ELF file SHA256:  f3231774957a423d...
I (309) cpu_start: ESP-IDF:          v4.4.1-dirty
I (315) heap_init: Initializing. RAM available for dynamic allocation:
I (322) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (328) heap_init: At 3FFB4138 len 0002BEC8 (175 KiB): DRAM
I (334) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (341) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (347) heap_init: At 4008C9F8 len 00013608 (77 KiB): IRAM
I (354) spi_flash: detected chip: generic
I (358) spi_flash: flash io: dio
I (363) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (373) GSM: setting reset pin high
I (473) GSM: setting reset pin low
I (20473) GSM: Waiting for modem to sync..
I (20473) uart: queue free spaces: 30
E (20473) **esp-modem: esp_modem_start_cmux(829): DTE has not yet bind with DCE**
I (20533) bg96: CMUX setup
I (21033) bg96: PIN ASK response: +CPIN: READY

I (21133) bg96: PIN ASK response: OK

I (26893) pppos_example: Module: SIMCOM_SIM7600G-H
I (26893) pppos_example: Operator: "Vi India Vodafone IN"
I (26893) pppos_example: IMEI: 862636050449717
I (26893) pppos_example: IMSI: 404466097514230
I (27093) pppos_example: rssi: 17, ber: 99
I (27093) GPS: Locating GPS
I (27193) GPS_AT_COMMAND_RESPONSE: Success line : OK

I (27193) GPS: Waiting 30 seconds for GPS to locate
I (57293) GPS_AT_COMMAND_RESPONSE: line : +CGPSINFO: 1057.271289,N,07619.376233,E,031222,042307.0,85.7,0.0,

I (57293) GPS_AT_COMMAND_RESPONSE: GPS line : +CGPSINFO: 1057.271289,N,07619.376233,E,031222,042307.0,85.7,0.0,

I (57403) GPS_AT_COMMAND_RESPONSE: Success line : OK

I (57503) GPS_AT_COMMAND_RESPONSE: Success line : OK

I (57503) GPS: Calculating co-ordinates
I (57503) Gps: direction >N,E
I (57503) GPS: Latitude---> 1057.271289  Longitude--->07619.376233
I (57513) decimal:  : 10.95452118
I (57513) degree:  : 76.32293701
I (57513) final:  : location------> 10.95452118,76.32293701
I (57523) esp-modem: APN: CMNET
I (57613) esp-modem: PPP MODE
I (57713) DCE_TAG: ATD response: CONNECT 115200

I (57713) pppos_example: Modem PPP Started
I (117713) esp-netif_lwip-ppp: Connection lost
I (117713) pppos_example: Modem Disconnect from PPP Server

AT command is working well to get the location. I can't get IP
Any help will really be appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant