Skip to content
This repository was archived by the owner on Dec 26, 2022. It is now read-only.

Commit 6535f37

Browse files
authored
Merge pull request #703 from splasky/not_found_device
Fix(endpoint): Fix device not found error message
2 parents d0c3d13 + 6a7b573 commit 6535f37

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

endpoint/endpointComp/endpoint.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,21 +126,25 @@ COMPONENT_INIT {
126126
srand(time(NULL));
127127

128128
device_t* device = ta_device(STRINGIZE(EP_TARGET));
129-
device->op->get_key(private_key);
130-
device->op->get_device_id(device_id);
131-
129+
if (device == NULL) {
130+
LE_ERROR("Can not get specific device");
131+
} else {
132+
device->op->get_key(private_key);
133+
device->op->get_device_id(device_id);
132134
#ifdef ENABLE_ENDPOINT_TEST
133-
LE_TEST_INIT;
134-
LE_TEST_INFO("=== ENDPOINT TEST BEGIN ===");
135-
LE_TEST(SC_OK == send_transaction_information(host, port, ssl_seed, value, message, message_fmt, tag, address,
136-
next_address, private_key, device_id_ptr, iv));
137-
LE_TEST_EXIT;
135+
LE_TEST_INIT;
136+
LE_TEST_INFO("=== ENDPOINT TEST BEGIN ===");
137+
LE_TEST(SC_OK == send_transaction_information(host, port, ssl_seed, value, message, message_fmt, tag, address,
138+
next_address, private_key, device_id_ptr, iv));
139+
LE_TEST_EXIT;
138140
#else
139-
while (true) {
140-
status_t ret = send_transaction_information(host, port, ssl_seed, value, message, message_fmt, tag, address,
141-
next_address, private_key, device_id_ptr, iv);
142-
LE_INFO("Send transaction information return: %d", ret);
143-
sleep(10);
144-
}
141+
while (true) {
142+
// TODO: listen input from UART here
143+
status_t ret = send_transaction_information(host, port, ssl_seed, value, message, message_fmt, tag, address,
144+
next_address, private_key, device_id_ptr, iv);
145+
LE_INFO("Send transaction information return: %d", ret);
146+
sleep(10);
147+
}
145148
#endif
149+
}
146150
}

endpoint/hal/device.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ device_t *ta_device(const char *type) {
2727
return NULL;
2828
}
2929
p = find_device(type, strlen(type));
30-
if (*p) {
31-
LE_INFO("Device type %s not found", type);
30+
if (*p == NULL) {
31+
LE_ERROR("Device type %s not found", type);
32+
return NULL;
3233
}
34+
LE_DEBUG("Successfully get %s device", type);
3335
return *p;
3436
}
3537

0 commit comments

Comments
 (0)