Merge branch 'main' into merge_to_jackimonster
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
This commit is contained in:
commit
1d3f4640c2
7 changed files with 41 additions and 17 deletions
8
.gitmodules
vendored
8
.gitmodules
vendored
|
@ -1,6 +1,6 @@
|
|||
[submodule "interface_lib/Fusion"]
|
||||
path = interface_lib/Fusion
|
||||
[submodule "interface_lib/modules/Fusion"]
|
||||
path = interface_lib/modules/Fusion
|
||||
url = https://github.com/xioTechnologies/Fusion.git
|
||||
[submodule "interface_lib/hidapi"]
|
||||
path = interface_lib/hidapi
|
||||
[submodule "interface_lib/modules/hidapi"]
|
||||
path = interface_lib/modules/hidapi
|
||||
url = https://github.com/libusb/hidapi.git
|
||||
|
|
|
@ -3,12 +3,10 @@ project(nrealAirLibrary C)
|
|||
|
||||
set(CMAKE_C_STANDARD 17)
|
||||
|
||||
add_subdirectory(hidapi)
|
||||
find_package(json-c REQUIRED CONFIG)
|
||||
|
||||
add_subdirectory(Fusion/Fusion)
|
||||
set(FUSION_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/interface_lib/Fusion)
|
||||
set(FUSION_LIBRARY Fusion)
|
||||
add_subdirectory(modules/hidapi)
|
||||
add_subdirectory(modules/Fusion/Fusion)
|
||||
|
||||
add_library(
|
||||
nrealAirLibrary
|
||||
|
@ -24,11 +22,13 @@ target_include_directories(nrealAirLibrary
|
|||
)
|
||||
|
||||
target_include_directories(nrealAirLibrary
|
||||
BEFORE PRIVATE ${FUSION_INCLUDE_DIR}
|
||||
SYSTEM BEFORE PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/modules/hidapi
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/modules/Fusion
|
||||
)
|
||||
|
||||
target_link_libraries(nrealAirLibrary
|
||||
PRIVATE hidapi::hidapi json-c::json-c ${FUSION_LIBRARY}
|
||||
PRIVATE hidapi::hidapi json-c::json-c Fusion m
|
||||
)
|
||||
|
||||
set(NREAL_AIR_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include PARENT_SCOPE)
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 09ab35ffa9dce60a993f4e55cdeaf0952645f9b7
|
1
interface_lib/modules/hidapi
Submodule
1
interface_lib/modules/hidapi
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit c19ae126d8856b55af34d64ee11641920475961c
|
|
@ -32,7 +32,7 @@
|
|||
#include <Fusion/Fusion.h>
|
||||
#include <json-c/json.h>
|
||||
|
||||
#include <../hidapi/hidapi/hidapi.h>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#include "crc32.h"
|
||||
|
||||
|
@ -235,7 +235,7 @@ device3_type* device3_open(device3_event_callback callback) {
|
|||
|
||||
uint32_t calibration_len = 0;
|
||||
if (recv_payload_msg(device, DEVICE3_MSG_GET_CAL_DATA_LENGTH, 4, (uint8_t*) &calibration_len)) {
|
||||
char* calibration_data = malloc(calibration_len);
|
||||
char* calibration_data = malloc(calibration_len + 1);
|
||||
|
||||
uint32_t position = 0;
|
||||
while (position < calibration_len) {
|
||||
|
@ -253,6 +253,8 @@ device3_type* device3_open(device3_event_callback callback) {
|
|||
|
||||
position += next;
|
||||
}
|
||||
|
||||
calibration_data[calibration_len] = '\0';
|
||||
|
||||
struct json_tokener* tokener = json_tokener_new();
|
||||
struct json_object* root = json_tokener_parse_ex(tokener, calibration_data, calibration_len);
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <../hidapi/hidapi/hidapi.h>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#include "crc32.h"
|
||||
|
||||
|
@ -111,16 +111,19 @@ static bool recv_payload_msg(device4_type* device, uint16_t msgid, uint8_t len,
|
|||
}
|
||||
|
||||
if (packet.head != PACKET_HEAD) {
|
||||
perror("ERROR: invalid payload received\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (packet.msgid != msgid) {
|
||||
perror("ERROR: unexpected payload received\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
const uint8_t status = packet.data[0];
|
||||
|
||||
const uint8_t status = packet.data[0];
|
||||
|
||||
if (status != 0) {
|
||||
perror("ERROR: payload status failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -153,6 +156,7 @@ static bool do_payload_action(device4_type* device, uint16_t msgid, uint8_t len,
|
|||
attempts--;
|
||||
}
|
||||
|
||||
perror("ERROR: payload status failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -483,6 +487,22 @@ bool device4_update_mcu_firmware(device4_type* device, const char* path) {
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!send_payload_action(device, DEVICE4_MSG_R_ACTIVATION_TIME, 0, NULL)) {
|
||||
perror("Requesting activation time failed!\n");
|
||||
return device;
|
||||
}
|
||||
|
||||
uint8_t activated;
|
||||
if (!recv_payload_msg(device, DEVICE4_MSG_R_ACTIVATION_TIME, 1, &activated)) {
|
||||
perror("Receiving activation time failed!\n");
|
||||
return device;
|
||||
}
|
||||
|
||||
if (!activated) {
|
||||
perror("Device is not activated!\n");
|
||||
goto jump_to_app;
|
||||
}
|
||||
|
||||
size_t offset = 0;
|
||||
|
||||
while (offset < firmware_len) {
|
||||
|
@ -500,10 +520,12 @@ bool device4_update_mcu_firmware(device4_type* device, const char* path) {
|
|||
msgid = DEVICE4_MSG_W_UPDATE_MCU_APP_FW_TRANSMIT;
|
||||
}
|
||||
|
||||
if (!do_payload_action(device, msgid, len, firmware)) {
|
||||
if (!do_payload_action(device, msgid, len, firmware + offset)) {
|
||||
fprintf(stderr, "Failed sending firmware upload!\n");
|
||||
goto jump_to_app;
|
||||
}
|
||||
|
||||
offset += len;
|
||||
}
|
||||
|
||||
printf("Finish upload!\n");
|
||||
|
|
Reference in a new issue