WiFi PLUS Click with TCP/IP Stack - Complete WiFi Solution

General discussion on Libstock website & codes posted on this website.
Author
Message
lexdean
Posts: 32
Joined: 19 Aug 2009 22:59

Re: WiFi PLUS Click with TCP/IP Stack - Complete WiFi Soluti

#46 Post by lexdean » 12 Feb 2014 20:40

Sorry this uart device is not fast enough for normal wireless use
for small data transfer there is better standards
I need stuff like broadcom's chips that can move 50 mb/s
not one mbs

sorry

aCkO
Posts: 1119
Joined: 14 Feb 2011 04:07
Location: Bar, Montenegro

Re: WiFi PLUS Click with TCP/IP Stack - Complete WiFi Soluti

#47 Post by aCkO » 12 Feb 2014 22:05


aCkO
Posts: 1119
Joined: 14 Feb 2011 04:07
Location: Bar, Montenegro

Re: WiFi PLUS Click with TCP/IP Stack - Complete WiFi Soluti

#48 Post by aCkO » 13 Feb 2014 06:52

Amir wrote:I am pretty sure that there is a bug inside this library. I would be happy if someone can convince me that I was wrong.
I'm afraid you're wrong :)

From Help:
Functions reentrancy

Functions reentrancy is allowed if the function has no parameters and local variables, or if the local variables are placed in the Rx space. Remember that the PIC has stack and memory limitations which can varies greatly between MCUs.
Simply put, you can't use the same function in main and interrupt because of the above limitations. However, you can create an exact copy of UART2_Write function and use that instead:

Code: Select all

void UART2_Write_Copy(char ch) {
  while (!TXSTA2.TRMT);
  TXREG2 = ch;
}
Regards

sairfan1
Posts: 79
Joined: 10 Jan 2010 17:02
Location: Regina, SK.
Contact:

Re: WiFi PLUS Click with TCP/IP Stack - Complete WiFi Soluti

#49 Post by sairfan1 » 12 Jun 2014 22:28

hi,

i have installed and run successfully http demo wifi click, want to learn it further but there is no associated help file. please help.
irfulabs

smile1357
Posts: 3
Joined: 11 Jun 2014 05:02

Re: WiFi PLUS Click with TCP/IP Stack - Complete WiFi Soluti

#50 Post by smile1357 » 13 Jun 2014 08:35

Hi! I m new here. I just want to know about wifi PLUS click. What is the output of example file wifi_HTTP_Demo that using PIC18F45K22. Is it can transmit the wifi? Should I connect the internet connection to the easyPICv7?

lexdean
Posts: 32
Joined: 19 Aug 2009 22:59

Re: WiFi PLUS Click with TCP/IP Stack - Complete WiFi Soluti

#51 Post by lexdean » 16 Jun 2014 09:31

I know how you feel but I cannot help you sorry

mikroElektronika if they wish to realise it or not
They have some major growing pains if they wish to survive Just like Delphi/Embarco as a business do

The support is not there, I am looking at snapdragon for my needs and Looking at C.


Regards,
Lex Dean

MaGiK
Posts: 897
Joined: 19 Apr 2013 10:00

Re: WiFi PLUS Click with TCP/IP Stack - Complete WiFi Soluti

#52 Post by MaGiK » 16 Jun 2014 14:47

Hello smile1357 and welcome to the forum :D

The WiFi Plus Click has two examples.

One of these examples connects one WiFi Plus Click (mounted on a mikromedia board) with another WiFi Plus Click (mounted on EasyPIC V7). And together, they form a network of only two nodes and start communicating with each other.

This video shows this example:
http://m.youtube.com/watch?v=oFTELrdpGIM

The other example connects the WiFi Plus Click (mounted on EasyPIC V7) to the Internet through a router and it requires an internet connection. Then you can use a computer to access a webpage that is created by the WiFi Plus Click in order to read to write data to it and the surrounding electronics.

This video shows this example:
http://m.youtube.com/watch?v=TbF4WdAChGo

