diff --git a/Applications/HTTP/httpd-fs/main.js b/Applications/HTTP/httpd-fs/main.js index b3883b5..cb04bf5 100644 --- a/Applications/HTTP/httpd-fs/main.js +++ b/Applications/HTTP/httpd-fs/main.js @@ -15,6 +15,42 @@ templates['status'] = ` {{build}} + +

EV Charger Status

+ + + + + + + + + + + + + +
Safety Relay + {{#safety_flag}} + ON + {{/safety_flag}} + {{^safety_flag}} + OFF + {{/safety_flag}} +
PWM Signal + {{#pwm_state}} + Charging + {{/pwm_state}} + {{^pwm_state}} + Idle + {{/pwm_state}} +
Battery Level + {{battery}}% +
+
+
+
+

EvalBoard

@@ -42,33 +78,6 @@ templates['status'] = `
-

Network

- - - - - - - - - - - - - - - - - - - - - - - - - -
Hostname{{hostname}}
MAC{{mac}}
IP{{ip}}
Netmask{{netmask}}
Gateway{{gateway}}
DNS{{dns}}
`; templates['config'] = `

Clickboards

diff --git a/Applications/HTTP/inc/ev_protocol.h b/Applications/HTTP/inc/ev_protocol.h new file mode 100644 index 0000000..d86db6f --- /dev/null +++ b/Applications/HTTP/inc/ev_protocol.h @@ -0,0 +1,5 @@ +typedef struct { + uint8_t safety_flag; // 0=OFF, 1=ON + uint8_t pwm_state; // 0=No current, 1=Charging + uint8_t battery_percent; // 0~100% +} VehicleStatus_t; diff --git a/Applications/HTTP/src/http_demo.c b/Applications/HTTP/src/http_demo.c index 6dd8d97..d84c9bc 100644 --- a/Applications/HTTP/src/http_demo.c +++ b/Applications/HTTP/src/http_demo.c @@ -55,82 +55,85 @@ BaseType_t xRequestHandler_Status( char *pcBuffer, size_t uxBufferLength, QueryParam_t *pxParams, BaseType_t xParamCount ) { -BaseType_t xCount = 0; -QueryParam_t *pxParam; -NetworkEndPoint_t *pxEndPoint; -uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress; -int8_t cBuffer[ 16 ]; - - pxParam = pxFindKeyInQueryParams( "reset", pxParams, xParamCount ); - if( pxParam != NULL ) - { - NVIC_SystemReset(); - } - - pxParam = pxFindKeyInQueryParams( "led", pxParams, xParamCount ); - if( pxParam != NULL ) - { - if( strcmp(pxParam->pcValue, "on") == 0 ) - { - Board_LED_Set( LEDS_LED0, TRUE ); - } - else if( strcmp(pxParam->pcValue, "off") == 0 ) - { - Board_LED_Set( LEDS_LED0, FALSE ); - } - else if( strcmp(pxParam->pcValue, "toggle") == 0 ) - { - Board_LED_Toggle( LEDS_LED0 ); - } - } - - xCount = snprintf( pcBuffer, uxBufferLength, - "{" - "\"uptime\":" "%d," - "\"free_heap\":" "%d," - "\"led\":" "%s," - "\"button\":" "%s," - "\"build\":" "\"%s\"," - "\"hostname\":" "\"%s\",", - ( portGET_RUN_TIME_COUNTER_VALUE() / 10000UL ), - xPortGetFreeHeapSize(), - ( Board_LED_Test( LEDS_LED0 ) ? "true" : "false" ), - ( ( Buttons_GetStatus() != 0 ) ? "true" : "false" ), - BUILD_STRING, - pcApplicationHostnameHook() - ); - - pxEndPoint = FreeRTOS_FirstEndPoint( NULL ); - if( pxEndPoint != NULL ) - { - xCount += snprintf( pcBuffer + xCount, uxBufferLength - xCount, - "\"mac\":\"%02x:%02x:%02x:%02x:%02x:%02x\",", - pxEndPoint->xMACAddress.ucBytes[0], - pxEndPoint->xMACAddress.ucBytes[1], - pxEndPoint->xMACAddress.ucBytes[2], - pxEndPoint->xMACAddress.ucBytes[3], - pxEndPoint->xMACAddress.ucBytes[4], - pxEndPoint->xMACAddress.ucBytes[5] - ); - - FreeRTOS_GetEndPointConfiguration( &ulIPAddress, - &ulNetMask, - &ulGatewayAddress, - &ulDNSServerAddress, - pxEndPoint ); - - FreeRTOS_inet_ntoa( ulIPAddress, cBuffer ); - xCount += snprintf( pcBuffer + xCount, uxBufferLength - xCount, "\"ip\":\"%s\",", cBuffer); - FreeRTOS_inet_ntoa( ulNetMask, cBuffer ); - xCount += snprintf( pcBuffer + xCount, uxBufferLength - xCount, "\"netmask\":\"%s\",", cBuffer); - FreeRTOS_inet_ntoa( ulGatewayAddress, cBuffer ); - xCount += snprintf( pcBuffer + xCount, uxBufferLength - xCount, "\"gateway\":\"%s\",", cBuffer); - FreeRTOS_inet_ntoa( ulDNSServerAddress, cBuffer ); - xCount += snprintf( pcBuffer + xCount, uxBufferLength - xCount, "\"dns\":\"%s\"", cBuffer); - } - - xCount += snprintf( pcBuffer + xCount, uxBufferLength - xCount, "}" ); - - - return xCount; + BaseType_t xCount = 0; + QueryParam_t *pxParam; + NetworkEndPoint_t *pxEndPoint; + uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress; + int8_t cBuffer[ 16 ]; + + // 기존 리셋, LED 제어 로직 그대로 유지 + pxParam = pxFindKeyInQueryParams( "reset", pxParams, xParamCount ); + if( pxParam != NULL ) NVIC_SystemReset(); + + pxParam = pxFindKeyInQueryParams( "led", pxParams, xParamCount ); + if( pxParam != NULL ) + { + if( strcmp(pxParam->pcValue, "on") == 0 ) + Board_LED_Set( LEDS_LED0, TRUE ); + else if( strcmp(pxParam->pcValue, "off") == 0 ) + Board_LED_Set( LEDS_LED0, FALSE ); + else if( strcmp(pxParam->pcValue, "toggle") == 0 ) + Board_LED_Toggle( LEDS_LED0 ); + } + + // 📌 기존 JSON 생성부 + xCount = snprintf( pcBuffer, uxBufferLength, + "{" + "\"uptime\":%d," + "\"free_heap\":%d," + "\"led\":%s," + "\"button\":%s," + "\"build\":\"%s\"," + "\"hostname\":\"%s\",", + ( portGET_RUN_TIME_COUNTER_VALUE() / 10000UL ), + xPortGetFreeHeapSize(), + ( Board_LED_Test( LEDS_LED0 ) ? "true" : "false" ), + ( ( Buttons_GetStatus() != 0 ) ? "true" : "false" ), + BUILD_STRING, + pcApplicationHostnameHook() + ); + + // 📍 여기에 추가 — safety, pwm, battery JSON 필드 삽입 + xCount += snprintf( pcBuffer + xCount, uxBufferLength - xCount, + "\"safety_flag\":%d," + "\"pwm_state\":%d," + "\"battery\":%d,", + g_vehicle_status.safety_flag, + g_vehicle_status.pwm_state, + g_vehicle_status.battery_percent + ); + + // MAC/IP 정보 부분 (기존 그대로) + pxEndPoint = FreeRTOS_FirstEndPoint( NULL ); + if( pxEndPoint != NULL ) + { + xCount += snprintf( pcBuffer + xCount, uxBufferLength - xCount, + "\"mac\":\"%02x:%02x:%02x:%02x:%02x:%02x\",", + pxEndPoint->xMACAddress.ucBytes[0], + pxEndPoint->xMACAddress.ucBytes[1], + pxEndPoint->xMACAddress.ucBytes[2], + pxEndPoint->xMACAddress.ucBytes[3], + pxEndPoint->xMACAddress.ucBytes[4], + pxEndPoint->xMACAddress.ucBytes[5] + ); + + FreeRTOS_GetEndPointConfiguration( &ulIPAddress, + &ulNetMask, + &ulGatewayAddress, + &ulDNSServerAddress, + pxEndPoint ); + + FreeRTOS_inet_ntoa( ulIPAddress, cBuffer ); + xCount += snprintf( pcBuffer + xCount, uxBufferLength - xCount, "\"ip\":\"%s\",", cBuffer); + FreeRTOS_inet_ntoa( ulNetMask, cBuffer ); + xCount += snprintf( pcBuffer + xCount, uxBufferLength - xCount, "\"netmask\":\"%s\",", cBuffer); + FreeRTOS_inet_ntoa( ulGatewayAddress, cBuffer ); + xCount += snprintf( pcBuffer + xCount, uxBufferLength - xCount, "\"gateway\":\"%s\",", cBuffer); + FreeRTOS_inet_ntoa( ulDNSServerAddress, cBuffer ); + xCount += snprintf( pcBuffer + xCount, uxBufferLength - xCount, "\"dns\":\"%s\"", cBuffer); + } + + xCount += snprintf( pcBuffer + xCount, uxBufferLength - xCount, "}" ); + + return xCount; }