This repository has been archived by the owner on Dec 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #253 from UltimateHackingKeyboard/parse_targets
Parse connections from config.
- Loading branch information
Showing
20 changed files
with
222 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../right/src/config_parser/error_reporting.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../right/src/config_parser/error_reporting.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../right/src/config_parser/parse_host_connection.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../right/src/config_parser/parse_host_connection.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../right/src/host_connection.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "error_reporting.h" | ||
#include "config_parser/basic_types.h" | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <inttypes.h> | ||
#include <stdarg.h> | ||
#include "macros/status_buffer.h" | ||
|
||
void ConfigParser_Error(config_buffer_t *buffer, const char *fmt, ...) | ||
{ | ||
va_list myargs; | ||
va_start(myargs, fmt); | ||
char printBuffer[256]; | ||
vsprintf(printBuffer, fmt, myargs); | ||
Macros_ReportErrorPrintf(NULL, "%d: %s", buffer->offset, printBuffer); | ||
config_buffer_t myBuffer = *buffer; | ||
myBuffer.offset = buffer->offset >= 10 ? buffer->offset - 10 : 0; | ||
uint8_t windowCount = 5; | ||
for (uint8_t window = 0; window < windowCount; window++) | ||
{ | ||
uint8_t context[10]; | ||
for (uint8_t i = 0; i < 10; i++) | ||
{ | ||
context[i] = ReadUInt8(&myBuffer); | ||
} | ||
Macros_ReportErrorPrintf(NULL, "%d: %u %u %u %u %u %u %u %u %u %u", myBuffer.offset-10, context[0], context[1], context[2], context[3], context[4], context[5], context[6], context[7], context[8], context[9]); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef __CONFIG_PARSER_ERROR_REPORTING_H__ | ||
#define __CONFIG_PARSER_ERROR_REPORTING_H__ | ||
|
||
// Includes: | ||
|
||
#include "basic_types.h" | ||
#include "parse_config.h" | ||
#include <stdint.h> | ||
#include <stdbool.h> | ||
|
||
// Typedefs: | ||
|
||
// Functions: | ||
|
||
void ConfigParser_Error(config_buffer_t *buffer, const char *fmt, ...); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "parse_host_connection.h" | ||
#include "config_manager.h" | ||
#include "config_parser/basic_types.h" | ||
#include "config_parser/parse_config.h" | ||
#include "host_connection.h" | ||
|
||
static void parseHostConnection(config_buffer_t* buffer, host_connection_t* host_connection) { | ||
host_connection->type = ReadUInt8(buffer); | ||
|
||
if (host_connection->type == HostConnectionType_Ble || host_connection->type == HostConnectionType_Dongle) { | ||
for (uint8_t i = 0; i < BLE_ADDRESS_LENGTH; i++) { | ||
host_connection->bleAddress[i] = ReadUInt8(buffer); | ||
} | ||
} | ||
|
||
if (host_connection->type != HostConnectionType_Empty) { | ||
uint16_t len; | ||
host_connection->name.start = ReadString(buffer, &len); | ||
host_connection->name.end = host_connection->name.start + len; | ||
} | ||
} | ||
|
||
parser_error_t ParseHostConnections(config_buffer_t *buffer) { | ||
for (uint8_t host_connectionId = 0; host_connectionId < HOST_CONNECTION_COUNT_MAX; host_connectionId++) { | ||
host_connection_t dummy; | ||
parseHostConnection(buffer, &dummy); | ||
} | ||
|
||
return ParserError_Success; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef __HOST_CONNECTIONS_H__ | ||
#define __HOST_CONNECTIONS_H__ | ||
|
||
|
||
// Includes: | ||
|
||
#include "basic_types.h" | ||
#include "parse_config.h" | ||
|
||
// Macros: | ||
|
||
// Typedefs: | ||
|
||
// Functions: | ||
|
||
parser_error_t ParseHostConnections(config_buffer_t *buffer); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.