Best Regards
My hobby is collecting MikroElektronika products.
Gotta catch them all!

Dracog71
Posts: 16
Joined: 16 Jun 2014 18:37

Re: WiFi PLUS Click with TCP/IP Stack - Complete WiFi Soluti

#53 Post by Dracog71 » 16 Jun 2014 18:54

Hi, i'm new here and i've some questions about programming wifi for MINI-M4 for STM32 with STM32F415RG...


I'm using the wifi example for STM32, and i don't undesrtand this part of the program:

"UART2_Init_Advanced(115200, _UART_8_BIT_DATA, _UART_NOPARITY, _UART_TWO_STOPBITS, &_GPIO_MODULE_USART2_PD56);"


i wanna use UART0 instead of UART2, Baud Rate, data bit, parity and stop bits are OK!, and then again i don't understand this:
"&_GPIO_MODULE_USART2_PD56);"

Is there any link u can give me to learn about and modify the "Wifi_Adhoc_server_example" for the MINI-M4 for STM32 with STM32F415RG??

I think this little line makes all the communication for the next commans in example, and if i don't make it work the way i want, i'm not going to see this works, so, help me please!!

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: WiFi PLUS Click with TCP/IP Stack - Complete WiFi Soluti

#54 Post by filip » 17 Jun 2014 09:32

Hi,
i wanna use UART0 instead of UART2, Baud Rate, data bit, parity and stop bits are OK!, and then again i don't understand this:
"&_GPIO_MODULE_USART2_PD56);"
The _GPIO_MODULE_USART2_PD56 presents the pin group that the UART2 is connected to.
If you read the datasheet, you will see on which pins the desired UART module can be connected to.
You may take a look at the UART2_Init_Advanced function explanation in the Help file, where you will find more information.

Regards,
Filip.

lexdean
Posts: 32
Joined: 19 Aug 2009 22:59

Re: WiFi PLUS Click with TCP/IP Stack - Complete WiFi Soluti

#55 Post by lexdean » 17 Jun 2014 11:26

Sorry I'm not familiar enough with Ajax
I'm working in totally different arana now

smile1357
Posts: 3
Joined: 11 Jun 2014 05:02

Re: WiFi PLUS Click with TCP/IP Stack - Complete WiFi Soluti

#56 Post by smile1357 » 25 Jun 2014 05:10

Hello smile1357 and welcome to the forum :D

The WiFi Plus Click has two examples.

One of these examples connects one WiFi Plus Click (mounted on a mikromedia board) with another WiFi Plus Click (mounted on EasyPIC V7). And together, they form a network of only two nodes and start communicating with each other.

This video shows this example:
http://m.youtube.com/watch?v=oFTELrdpGIM

The other example connects the WiFi Plus Click (mounted on EasyPIC V7) to the Internet through a router and it requires an internet connection. Then you can use a computer to access a webpage that is created by the WiFi Plus Click in order to read to write data to it and the surrounding electronics.

This video shows this example:


http://m.youtube.com/watch?v=TbF4WdAChGo

Best Regards

_________________
My hobby is collecting MikroElektronika products.
Gotta catch them all!


__________________________________________________________________________________________________
Thank you for the reply.

