Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable cloud serial comms to individual devices #60

Merged
merged 1 commit into from
Apr 3, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions cores/oak/OakParticle/particle_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2792,6 +2792,9 @@ const char* RESET_EVENT = "spark/device/reset";
const char* OAK_RESET_EVENT = "oak/device/reset";
const char* OAK_RX_EVENT = "oak/device/stdin";

#define OAK_RESET_EVENT_LEN 16
#define OAK_RX_EVENT_LEN 16

void SystemEvents(const char* name, const char* data)
{
if (!strncmp(name, CLAIM_EVENTS, strlen(CLAIM_EVENTS))) {
Expand All @@ -2810,7 +2813,10 @@ void SystemEvents(const char* name, const char* data)
ESP.reset();
}
}
if (!strcmp(name, OAK_RESET_EVENT)) {
if (!strncmp(name, OAK_RESET_EVENT, OAK_RESET_EVENT_LEN) &&
(name[OAK_RESET_EVENT_LEN] == 0 ||
(name[OAK_RESET_EVENT_LEN] == '/' &&
!strcmp((name+OAK_RESET_EVENT_LEN+1),deviceConfig->device_id)))) {
if (data && *data) {
if (!strcmp("config mode", data))
reboot_to_config();
Expand Down Expand Up @@ -3180,7 +3186,11 @@ void spark_get_rx(const char* name, const char* data){ //this is automatically c
if(spark_serial_state < 2){
return;
}

if ((name[OAK_RX_EVENT_LEN] != 0 &&
(name[OAK_RX_EVENT_LEN] != '/' ||
strcmp((name+OAK_RX_EVENT_LEN+1),deviceConfig->device_id)))) {
return;
}
if (data && *data) {

while(*data != '\0'){
Expand Down