1
\$\begingroup\$

I have started working on HLK-m30 WiFi module. I am developing the simple client on the module using simple AT commands. I have Opened socket TCP client and then Write data using the command.

GET / HTTP/1.1
Host: www.google.com

when I read socket using AT command it shows me 0:ok. whereas 0 is Socket number and ok is response of command but not receiving any data. Also I am not able to make it work on transparent transmission mode. when I am reading Socket query, Using at+SL command. I got this:

at+SL=?
0:2,3
1:0,0
2:0,0
3:0,0

If anyone here as worked on this module please guide me.

EDIT1:

I have written a code on ATmega16 which open socket, write to it and receive or read socket. I am sending http get request to a server but not able to receive the response back. What can be the problem? here is my code:

/*
 * ATmega16_HLK_m30.c
 *
 * Created: 03-03-2015 16:12:22
 *  Author: B2
 */ 


#ifndef F_CPU
#define F_CPU 16000000UL // or whatever may be your frequency
#endif

#include <avr/io.h>
#include <util/delay.h>
#include <string.h>
#include <avr/eeprom.h>
#include "usart.h"
#include "dbg_putchar.h"

char buffer[255];
const char AT[]="at";                                                           
const char AT_WC[] = "at+WC=";                                                  //Calculation PMK
const char AT_DHCP[] = "at+dhcp=";                                              //Set DHCP or static IP
const char AT_UTYPE[] = "at+UType=";                                            //Set TCP or UDP
const char AT_UIP[] = "at+UIp=";                                                //Set remote IP address
const char AT_URPORT[] = "at+URPort=";                                          //Set remote port
const char AT_ULPORT[] = "at+ULPort=";                                          //Set local port
const char AT_REBOOT[] = "at+Rb=";                                              //Reboot module
const char AT_VERSION[] = "at+ver=";                                            //Get version
const char AT_DEFAULT[] = "at+Df=";                                             //Back to default settings
const char AT_SO[] = "at+SO=";                                                  //Socket open
const char AT_SC[] = "at+SC=";                                                  //Socket close
const char AT_SL[] = "at+SL=";                                                  //Socket check
const char AT_SW[] = "at+SW=";                                                  //Socket write
const char AT_SR[] = "at+SR=";                                                  //Socket read
const char AT_DR[] = "at+DR=";                                                  //Domain name resolution
const char AT_GPW[] = "at+GW=";                                                 //GPIO write
const char AT_GPR[] = "at+GR=";                                                 //GPIO read
const char AT_TS[] = "at+TS=";                                                  //Transparent transmission change
const char AT_MAC[] = "at+mac=";
char HttpRequest[] = "GET / HTTP/1.1\r\nHost: www.google.com\r\n\r\n";
uint8_t hlkM30SendCmd(char *,char *);   //Send Command
uint8_t hlkM30AT();                     //send at and check connection
uint8_t hlkM30_Dhcp();                  //Configure module with dynamic IP
uint8_t hlkM30TCPClient();              //Set TCP Client
uint8_t hlkM30LocalPort();              //Set local Port
uint8_t hlkM30RemotePort();             //Set Remote Port
uint8_t hlkM30PMK();                    //Calculate PMK
uint8_t hlkM30Reboot();                 //Reboot
uint8_t hlkM30OpenSocket();             //Open Socket
uint8_t hlkM30ListSocket();             //List Socket
uint8_t hlkM30WriteSocket();            //Write Socket
uint8_t hlkM30ReadSocket();             //Read  Socket
uint8_t hlkM30CloseSocket();            //Close Socket

int main(void)
{

    USARTInit(9600);
    dbg_tx_init();
    dbg_puts("HLK-M30 Test\r\n");
    //hlkM30Init();
    hlkM30AT();
    hlkM30_Dhcp();
    hlkM30TCPClient();
    hlkM30LocalPort();
    hlkM30RemotePort();
    //hlkM30CloseSocket();
    //hlkM30OpenSocket();
    hlkM30ListSocket();
    hlkM30WriteSocket();
    hlkM30ReadSocket();
    //hlkM30PMK();*/
}

uint8_t hlkM30SendCmd(char *cmd,char *val)
{
    UWriteString(cmd);
    UWriteString(val);
    UWriteData(0x0D);
}