I already run the xample, however,the wifi keep on searching for SSID, never connect to any of them. Do I have to set the wireless network in the code? I already tried with no luck at all..:(

Dracog71
Posts: 16
Joined: 16 Jun 2014 18:37

Re: WiFi PLUS Click with TCP/IP Stack - Complete WiFi Soluti

#57 Post by Dracog71 » 17 Jul 2014 01:32

Hi AGAIN!, i just make this run in STM32, with an adhoc open network, but when y wanna make it connect to a WPA2-PSK network, with the parameters the library helps says, it did not work, even if I copy the explame as it is in the library, the compilers marks an error

Code: Select all

 //Net_Wireless_MCW1001_SetSecurity_WPA(_NET_WIRELESS_MCW1001_CP_1, _NET_WIRELESS_MCW1001_WPA_TYPE_2, &key);
and when i write :

Code: Select all

 //Net_Wireless_MCW1001_SetSecurity_WPA(_NET_WIRELESS_MCW1001_CP_1, _NET_WIRELESS_MCW1001_WPA_PSK2, &key);
it "works", but not connect to the AP

Other thing is that, when i wanna send something in TCP this doesn't works:

Code: Select all

 response = Net_Wireless_MCW1001_TCP_SendBytes(socketHandleGlobal, &buffer, 1, &numOfSendBytes);
but

Code: Select all

 char buffer []= "STRING" ;
response = Net_Wireless_MCW1001_TCP_SendString(socketHandleGlobal, buffer , &numOfSendBytes);
, here is the complete solution (Workin in OPEN adhoc, but i wanna make it work in WPA2-PSK network)

Code: Select all


/*
 * Project name:
     WiFi_Demo.vtft
 * Generated by:
     Visual TFT
 * Date of creation
     4/21/2012
 * Time of creation
     11:54:30 AM
 * Test configuration:
     MCU:             STM32F407VG

     Dev.Board:       mikromedia for STM32 M4

     Oscillator:      HSI-PLL, 140.000MHz
     ext. modules:    
                   ick on mikrobus2
     SW:              mikroC PRO for ARM

 */


////////////////////////////////////////////////////////////////////////////////
sbit Net_Wireless_MCW1001_Chip_RST at GPIOA_ODR.B8;

sbit STAT at ODR13_GPIOC_ODR_bit;
sbit DATA at ODR12_GPIOC_ODR_bit;

sbit PB at  IDR1_GPIOA_IDR_bit;
sbit CG at IDR2_GPIOA_IDR_bit;
sbit PP at  IDR3_GPIOA_IDR_bit;
sbit PA at  IDR0_GPIOC_IDR_bit;

sbit BUENOS at ODR6_GPIOB_ODR_bit;
sbit MALOS at ODR5_GPIOA_ODR_bit;
sbit CONTADOR at ODR0_GPIOB_ODR_bit;
sbit PPS at ODR8_GPIOB_ODR_bit;
sbit RUN at  ODR5_GPIOC_ODR_bit;
////////////////////////////////////////////////////////////////////////////////

// Global variables
char socketHandleGlobal;
char strSSID[13] = "DRACOTRY";
//char key[11]="260D5243A5";
unsigned int remotePort = 256;
char commandOldValue;
char channels[11] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
char myMac[6] = {0x22, 0x33, 0x44, 0x55, 0x44, 0x22 };
char gatewayAdd[4] = {169, 254, 24, 200};
char response;
unsigned int seguro = 0;

//void RefreshAndDrawNetStatus();
//void CheckTcpReceive();

////////////////////////////////////////////////////////////////////////////////
// Timer interrupt

unsigned int wifiTmr = 0, netStatusTmr = 0;
void TIMER2_interrupt() iv IVT_INT_TIM2{
  TIM2_SR.UIF = 0;
  wifiTmr++;
  netStatusTmr++;

  if(wifiTmr >= 5) {
    Net_Wireless_MCW1001_Time++ ;  // increment WiFi library counter
    wifiTmr = 0;
  }
}

////////////////////////////////////////////////////////////////////////////////
// Initialization of MCU modules

void MCU_Init() {

  // Initialization of timer..............
  RCC_APB1ENR.TIM2EN = 1;       // Enable clock gating for timer module 2
  TIM2_CR1.CEN = 0;             // Disable timer
  TIM2_PSC = 213;              // Set timer prescaler.
  TIM2_ARR = 65420;
  NVIC_IntEnable(IVT_INT_TIM2); // Enable timer interrupt
  TIM2_DIER.UIE = 1;            // Update interrupt enable
  TIM2_CR1.CEN = 1;             // Enable timer
}

////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
// Initialization of WiFi module

void InitWiFi() {
  Net_Wireless_MCW1001_TimeToWait = 1;
  response = 1;
  while(response != 0)
    response = Net_Wireless_MCW1001_SetMode(_NET_WIRELESS_MCW1001_CP_1, _NET_WIRELESS_MCW1001_MODE_ADHOC); // Set "Connection Profile 1" mode (Ad-Hoc mode)
  // WiFi is ready
  Net_Wireless_MCW1001_TimeToWait = 10;
  Net_Wireless_MCW1001_InitDHCP();                                      // Init DHCP to get network parameter
  Net_Wireless_MCW1001_SetSSID(_NET_WIRELESS_MCW1001_CP_1, strSSID);    // Set SSID of network
  Net_Wireless_MCW1001_SetSecurity_Open(_NET_WIRELESS_MCW1001_CP_1);    // Set open security level
  //Net_Wireless_MCW1001_SetSecurity_WPA(_NET_WIRELESS_MCW1001_CP_1, _NET_WIRELESS_MCW1001_WPA_TYPE_2, &key);
  Net_Wireless_MCW1001_SetChannelList(1, channels);                     // Choose only channerl one for communication
  Net_Wireless_MCW1001_SetMAC(myMac);                                   // Set my MAC address
  Net_Wireless_MCW1001_SetArpTime(1);                                   // Set gratuitous ARP timing
  Net_Wireless_MCW1001_SetRetryCount(5, 255);                           // Retrying the network connection forever.
}

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Constants that define the protocol.
// For example, when server receive TCP packet with "SWITCH_E8_ON" command, server know that switch PJ0 on MMB is pressed,
// and then server turn PJ0 LED on. When button PD0 is pressed server send TCP packet with "LED_PD0_ON" command to MMB, and client turn on
// PD0 LED on display.

const char SWITCH_E8_ON  = 1;
const char SWITCH_E8_OFF = 2;
//
const char SWITCH_E9_ON  = 3;
const char SWITCH_E9_OFF = 4;
//
const char SWITCH_E10_ON  = 5;
const char SWITCH_E10_OFF = 6;
//
const char SWITCH_E11_ON  = 7;
const char SWITCH_E11_OFF = 8;

const char LED_PD0_ON  = 9;
const char LED_PD0_OFF = 10;
//
const char LED_PD1_ON  = 11 ;
const char LED_PD1_OFF = 12;
//
const char LED_PD2_ON  = 13;
const char LED_PD2_OFF = 14;
//
const char LED_PD3_ON  = 15;
const char LED_PD3_OFF = 16;

//////////////////////


////////////////////////////////////////////////////////////////////////////////
// This function check network and TCP status

void RefreshAndDrawNetStatus() {
char i, tmpIP[16], response, markFound, markStatus, numOfScanRes, connStatus;
char connectCnt, connectResponse;
unsigned int time;

  // Try to ping gateway.
  response = Net_Wireless_MCW1001_PingSend(gatewayAdd, &time);

  if(response != 0) {
    Net_Wireless_MCW1001_Disconnect();
    //Delay_ms(500);
  }
  markStatus = 1;
  while(markStatus != 2) {

  // Get network status
  Net_Wireless_MCW1001_GetNetworkStatus();

    if(Net_Wireless_MCW1001_Properties.networkStatus != _NET_WIRELESS_MCW1001_STATUS_CONN_DHCP) {        // If this true, our module is disconnected from network
      // Refresh connection indicators
      commandOldValue = 255;
      markStatus = 0;


      // Try to connect
      while(1) {


        // Search SSID "WiFi Control"
        markFound = 0;
        while(markFound != 1) {
          while(1) {
            response = Net_Wireless_MCW1001_ScanStart(255, &numOfScanRes);             // Scan network
            if(response == 0)                                                          // Check if scanning successful
              break;
            //Delay_ms(500);
          }
          // Check whether is there our ("WiFi Control") network
          for(i = 1; i <= numOfScanRes; i++) {
            response = Net_Wireless_MCW1001_GetScanResult(i);
            //strncpy(strTmp, Net_Wireless_MCW1001_ScanResult.SSID, Net_Wireless_MCW1001_ScanResult.SSIDLength);

            if(Net_Wireless_MCW1001_ScanResult.SSIDLength > 13) {

             //No se que pasa aqui

            }
            else
             // strTmp[Net_Wireless_MCW1001_ScanResult.SSIDLength] = '\0';
              markFound = 1;

            //Delay_ms(700);
          }
        }

        // Connect to AdHoc network
        response = Net_Wireless_MCW1001_Connect(_NET_WIRELESS_MCW1001_CP_1, &connStatus);
        if((response != 0)||(connStatus != 1)) {
        //No se pudo conectar
           BUENOS = 0;
         // Delay_ms(500);
        }
        else {
          //Si se pudo conectar
          BUENOS = 1;
          break;
        }
      }
    }

    // Check whether the TCP connection is established
    if(Net_Wireless_MCW1001_TCP_Status(socketHandleGlobal, 0xff) != 0) {
      if(markStatus == 1) {
         //La red se desconecto
         CONTADOR = 0;
      }

      // Connecting to TCP sever
     // "Connecting To:");
     //, "Server");

      socketHandleGlobal = 0;
      response = Net_Wireless_MCW1001_SocketClose(socketHandleGlobal);
      response = Net_Wireless_MCW1001_SocketCreate(&socketHandleGlobal, _NET_WIRELESS_MCW1001_SOCKET_TYPE_TCP);
      // Socket created successfully?
      if( (response == 0)&&(socketHandleGlobal <= 253) ) {
        // Try to connect to target server (try max 5 times)
        for(connectCnt = 0; connectCnt < 5; connectCnt++) {
          response = Net_Wireless_MCW1001_TCP_Connect(socketHandleGlobal, remotePort, gatewayAdd,  &connectResponse);
          if(connectResponse == 0) {
            markStatus = 2;
            CONTADOR = 1;
            //strcpy(LabelConnStatus_Caption, "Connected");
            break;
          }
          //Delay_ms(300);
        }
      }

    }
    else
      markStatus = 2;
  }
}

//////////////////////////
////Decode Command in received TCP packet

void ComandDecode(signed char command) {

  if(command < 20) {
    switch(command) {
      case LED_PD0_ON : {
        break;
      }
      case LED_PD0_OFF : {

        break;
      }
      case LED_PD1_ON : {
      
        break;
      }
      case LED_PD1_OFF : {

        break;
      }
      case LED_PD2_ON : {

        break;
      }
      case LED_PD2_OFF : {

        break;
      }
      case LED_PD3_ON : {

        break;
      }
      case LED_PD3_OFF : {

        break;
      }
    }
  }

}
////////////////////////////////////////////////////////////////////////////////
// Check TCP buffer to see is there some received data

void CheckTcpReceive() {
  char response, dat[10], i;
  unsigned int numOfReceiveBytes = 0;

  response = Net_Wireless_MCW1001_TCP_ReadBytes(&socketHandleGlobal, 10, dat, &numOfReceiveBytes);
  if( (response == 0) && (numOfReceiveBytes != 0) ) {              // If there is no error, and number of received bytes is greater than zero
    for(i = 0; i < numOfReceiveBytes; i++) {
      ComandDecode(dat[i]);
    }
  }
}

/////////////////////////////////////////////////////////////////////////////////

 void Envio_de_datos()
 {
    char response, txBuffer ,numOfSendBytes;
    char envio[3] = "BN";
    response = Net_Wireless_MCW1001_TCP_SendString(socketHandleGlobal, envio, &numOfSendBytes);
 }
//////////////////////////////////////////////////////////////////////////////////
 void CHECKBUTTON(){
 if ((PB == 1) & (SEGURO == 0))
    {
    seguro = 1;
      Envio_de_datos();
    }
       if ((PB == 0) & (SEGURO == 1))
    {
    seguro = 0;
    }
 }


void main() {
   ////////////////////////////////////////////////////////////////////////////////
    // configure DATA and STAT pins as output
  GPIO_Digital_Input(&GPIOA_BASE, _GPIO_PINMASK_1 | _GPIO_PINMASK_2 | _GPIO_PINMASK_3);     // Set PA1-3 as digital input
  GPIO_Digital_Input(&GPIOC_IDR, _GPIO_PINMASK_0);

  GPIO_Digital_Output(&GPIOA_ODR,_GPIO_PINMASK_5| _GPIO_PINMASK_8);
  GPIO_Digital_Output(&GPIOB_BASE, _GPIO_PINMASK_0 | _GPIO_PINMASK_6 | _GPIO_PINMASK_8 );
  GPIO_Digital_Output(&GPIOC_BASE, _GPIO_PINMASK_5 | _GPIO_PINMASK_12  | _GPIO_PINMASK_13);
////////////////////////////////////////////////////////////////////////////////
//////////////////////////Secuencia de valores repetidos////////////////////////
  GPIO_Digital_Input(&GPIOB_IDR, _GPIO_PINMASK_3);   //Repetida de RST
  //PB1,PC4,PA15,PC2
  GPIO_Digital_Input(&GPIOB_IDR, _GPIO_PINMASK_1);
  GPIO_Digital_Input(&GPIOC_IDR, _GPIO_PINMASK_4);
  GPIO_Digital_Input(&GPIOA_IDR, _GPIO_PINMASK_15);
  GPIO_Digital_Input(&GPIOC_IDR, _GPIO_PINMASK_2);
///////////////////////////////////////////////////////////////////////////////
  STAT = 0;                                  // turn OFF the STAT LED
  DATA = 0;                                  // turn OFF the DATA LED

  BUENOS = 0;                               //  Turn OFF all METRICS indicators
  MALOS = 0;
  CONTADOR = 0;
  PPS =1;
  SEGURO = 0;

////////////////////////////////////////////////////////////////////////////////
  MCU_Init();
  Net_Wireless_MCW1001_HwReset();
  UART3_Init_Advanced(115200, _UART_8_BIT_DATA, _UART_NOPARITY, _UART_TWO_STOPBITS, &_GPIO_MODULE_USART3_PC10_11);
  InitWiFi();
  MALOS = 1;
  RefreshAndDrawNetStatus();

  while(1) {

    CheckTcpReceive();
    CHECKBUTTON();
    //Envio_de_datos();
    
    if(netStatusTmr >= 10) {                                             // Approximately every 2 second check network status
      RefreshAndDrawNetStatus();
      netStatusTmr = 0;
    }

  }
}
ANY HELP??

Dracog71
Posts: 16
Joined: 16 Jun 2014 18:37

Re: WiFi PLUS Click with TCP/IP Stack - Complete WiFi Soluti

#58 Post by Dracog71 » 29 Jul 2014 19:59

Me again!, to make it works with an infrastructure network with WPA-PSK security, all "connection profiles" ned to be in mode "2",

Code: Select all

 //Net_Wireless_MCW1001_SetSecurity_WPA(_NET_WIRELESS_MCW1001_CP_2, _NET_WIRELESS_MCW1001_WPA_PSK2, &key);
search and change avery "CP_1" to "CP_2" and it will work!

lexdean
Posts: 32
Joined: 19 Aug 2009 22:59

Re: WiFi PLUS Click with TCP/IP Stack - Complete WiFi Soluti

#59 Post by lexdean » 29 Jul 2014 23:51

Look I'm interested in the broudcom chips and have no support with this language
So I'm only interested in C at the moment sorry

you can only use languages that that support the hardware

MaGiK
Posts: 897
Joined: 19 Apr 2013 10:00

Re: WiFi PLUS Click with TCP/IP Stack - Complete WiFi Soluti

#60 Post by MaGiK » 05 Aug 2014 12:14

lexdean wrote:Look I'm interested in the broudcom chips and have no support with this language
So I'm only interested in C at the moment sorry
Is there a question or a point in this post? I cannot see either. And to whom is he talking to and apologizing?
This post sounds like a reply, but it's not! Is it? Somebody help me.

Best Regards
My hobby is collecting MikroElektronika products.
Gotta catch them all!

Post Reply

Return to “Libstock Discussion”