Compare commits

..

2 Commits

Author SHA1 Message Date
dda8feae86 feat: update device ID and signature in OneNet.c 2025-05-23 11:57:09 +08:00
2d2bfa28f3 fix: remove cJSON on FillBuf 2025-05-09 01:32:23 +08:00
3 changed files with 115 additions and 92 deletions

109
.idea/workspace.xml generated
View File

@ -29,22 +29,9 @@
</configurations>
</component>
<component name="ChangeListManager">
<list default="true" id="56631632-52f0-4e39-b905-89e46eb6e768" name="Changes" comment="dev: 暂时禁用指令下发处理">
<list default="true" id="56631632-52f0-4e39-b905-89e46eb6e768" name="Changes" comment="feat: add DMA support">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.mxproject" beforeDir="false" afterPath="$PROJECT_DIR$/.mxproject" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Core/Inc/main.h" beforeDir="false" afterPath="$PROJECT_DIR$/Core/Inc/main.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Core/Inc/oledfont.h" beforeDir="false" afterPath="$PROJECT_DIR$/Core/Inc/oledfont.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Core/Inc/rc522.h" beforeDir="false" afterPath="$PROJECT_DIR$/Core/Inc/rc522.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Core/Inc/stm32f1xx_hal_conf.h" beforeDir="false" afterPath="$PROJECT_DIR$/Core/Inc/stm32f1xx_hal_conf.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Core/Inc/stm32f1xx_it.h" beforeDir="false" afterPath="$PROJECT_DIR$/Core/Inc/stm32f1xx_it.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Core/Src/OneNet.c" beforeDir="false" afterPath="$PROJECT_DIR$/Core/Src/OneNet.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Core/Src/esp8266.c" beforeDir="false" afterPath="$PROJECT_DIR$/Core/Src/esp8266.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Core/Src/freertos.c" beforeDir="false" afterPath="$PROJECT_DIR$/Core/Src/freertos.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Core/Src/main.c" beforeDir="false" afterPath="$PROJECT_DIR$/Core/Src/main.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Core/Src/rc522.c" beforeDir="false" afterPath="$PROJECT_DIR$/Core/Src/rc522.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Core/Src/spi.c" beforeDir="false" afterPath="$PROJECT_DIR$/Core/Src/spi.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Core/Src/stm32f1xx_it.c" beforeDir="false" afterPath="$PROJECT_DIR$/Core/Src/stm32f1xx_it.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/IntelliChargingPile.ioc" beforeDir="false" afterPath="$PROJECT_DIR$/IntelliChargingPile.ioc" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -891,32 +878,32 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
"CMake Application.IntelliChargingPile.elf.executor": "Run",
"OpenOCD Download & Run.IntelliChargingPile.elf.executor": "Run",
"OpenOCD Download & Run.OCD IntelliChargingPile.executor": "Run",
"RunOnceActivity.RadMigrateCodeStyle": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.cidr.known.project.marker": "true",
"RunOnceActivity.git.unshallow": "true",
"RunOnceActivity.readMode.enableVisualFormatting": "true",
"RunOnceActivity.west.config.association.type.startup.service": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"cf.first.check.clang-format": "false",
"cidr.known.project.marker": "true",
"git-widget-placeholder": "main",
"last_opened_file_path": "/Users/timothy/Workbench/embedded/project/IntelliChargingPile/Core/Src",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"settings.editor.selected.configurable": "preferences.lookFeel",
"vue.rearranger.settings.migration": "true"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;ASKED_SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;CMake Application.IntelliChargingPile.elf.executor&quot;: &quot;Run&quot;,
&quot;OpenOCD Download &amp; Run.IntelliChargingPile.elf.executor&quot;: &quot;Run&quot;,
&quot;OpenOCD Download &amp; Run.OCD IntelliChargingPile.executor&quot;: &quot;Run&quot;,
&quot;RunOnceActivity.RadMigrateCodeStyle&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.cidr.known.project.marker&quot;: &quot;true&quot;,
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
&quot;RunOnceActivity.readMode.enableVisualFormatting&quot;: &quot;true&quot;,
&quot;RunOnceActivity.west.config.association.type.startup.service&quot;: &quot;true&quot;,
&quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;cf.first.check.clang-format&quot;: &quot;false&quot;,
&quot;cidr.known.project.marker&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;main&quot;,
&quot;last_opened_file_path&quot;: &quot;/Users/timothy/Workbench/embedded/project/IntelliChargingPile/Core/Src&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.lookFeel&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}]]></component>
}</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/Core/Src" />
@ -929,12 +916,12 @@
</key>
</component>
<component name="RunManager" selected="OpenOCD Download &amp; Run.OCD IntelliChargingPile">
<configuration default="true" type="CLionExternalRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true">
<configuration name="IntelliChargingPile.elf" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="IntelliChargingPile" TARGET_NAME="IntelliChargingPile.elf" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="IntelliChargingPile" RUN_TARGET_NAME="IntelliChargingPile.elf">
<method v="2">
<option name="CLION.EXTERNAL.BUILD" enabled="true" />
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
<configuration name="IntelliChargingPile.elf" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="IntelliChargingPile" TARGET_NAME="IntelliChargingPile.elf" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="IntelliChargingPile" RUN_TARGET_NAME="IntelliChargingPile.elf">
<configuration default="true" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
@ -977,7 +964,7 @@
<workItem from="1743488783461" duration="3691000" />
<workItem from="1743492489952" duration="8816000" />
<workItem from="1743525779889" duration="15870000" />
<workItem from="1746680992201" duration="37397000" />
<workItem from="1746680992201" duration="39002000" />
</task>
<task id="LOCAL-00001" summary="initial commit: oled, rc522, exti">
<option name="closed" value="true" />
@ -1075,7 +1062,23 @@
<option name="project" value="LOCAL" />
<updated>1746710418606</updated>
</task>
<option name="localTasksCounter" value="13" />
<task id="LOCAL-00013" summary="feat: 完成状态机,完成刷卡、数据上报、命令处理">
<option name="closed" value="true" />
<created>1746724022145</created>
<option name="number" value="00013" />
<option name="presentableId" value="LOCAL-00013" />
<option name="project" value="LOCAL" />
<updated>1746724022145</updated>
</task>
<task id="LOCAL-00014" summary="feat: add DMA support">
<option name="closed" value="true" />
<created>1746724037639</created>
<option name="number" value="00014" />
<option name="presentableId" value="LOCAL-00014" />
<option name="project" value="LOCAL" />
<updated>1746724037639</updated>
</task>
<option name="localTasksCounter" value="15" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -1098,23 +1101,11 @@
<MESSAGE value="feat: before tring to fix cmdHandler" />
<MESSAGE value="chore: update .gitignore" />
<MESSAGE value="dev: 暂时禁用指令下发处理" />
<option name="LAST_COMMIT_MESSAGE" value="dev: 暂时禁用指令下发处理" />
<MESSAGE value="feat: 完成状态机,完成刷卡、数据上报、命令处理" />
<MESSAGE value="feat: add DMA support" />
<option name="LAST_COMMIT_MESSAGE" value="feat: add DMA support" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
<url>file://$PROJECT_DIR$/Core/Src/OneNet.c</url>
<line>66</line>
<option name="timeStamp" value="16" />
</line-breakpoint>
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
<url>file://$PROJECT_DIR$/Core/Src/OneNet.c</url>
<line>163</line>
<option name="timeStamp" value="17" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
<watches-manager>
<configuration name="com.jetbrains.cidr.embedded.openocd.conf.type">
<watch expression="rc522Handle.state" language="C++" />

