├── main ├── CMakeLists.txt ├── component.mk ├── idf_component.yml ├── twai.h ├── Kconfig.projbuild ├── twai.c ├── http_post.c ├── http_server.c └── main.c ├── sdkconfig.defaults ├── partitions.csv ├── csv └── can2http.csv ├── CMakeLists.txt ├── flask ├── templates │ └── index.html └── can.py ├── tornado ├── templates │ └── index.html └── can.py ├── LICENSE └── README.md /main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_SRCS "main.c" "http_post.c" "http_server.c" "twai.c") 2 | set(COMPONENT_ADD_INCLUDEDIRS ".") 3 | 4 | register_component() 5 | -------------------------------------------------------------------------------- /main/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Main Makefile. This is basically the same as a component makefile. 3 | # 4 | # (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) 5 | -------------------------------------------------------------------------------- /sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | # 2 | # Partition Table 3 | # 4 | CONFIG_PARTITION_TABLE_CUSTOM=y 5 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 6 | CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" 7 | 8 | # 9 | # HTTP Server 10 | # 11 | CONFIG_HTTPD_MAX_REQ_HDR_LEN=1024 12 | -------------------------------------------------------------------------------- /main/idf_component.yml: -------------------------------------------------------------------------------- 1 | ## IDF Component Manager Manifest File 2 | dependencies: 3 | espressif/mdns: 4 | version: "^1.0.3" 5 | rules: 6 | - if: "idf_version >=5.0" 7 | espressif/cjson: 8 | version: "^1.7.0" 9 | rules: 10 | - if: "idf_version >=6.0" 11 | -------------------------------------------------------------------------------- /partitions.csv: -------------------------------------------------------------------------------- 1 | # Name, Type, SubType, Offset, Size, Flags 2 | # Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild 3 | nvs, data, nvs, 0x9000, 0x6000, 4 | phy_init, data, phy, 0xf000, 0x1000, 5 | factory, app, factory, 0x10000, 0x120000, 6 | storage, data, spiffs, , 0xD0000, 7 | -------------------------------------------------------------------------------- /csv/can2http.csv: -------------------------------------------------------------------------------- 1 | #The file can2http.csv has three columns. 2 | #In the first column you need to specify the CAN Frame type. 3 | #The CAN frame type is either S(Standard frame) or E(Extended frame). 4 | #In the second column you have to specify the CAN-ID as a __hexdecimal number__. 5 | #In the last column you have to specify the PATH of external web server. 6 | #Each CAN-ID is allowed to appear only once in the whole file. 7 | 8 | S,101,/post 9 | E,101,/post 10 | S,103,/post 11 | E,103,/post 12 | -------------------------------------------------------------------------------- /main/twai.h: -------------------------------------------------------------------------------- 1 | #define STANDARD_FRAME 0 2 | #define EXTENDED_FRAME 1 3 | 4 | #define DATA_FRAME 0 5 | #define REMOTE_FRAME 1 6 | 7 | #define CMD_RECEIVE 100 8 | #define CMD_SEND 200 9 | 10 | typedef struct { 11 | int16_t command; 12 | char topic[64]; 13 | int16_t topic_len; 14 | int32_t canid; 15 | int16_t ext; 16 | int16_t rtr; 17 | int16_t data_len; 18 | char data[8]; 19 | } FRAME_t; 20 | 21 | typedef struct { 22 | uint16_t frame; 23 | uint32_t canid; 24 | char * topic; 25 | int16_t topic_len; 26 | } TOPIC_t; 27 | 28 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's CMakeLists 2 | # in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 6 | project(can2http) 7 | 8 | # Create a SPIFFS image from the contents of the 'font' directory 9 | # that fits the partition named 'storage'. FLASH_IN_PROJECT indicates that 10 | # the generated image should be flashed when the entire project is flashed to 11 | # the target with 'idf.py -p PORT flash 12 | spiffs_create_partition_image(storage csv FLASH_IN_PROJECT) 13 | -------------------------------------------------------------------------------- /flask/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 || Date | 16 |Time | 17 |ID | 18 |Frame | 19 |Value | 20 |
|---|---|---|---|---|
| {{ i.date }} | 25 |{{ i.time }} | 26 |{{ i.id }} | 27 |{{ i.frame }} | 28 |{{ i.value }} | 29 |