2021-01-26 01:24 PM
Hi,
I am trying to get my head around LwIP stack. I am following document "Getting Started with Ethernet on the STM32 Nucleo" by Daniel W Rickey. In Server side includes (SSI) example everything works fine only when I try to access my website by entering IP of my microcontroller ("http://192.168.0.36"). When I try to access it by entering "http://192.168.0.36/index.shtml" (or any other website) page is loaded but SSIs on website are not displayed (SSIHandler is not called when apparently it should be called). I am using NUCLEO-F767ZI development board but I guess it does not matter. LwIP version 2.1.2.
Any advice appreciated.
Rafal
Solved! Go to Solution.
2021-01-27 03:19 AM
Hello
In default file "/" case, tag_check evaluation made by file extension only.
For files from URIs "/file.ext" ,
in static files tag_check evaluation made from FS_FILE_FLAGS_SSI inside the file and if LWIP_HTTPD_SSI_BY_FILE_EXTENSION==1 , tag_check evaluationmade by file extension . (or)
So for dynamic files , suggest LWIP_HTTPD_SSI_BY_FILE_EXTENSION set as 1, to evaluate tag check by file extension .
2021-01-26 03:32 PM
Hello
is SSI handler registered when starting HTTPD?
const char* TAGS[]={"tmp","vbat","vcc","freq","ipaddrp","ipaddrl"};
const unsigned short num_tags=sizeof(TAGS)/sizeof(const char*);
httpd_init();
http_set_ssi_handler(SSI_Handler, TAGS, num_tags);//set callbacks for SSI array
2021-01-26 10:54 PM
Hi,
Thanks for answer. Yes I got it defined :
char const *theSSItags[2] = {"tag1","tag2"};
httpd_init();
http_set_ssi_handler(mySSIHandler, (char const **)theSSItags, 2);
Also I have added #define LWIP_HTTPD_SSI 1 in lwipopts.h. As I said it works when just IP is entered in the browser. I don't understand why SSIs don't not work when I enter full website address.
My SSI handler:
u16_t mySSIHandler(int iIndex, char *pcInsert, int iInsertLen)
{
//debug start
extern char GUI_buffer[200];
snprintf(GUI_buffer, sizeof(GUI_buffer), "mySSIHandler called");
HAL_UART_Transmit(&huart3, (unsigned char*)&GUI_buffer , strlen(GUI_buffer) + 1, 200);
//debug end
// see which tag in the array theSSItags to handle
if (iIndex == 0) //is “tag1�?
{
char myStr1[] = "Hello from Tag #1!"; //string to be displayed on web page
//copy the string to be displayed to pcInsert
strcpy(pcInsert, myStr1);
//return number of characters that need to be inserted in html
return strlen(myStr1);
}
else if (iIndex == 1) //is “tag2�?
{
char myStr2[] = "Hello from Tag #2!"; //string to be displayed on web page
//copy string to be displayed
strcpy(pcInsert, myStr2);
//return number of characters that need to be inserted in html
return strlen(myStr2);
}
return 0;
} //mySSIHandler
2021-01-27 03:19 AM
Hello
In default file "/" case, tag_check evaluation made by file extension only.
For files from URIs "/file.ext" ,
in static files tag_check evaluation made from FS_FILE_FLAGS_SSI inside the file and if LWIP_HTTPD_SSI_BY_FILE_EXTENSION==1 , tag_check evaluationmade by file extension . (or)
So for dynamic files , suggest LWIP_HTTPD_SSI_BY_FILE_EXTENSION set as 1, to evaluate tag check by file extension .
2021-01-27 08:45 AM
It works now!
Thank you!