uint8_t hlkM30AT()
{
        uint8_t len=0;
        uint16_t i=0;
        len=strlen(AT);
        UFlushBuffer();
        hlkM30SendCmd(AT,"\r");
        //UWriteString(AT);
        //Wait for echo
        _delay_ms(300);
        while(i<10*len)
        {
            if(UDataAvailable()<len)
            {
                i++;
                //dbg_putchar('.');
                _delay_ms(10);

                continue;
            }
            else
            {
                //We got an echo
                //Now check it
                UReadBuffer(buffer,len);    //Read serial Dat
                //UWriteString(buffer);
                dbg_puts(buffer);
            }
        }
}

uint8_t hlkM30_Dhcp()
{
    uint8_t len=0;
    uint16_t i=0;
    len=strlen(AT_DHCP);
    UFlushBuffer();
    hlkM30SendCmd(AT_DHCP,"1\r");
    //Wait for echo
    _delay_ms(300);
    while(i<10*len)
    {
        if(UDataAvailable()<len)
        {
            i++;
            //dbg_putchar('.');
            _delay_ms(10);

            continue;
        }
        else
        {
            //We got an echo
            //Now check it
            UReadBuffer(buffer,len);    //Read serial Dat
            //UWriteString(buffer);
            dbg_puts(buffer);
        }
    }
}

uint8_t hlkM30TCPClient()
{
    uint8_t len=0;
    uint16_t i=0;
    len=strlen(AT_UTYPE);
    UFlushBuffer();
    hlkM30SendCmd(AT_UTYPE,"2\r");
    //Wait for echo
    _delay_ms(300);
    while(i<10*len)
    {
        if(UDataAvailable()<len)
        {
            i++;
            //dbg_putchar('.');
            _delay_ms(10);

            continue;
        }
        else
        {
            //We got an echo
            //Now check it
            UReadBuffer(buffer,10); //Read serial Dat
            //UWriteString(buffer);
            dbg_puts(buffer);
        }
    }
}

uint8_t hlkM30LocalPort()
{
    uint8_t len=0;
    uint16_t i=0;
    len=strlen(AT_ULPORT);
    UFlushBuffer();
    hlkM30SendCmd(AT_ULPORT,"80\r");
    //Wait for echo
    _delay_ms(300);
    while(i<10*len)
    {
        if(UDataAvailable()<len)
        {
            i++;
            //dbg_putchar('.');
            _delay_ms(10);

            continue;
        }
        else
        {
            //We got an echo
            //Now check it
            UReadBuffer(buffer,17); //Read serial Dat
            //UWriteString(buffer);
            dbg_puts(buffer);
        }
    }
}

uint8_t hlkM30RemotePort()
{
    uint8_t len=0;
    uint16_t i=0;
    len=strlen(AT_URPORT);
    UFlushBuffer();
    hlkM30SendCmd(AT_URPORT,"80\r");
    //Wait for echo
    _delay_ms(300);
    while(i<10*len)
    {
        if(UDataAvailable()<len)
        {
            i++;
            //dbg_putchar('.');
            _delay_ms(10);

            continue;
        }
        else
        {
            //We got an echo
            //Now check it
            UReadBuffer(buffer,19); //Read serial Dat
            //UWriteString(buffer);
            dbg_puts(buffer);
        }
    }
}

uint8_t hlkM30PMK()
{
    uint8_t len=0;
    uint16_t i=0;
    len=strlen(AT_WC);
    UFlushBuffer();
    hlkM30SendCmd(AT_WC,"1\r");
    //Wait for echo
    _delay_ms(300);
    while(i<10*len)
    {
        if(UDataAvailable()<len)
        {
            i++;
            //dbg_putchar('.');
            _delay_ms(10);

            continue;
        }
        else
        {
            //We got an echo
            //Now check it
            UReadBuffer(buffer,7);  //Read serial Dat
            //UWriteString(buffer);
            dbg_puts(buffer);
        }
    }
}