View File

@ -9,9 +9,10 @@
#include "cJSON.h"
#define PRODUCT_ID "zzS53oqy5l"
#define DEVICE_ID "ESP_67EAF3"
#define SIGNATURE "version=2018-10-31&res=products%2FzzS53oqy5l%2Fdevices%2FESP_67EAF3&et=1766658508&method=md5&sign=r2rPhQdTZ3vpkxJTbgN5NQ%3D%3D"
// #define DEVICE_ID "ICP_8EA3F2"
// #define SIGNATURE "version=2018-10-31&res=products%2FzzS53oqy5l%2Fdevices%2FICP_8EA3F2&et=1779440114&method=md5&sign=2uYsPvhvXhn2PH2QczmMcg%3D%3D"
#define DEVICE_ID "ICP_044D8D"
#define SIGNATURE "version=2018-10-31&res=products%2FzzS53oqy5l%2Fdevices%2FICP_044D8D&et=1779442445&method=md5&sign=RZmI0idVEgglgxmZ%2BUrKUA%3D%3D"
extern unsigned char esp8266_buf[128];
@ -61,44 +62,75 @@ _Bool OneNet_DevLink(void)
unsigned char OneNet_FillBuf(char* buf)
{
cJSON* packet = cJSON_CreateObject();
char text[48];
char packet_id[16];
sprintf(packet_id, "%d", uwTick);
cJSON_AddItemToObject(packet, "id", cJSON_CreateString(packet_id));
strcpy(buf, "{\"id\":\"1743082944\",\"params\":{");
cJSON* params = cJSON_CreateObject();
cJSON* valueObj = cJSON_CreateObject();
memset(text, 0, sizeof(text));
sprintf(text, "\"volt\":{\"value\":%.2f},", IM_Volt * 0.0001);
strcat(buf, text);
cJSON_AddItemToObject(valueObj, "value", cJSON_CreateNumber(IM_Volt * 0.0001));
cJSON_AddItemToObject(params, "volt", valueObj);
memset(text, 0, sizeof(text));
sprintf(text, "\"current\":{\"value\":%.2f},", IM_Curr * 0.0001);
strcat(buf, text);
valueObj = cJSON_CreateObject();
cJSON_AddItemToObject(valueObj, "value", cJSON_CreateNumber(IM_Curr * 0.0001));
cJSON_AddItemToObject(params, "current", valueObj);
memset(text, 0, sizeof(text));
sprintf(text, "\"watt_P\":{\"value\":%.2f},", IM_Power * 0.0001);
strcat(buf, text);
valueObj = cJSON_CreateObject();
cJSON_AddItemToObject(valueObj, "value", cJSON_CreateNumber(IM_Power * 0.0001));
cJSON_AddItemToObject(params, "watt_P", valueObj);
memset(text, 0, sizeof(text));
sprintf(text, "\"energy\":{\"value\":%.3f},", IM_Energy * 0.0001);
strcat(buf, text);
valueObj = cJSON_CreateObject();
cJSON_AddItemToObject(valueObj, "value", cJSON_CreateNumber(IM_Energy * 0.0001));
cJSON_AddItemToObject(params, "energy", valueObj);
memset(text, 0, sizeof(text));
sprintf(text, "\"ic_id\":{\"value\":\"%s\"},", IC_CARD_ID);
strcat(buf, text);
valueObj = cJSON_CreateObject();
cJSON_AddItemToObject(valueObj, "value", cJSON_CreateString(IC_CARD_ID));
cJSON_AddItemToObject(params, "ic_id", valueObj);
memset(text, 0, sizeof(text));
sprintf(text, "\"output\":{\"value\":%s}",
HAL_GPIO_ReadPin(RELAY1_GPIO_Port, RELAY1_Pin) == GPIO_PIN_RESET ? "true" : "false");
strcat(buf, text);
valueObj = cJSON_CreateObject();
cJSON_AddItemToObject(valueObj, "value", cJSON_CreateBool(HAL_GPIO_ReadPin(RELAY1_GPIO_Port, RELAY1_Pin) == GPIO_PIN_RESET));
cJSON_AddItemToObject(params, "output", valueObj);
strcat(buf, "}}");
cJSON_AddItemToObject(packet, "params", params);
const char* json_str = cJSON_Print(packet);
strcpy(buf, json_str);
cJSON_Delete(packet);
// cJSON* packet = cJSON_CreateObject();
//
// char packet_id[16];
// sprintf(packet_id, "%d", uwTick);
// cJSON_AddItemToObject(packet, "id", cJSON_CreateString(packet_id));
//
// cJSON* params = cJSON_CreateObject();
// cJSON* valueObj = cJSON_CreateObject();
//
// cJSON_AddItemToObject(valueObj, "value", cJSON_CreateNumber(IM_Volt * 0.0001));
// cJSON_AddItemToObject(params, "volt", valueObj);
//
// valueObj = cJSON_CreateObject();
// cJSON_AddItemToObject(valueObj, "value", cJSON_CreateNumber(IM_Curr * 0.0001));
// cJSON_AddItemToObject(params, "current", valueObj);
//
// valueObj = cJSON_CreateObject();
// cJSON_AddItemToObject(valueObj, "value", cJSON_CreateNumber(IM_Power * 0.0001));
// cJSON_AddItemToObject(params, "watt_P", valueObj);
//
// valueObj = cJSON_CreateObject();
// cJSON_AddItemToObject(valueObj, "value", cJSON_CreateNumber(IM_Energy * 0.0001));
// cJSON_AddItemToObject(params, "energy", valueObj);
//
// valueObj = cJSON_CreateObject();
// cJSON_AddItemToObject(valueObj, "value", cJSON_CreateString(IC_CARD_ID));
// cJSON_AddItemToObject(params, "ic_id", valueObj);
//
// valueObj = cJSON_CreateObject();
// cJSON_AddItemToObject(valueObj, "value", cJSON_CreateBool(HAL_GPIO_ReadPin(RELAY1_GPIO_Port, RELAY1_Pin) == GPIO_PIN_RESET));
// cJSON_AddItemToObject(params, "output", valueObj);
//
// cJSON_AddItemToObject(packet, "params", params);
//
// const char* json_str = cJSON_Print(packet);
// strcpy(buf, json_str);
//
// cJSON_Delete(packet);
return strlen(buf);
}

View File

@ -324,7 +324,7 @@ void Display_IM1281B(void)
char buffer[16];
snprintf(buffer, sizeof(buffer), "%.2fV ", IM_Volt * 0.0001);
snprintf(buffer, sizeof(buffer), "%.1f ", IM_Volt * 0.0001);
OLED_ShowString(16, 5, buffer, 12);
snprintf(buffer, sizeof(buffer), "%.2fA ", IM_Curr * 0.0001);