Skip to content

Framework ThreadX

Georgi Angelov edited this page Jul 29, 2019 · 86 revisions

Quectel BG96 Framework for PlatformIO

  • ThreadX is default API for user applications inside the modules with Qualcomm chipset
  • Module BG96 (GPRS + CAT/NB + GPS)
  • Quectel Support

Firmwares and Quectel BG96 ThreadX SDK

  • SDK2 used by default ( 2.7.3.3 ) firmwares labeled with BG96...R02...
    • BG96MAR02A07M1G_BETA0310A
    • BG96MAR02A09M1G_01.011.01.011 ( recommended )
  • SDK2831 ( see SDK2 )
  • SDK325 ( not tested ) MMU Enabled [ Memory Management Unit ]
  • SDK424 ( not tested ) MMU Enabled

Documentations, Firmwares and Tools ask Quectel

  • QFlash ( Windows )
  • QEFS Explore ( Windows )
  • Lunux uploader

Create New Project

  • PlatformIO Home - New Project
    • Name: { project-name }
    • Board: bg96 ( search bg96 )
    • Framework: ThreadX
    • Тhe platform will create a main.c

Project INI file

[env:bg6]
platform = quectel
framework = threadx
board = bg96
;board_build.base = ; empty is 0x40000000
;board_build.sdk =  ; empty is SDK2, other SDK2831 SDK325 SDK424
;board_build.heap = ; empty is -D HEAP=1048576
;monitor_port = COM1
;monitor_speed = 115200

The MAIN entry

#include <txm_module.h>
__attribute__((section(".library"))) int TXM_MODULE_THREAD_ENTRY(void) {
    while (1) {
        tx_thread_sleep(1000); // USE ONLY HERE
    }
}

Thread Examples

NOTES

Sometimes user app crash and can not be removed or upload new

Solution 1

Begin project with wait SIM ready ... qapi_Device_Info_Get(QAPI_DEVICE_INFO_SIM_STATE_E ... )

Solution 2

  • Reflash ( _slow _ )
  • Reflash only EFS ( fast )
    • and read the scrypt beginning for instructions

ARDUINO Applications

Note: is in process, there may be bugs

Arduino Quectel BG96

Video https://www.youtube.com/watch?v=OjdAD0WR6vw

Tested with SDK2

    • BG96MAR02A07M1G_BETA0310A
    • BG96MAR02A09M1G_01.011.01.011 ( recommended )
  • other - later

Create New Project

  • PlatformIO Home - New Project
    • Name: { project-name }
    • Board: bg96 ( search bg96 )
    • Framework: Arduino

Project INI file

[env:bg6]
platform = quectel
framework = arduino
board = bg96
;board_build.base = ; empty is 0x40000000
;board_build.sdk =  ; empty is SDK2 
;board_build.heap = ; empty is -D HEAP=1048576
;monitor_port = COM1
;monitor_speed = 115200

Arduino Examples

  • ( will more ) LINK

ThreadX UNIX-LIKE (in process)

void http_get(const char *str_ip, const char *s_request)
{
    int sock = socket(AF_INET, SOCK_STREAM, 0);
    printf("[SOC] Socket = %d\n", sock);
    struct sockaddr_in address;
    address.sin_addr.s_addr = inet_addr(str_ip);
    address.sin_family = AF_INET;
    address.sin_port = htons(80);
    int rc = connect(sock, (struct sockaddr *)&address, sizeof(address));
    printf("[SOC] Connect = %d\n", rc);
    rc = write(sock, s_request, strlen(s_request));
    printf("[SOC] Write = %d\n", rc);
    rc = read(sock, http_buffer, sizeof(http_buffer));
    printf("[SOC] Read = %d\n", rc);
    printf("%.*s", sizeof(http_buffer), http_buffer);
    rc = close(sock);
    printf("[SOC] Close = %d\n", rc);
}

void TEST_SOCKET(void)
{
    printf("\n -= TEST SOCKET =-\n");
    int dss = open("/dss/auto 1000", 0);
    http_get(HOST_IP, HTTP_REQUEST);
    close(dss);
    printf("\n");
}
Clone this wiki locally