1233
Dependencies: cJSON_lib mcp2515- mbed-dev-f303 esp8266 yezhong_main_controller_copy_3
DATA_wifi/data_wifi.cpp
- Committer:
- yezhong
- Date:
- 2022-06-24
- Revision:
- 0:e923de71caa5
File content as of revision 0:e923de71caa5:
#include "mbed.h" #include "data_wifi.h" #include "data_pc.h" #include "cJSON.h" #include "esp8266.h" Timer ttt; char RX[33],RXX[33]; unsigned int m=0; void wifi_decode() { double zitai_date; float bbb; ttt.start(); ttt.read(); bbb=ttt.read(); cJSON *root = cJSON_Parse(RXX); if(!root) { printf("Error in cjosn: [%s]\n",cJSON_GetErrorPtr()); } else { cJSON *temp1 = cJSON_GetObjectItem(root,"J"); cJSON *temp = cJSON_GetObjectItem(temp1,"a"); if(temp != NULL) { if(temp->type == cJSON_Number) { zitai_date = temp->valuedouble; //double型 valuedoule } } } cJSON_Delete(root); //pc.printf("%.4f,%.3f\r\n",zitai_date,bbb); pc.printf("zitai %.4f\r\n",zitai_date); } void wifi_clear() { for(int i = 0; i <m+1; i++){ RXX[i] = 0; } m=0; } void serial_wifi_isr(void) { static unsigned int A=0,B=0,z=0,n=0,b=0; while(wifi.readable()) { char c=wifi.getc(); //pc.putc(c); if((c=='{')&&(b<2)) { A = 1; B = 0; z= 0; n=0; for(unsigned int i=0;i<33;i++) { RX[i]=0; } } if((c == '}')&&(n!=1)) { B = 1; RX[z] = '}'; } if(A==1) { if(B!=1) { RX[z] = c; } z++; b++; m=z; if(B == 1) { A = 0; B= 0; b=0; RX[z] = '}'; z= 0; n=1; for(unsigned int i = 0; i<m+1; i++) { RXX[i] = RX[i] ; //pc.printf("%c",RXX[i]); } if((RXX[2]=='J')&&(RXX[8]=='a')) { wifi_decode(); } wifi_clear(); } } } } AnalogIn LaLi_pf(PC_1); AnalogIn LaLi_df(PC_2); AnalogIn LaLi_df1(PC_3); float La_pf_real = 0.0f, La_df_real = 0.0f,La_df1_real = 0.0f; float Ffilter_pf[10 + 2] = {0.0f}; float pf_filter = 0.0f; float F_pf = 0.0f;