uint8_t hlkM30OpenSocket()
{
    uint8_t len=0;
    uint16_t i=0;
    len=strlen(AT_SO);
    UFlushBuffer();
    hlkM30SendCmd(AT_SO,"2,www.stealmylogin.com,80,80\r");
    //Wait for echo
    _delay_ms(300);
    while(i<10*len)
    {
        if(UDataAvailable()<len)
        {
            i++;
            //dbg_putchar('.');
            _delay_ms(10);

            continue;
        }
        else
        {
            //We got an echo
            //Now check it
            UReadBuffer(buffer,25); //Read serial Dat
            //UWriteString(buffer);
            dbg_puts(buffer);

        }
    }
}

uint8_t hlkM30ListSocket()
{
        uint8_t len=0;
        uint16_t i=0;
        len=strlen(AT_SL);
        UFlushBuffer();
        hlkM30SendCmd(AT_SL,"?\r");
        //Wait for echo
        _delay_ms(300);
        while(i<10*len)
        {
            if(UDataAvailable()<len)
            {
                i++;
                //dbg_putchar('.');
                _delay_ms(10);

                continue;
            }
            else
            {
                //We got an echo
                //Now check it
                UReadBuffer(buffer,20); //Read serial Dat
                //UWriteString(buffer);
                dbg_puts(buffer);
            }
        }
}

uint8_t hlkM30CloseSocket()     //Close Socket
{
    uint8_t len=0;
    uint16_t i=0;
    len=strlen(AT_SC);
    UFlushBuffer();
    hlkM30SendCmd(AT_SC,"0\r");
    //Wait for echo
    _delay_ms(300);
    while(i<10*len)
    {
        if(UDataAvailable()<len)
        {
            i++;
            //dbg_putchar('.');
            _delay_ms(10);

            continue;
        }
        else
        {
            //We got an echo
            //Now check it
            UReadBuffer(buffer,7);  //Read serial Dat
            //UWriteString(buffer);
            dbg_puts(buffer);
        }
    }
}

uint8_t hlkM30WriteSocket()
{
    uint8_t len=0;
    uint16_t i=0;
    len=strlen(AT_SW);
    //char str[];
    UFlushBuffer();
    hlkM30SendCmd(AT_SW,"0,,\"GET / HTTP/1.1\r\nHost: www.stealmylogin.com\r\n\r\n\"\r");
    //hlkM30SendCmd(AT_SW,"0,,\"GET / HTTP/1.1\n\r\"\r");
    //Wait for echo
    _delay_ms(300);
    while(i<1000)
    {
        if(UDataAvailable()<len)
        {
            i++;
            //dbg_putchar('.');
            _delay_ms(10);

            continue;
        }
        else
        {
            //We got an echo
            //Now check it
            UReadBuffer(buffer,50); //Read serial Data
            dbg_puts(buffer);
        }
    }
}

uint8_t hlkM30ReadSocket()              //Read  Socket
{
    uint8_t len=0;
    uint16_t i=0;
    len=strlen(AT_SR);
    //char str[];
    UFlushBuffer();
    hlkM30SendCmd(AT_SR,"0,50\r");
    //hlkM30SendCmd(AT_SW,"0,,\"GET / HTTP/1.1\n\r\"\r");
    //Wait for echo
    _delay_ms(300);
    while(i<10*len)
    {
        if(UDataAvailable()<len)
        {
            i++;
            //dbg_putchar('.');
            _delay_ms(10);

            continue;
        }
        else
        {
            //We got an echo
            //Now check it
            UReadBuffer(buffer,50); //Read serial Dat
            //UWriteString(buffer);
            dbg_puts(buffer);
        }
    }
}

here is the Log which I received:

HLK-M30 Test
at


at+dhcp=1
ok

at+UType=2
ok


at+ULPort=80
at+URPort=80
ok

at+SL=?
0:2,3
1:0,0
2:0,0
3:0,0


at+SW=0,,"GET / HTTP/1.1
ok
almylogin.com







ok
at+SR=0,50
0:ok

I dont understand what to do the next step? How can I send receive from server?

\$\endgroup\$
  • \$\begingroup\$ need motivation guys. \$\endgroup\$ – isoln Feb 27 '15 at 14:24
  • \$\begingroup\$ Hi there?Need to develope a TCP client on HLK-m30 with ATmega16 micro controller. \$\endgroup\$ – isoln Mar 5 '15 at 11:00
0
\$\begingroup\$

Problem Has been solved. the configuration was correct. After reset the module, it gets connect to server and start send/receive data.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.