HTTP client library

Hi there,

I’ve inherited a design based on a HL8548 and a STM32L4, the problem is the driver for the HL8548 is extremely ugly and highly coupled with the Sierra Wireless. Does anybody know any C library to implement a HTTP client (I guess it’d need a TCP client as a dependency) for the HL8548?

I guess somebody using a 3g module is likely to implement HTTP so reinventing the wheel every time doesn’t seem very smart!

Thanks!

Hi,
If you use HL8548 as a dial-up modem, you can set up a PPP connection to device and then develop a HTTP client to connect to server, you can using libcurl library.
If you want to send AT command to serial port, you can use termios library, below is the simple code to send AT command, please refer AirPrime_HL6_and_HL8_Series_AT_Commands_Interface_Guide document for AT command.

#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>

int issue_at(int port, char *command, char *result, int biggest)
{
int count=0, len=strlen(command), n=0;

// Flush any buffered characters
read(port, result, biggest);

// Send the AT command over the port
count=write(port, command, strlen(command));
if(count<0) {
result[0]=0x00;
return -1;
}
int main(void)
{
char result[256], ip[64], search=“XDNS: 3”, *dns=NULL, dns1[64], dns2[64];
int i=0, j=0, k=0, at_fd=open("/dev/ttyACM2", O_RDWR|O_NOCTTY|O_SYNC);
struct termios options;
FILE *fout=NULL;

if(at_fd<=0) return -1;

bzero(&options, sizeof(options));
options.c_cflag=B9600|CS8|CLOCAL|CREAD|IGNPAR;
tcflush(at_fd, TCIFLUSH);
tcsetattr(at_fd, TCSANOW, &options);

// Flush any buffered characters
read(at_fd, result, sizeof(result));
usleep(100000);
issue_at(at_fd, “AT\r”, result, sizeof(result));
usleep(100000);
read(at_fd, result, sizeof(result));

usleep(10000);
}
Thanks,

1 Like