From: kyz Date: Fri, 12 Apr 2024 05:47:59 +0000 (+0800) Subject: 平台通信协议修改,上报平台数据增加新的字段 X-Git-Url: http://kyz.pub/gitweb/?a=commitdiff_plain;h=ff86c38a5c23d942544a931fa51df3d85870c115;p=yn%2Fweldingcontroller.git 平台通信协议修改,上报平台数据增加新的字段 --- diff --git a/user/user_report.c b/user/user_report.c index e3d54f6..dca31ee 100644 --- a/user/user_report.c +++ b/user/user_report.c @@ -2,7 +2,7 @@ static char mac_str_buf[20]; //"00:00:00:00:00:00"; static char *g_mac_str; - +#if 0 static const char *fmt = "{\n\ \"cmd\":\"rt\",\n\ \"cid\":%d,\n\ @@ -17,6 +17,29 @@ static const char *fmt = "{\n\ }\n\ }"; +#else +static const char *fmt = "{\n\ + \"cmd\":\"rt\",\n\ + \"cid\":%d,\n\ + \"mac\":\"%s\",\n\ + \"val\":{\n\ + \"c\":\"%0.1f\",\n\ + \"s\":\"%d\",\n\ + \"g\":\"%0.1f\"\n\ + },\n\ + \"weldCurrent\":\"%0.1f\",\n\ + \"gasFlow\":\"%0.1f\",\n\ + \"weldTech\":\"%s\",\n\ + \"solarTermFactor\":\"%d\",\n\ + \"gasPressure\":\"%d\",\n\ + \"totalFlow\":\"%d\",\n\ + \"onlineStatus\":\"%d\",\n\ + \"softVersion\":\"V%d.%d\",\n\ + \"lock\":\"%d\"\n\ + }"; + +#endif + static void mac_str_init( void ) { uint8_t mac[6]; @@ -26,11 +49,11 @@ static void mac_str_init( void ) g_mac_str = mac_str_buf; } +static const char * weld_method_str[3] = {"TIG", "MIG", "MAG" }; char * devinfo_report_str( void ) { static uint32_t cid = 0; - static char tx_buf[200]; - + static char tx_buf[500]; float c,g; uint32_t s; @@ -42,10 +65,19 @@ char * devinfo_report_str( void ) g = g_dev.flowmeter.flow_speed; s = g_dev.welding_start; - //+10A 到 -10A 上报0,与屏上显示一致 - if( c<10.0f && c>-10.0f ) - c = 0.0f; - sprintf( (char*)tx_buf, fmt, cid++, APP_VER_MAJOR, APP_VER_MINOR, g_dev.remote_locked, g_mac_str, c, s, g ); + //+10A 到 -10A 上报0,与屏上显示一致 + if( c<10.0f && c>-10.0f ) + c = 0.0f; + + sprintf( (char*)tx_buf, fmt, cid++, g_mac_str, c, s, g, + c,g, + weld_method_str[g_dev.cfg.welding_method], + g_dev.cfg.save_gas_factor, + (int)g_dev.pressure, + (int)g_dev.flowmeter.flow_total, + 1, + APP_VER_MAJOR, APP_VER_MINOR, + g_dev.remote_locked ); return tx_buf; }