/********************************************************************* * * GUI_VNC_X_StartServer * * Function description * To start the server, the following steps are executed * - Make sure the TCP-IP stack is up and running * - Init the server context and attach it to the layer * - Start the thread (task) which runs the VNC server * Notes: * (1) The first part of the code initializes the TCP/IP stack. In a typical * application, this is not required, since the stack should have already been * initialized some other place. * This could be done in a different module. (TCPIP_AssertInit() ?) */ int GUI_VNC_X_StartServer(int LayerIndex, int ServerIndex) { /* Make sure the TCP/IP stack is initialized. (1) */ if (xn_rtip_init() != 0) { OS_SendString("GUI_VNC_X_StartServer: Init failed\n"); return 1; /* Error */ } { int interface; xn_bind_cs(0); /* append interface to device table */ interface = xn_interface_open_config(CS89X0_DEVICE, 0, (IOADDRESS)0x20000300,5,0); /* open interface */ if (interface < 0) { OS_SendString("GUI_VNC_X_StartServer: Can not open interface\n"); return 1; /* Error */ } xn_set_ip(interface, (PFBYTE)&_IPLocal[0], (PFBYTE)&_IPMask[0]); /* set IP address of interface */ HW_EnableEthernetIRQ(); /* Enable ethernet IRQ. Make sure it is done after xn_interface_open_config() */ } /* Init VNC context and attach to layer (so context is updated if the display-layer-contents change */ GUI_VNC_AttachToLayer(&_Context, LayerIndex); _Context.ServerIndex = ServerIndex; /* Create task for VNC Server */ OS_CREATETASK(&_VNCServer_TCB, "VNC Server", _ServerTask, 50, _StackVNCServer); return 0; /* O.k., server has been started */ }
/********************************************************************* * * GUI_VNC_X_StartServer * * Function description * To start the server, the following steps are executed * - Make sure the TCP-IP stack is up and running * - Init the server context and attach it to the layer * - Start the thread (task) which runs the VNC server * Notes: * (1) The first part of the code initializes the TCP/IP stack. In a typical * application, this is not required, since the stack should have already been * initialized some other place. * This could be done in a different module. (TCPIP_AssertInit() ?) */ int GUI_VNC_X_StartServer(int LayerIndex, int ServerIndex) { // // Init VNC context and attach to layer (so context is updated if the display-layer-contents change // GUI_VNC_AttachToLayer(&_Context, LayerIndex); _Context.ServerIndex = ServerIndex; // // Create task for VNC Server // OS_CREATETASK(&_VNCServer_TCB, "VNC Server", _ServerTask, 230, _StackVNCServer); // // O.k., server has been started // return 0; }
/********************************************************************* * * GUI_VNC_X_StartServer * * Function description * To start the server, the following steps are executed * - Make sure the TCP-IP stack is up and running * - Init the server context and attach it to the layer * - Start the thread (task) which runs the VNC server * Notes: * (1) The first part of the code initializes the TCP/IP stack. In a typical * application, this is not required, since the stack should have already been * initialized some other place. * This could be done in a different module. (TCPIP_AssertInit() ?) */ int GUI_VNC_X_StartServer(int LayerIndex, int ServerIndex) { // // Init VNC context and attach to layer (so context is updated if the display-layer-contents change // GUI_VNC_AttachToLayer(&_Context, LayerIndex); _Context.ServerIndex = ServerIndex; // // Create task for VNC Server // xTaskCreate(_ServerTask, (signed char const*)"VNC_Server", _VNCServer_Stack, NULL, _VNCServer_PRIO, &_VNCServer_TCB); // // O.k., server has been started // return 0; }
/** * @brief starts VNC server thread * @param LayerIndex: LCD layer index * @param ServerIndex: Server index * @retval server started or not */ int GUI_VNC_X_StartServer(int LayerIndex, int ServerIndex) { /* Init VNC context and attach to layer (so context is updated if the display-layer-contents change */ GUI_VNC_AttachToLayer(&_Context, LayerIndex); _Context.ServerIndex = ServerIndex; _Context.LayerIndex = LayerIndex; /* Create task for VNC Server */ osThreadDef(VNC_Server, _ServerThread, _VNCServer_PRIO, 0, _VNCServer_Stack); _VNCServer_TCB = osThreadCreate (osThread(VNC_Server), NULL); if (_VNCServer_TCB == 0) { /* K.O., server initialization failed */ return 0; } else { /* O.k., server has been started */ return 1; } }
/** * @brief VNC Thread * @param argument: network interface * @retval None */ void VNC_Thread(void const * argument) { for (;;) { switch (VNC_State) { case VNC_LINK_UP: { gnetif.ip_addr.addr = 0; gnetif.netmask.addr = 0; gnetif.gw.addr = 0; dhcp_start(&gnetif); VNC_State = VNC_WAIT_FOR_ADDRESS; VNC_SERVER_LogMessage ("Waiting for DHCP server...\n"); VNC_SERVER_StatusChanged(VNC_WAIT_FOR_ADDRESS); } break; case VNC_WAIT_FOR_ADDRESS: { if (gnetif.ip_addr.addr!=0) { dhcp_stop(&gnetif); VNC_State = VNC_START; VNC_SERVER_StatusChanged(VNC_START); } else { /* DHCP timeout */ if (gnetif.dhcp->tries > MAX_DHCP_TRIES) { VNC_State = VNC_ERROR; dhcp_stop(&gnetif); VNC_SERVER_LogMessage ("No reply from DHCP Server!\n"); } } } break; case VNC_START: sprintf((char*)iptxt, "IP address : %d.%d.%d.%d\n", (uint8_t)(gnetif.ip_addr.addr), (uint8_t)((gnetif.ip_addr.addr) >> 8), (uint8_t)((gnetif.ip_addr.addr) >> 16), (uint8_t)((gnetif.ip_addr.addr) >> 24)); VNC_SERVER_LogMessage ((char *)iptxt); /* Init VNC context and attach to layer (so context is updated if the display-layer-contents change */ GUI_VNC_AttachToLayer(&_Context, 0); _Context.ServerIndex = 0; GUI_VNC_SetProgName ("STM32 VNC Server"); if(VNC_LockState) { GUI_VNC_SetPassword((U8 *)"STM32"); } else { GUI_VNC_SetAuthentication(NULL); } VNC_State = VNC_PROCESS; break; case VNC_PROCESS: VNC_Process(); break; case VNC_IDLE: break; default: break; } osDelay(250); } }
/**This method must be called only once when booting the system. * The display has to be initialized and running before doing so. * * \param layerindex Layerindex passed to GUI_VNC_AttachToLayer. * \param serverindex Serverindex copied to _Context.ServerIndex. */ void MPCVNCServer::init(int layerindex, int serverindex) { GUI_VNC_AttachToLayer(&_Context, layerindex); _Context.ServerIndex = serverindex; }