Author Topic: Simblee COM Send and Receive  (Read 371 times)

LordOddEye

  • RFduino Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Simblee COM Send and Receive
« on: June 12, 2017, 07:21:54 AM »
Hello everyone,

I am dealing with two Simblee devices that need to Send and Receive data back and forth.

When programming this I experience a problem. The moment I begin to Send files the Recieve function will no longer work.

I am wondering how I can remedy this and work around the issue.

This is the two codes for the two devices:

Device 1:

Code: [Select]
#include "SimbleeCOM.h"

char sensor[] = {'S', 'U', 'C', 'C', 'E', 'S', 'S'};

void setup() {

    Serial.begin(9600);
  pinMode(30, OUTPUT);
pinMode(29, OUTPUT);
pinMode(28, OUTPUT);
digitalWrite(30, LOW);
digitalWrite(29, LOW);
digitalWrite(28, LOW);
  SimbleeCOM.begin();
}

void loop() {

  //SimbleeCOM.send(sensor, sizeof(sensor));

}

void SimbleeCOM_onReceive(unsigned int esn, const char *screen_send, int len, int rssi)
{
 
digitalWrite(30, HIGH);
delay(1000);
digitalWrite(30, LOW);
digitalWrite(29, HIGH);
delay(1000);
digitalWrite(29, LOW);
digitalWrite(28, HIGH);
delay(1000);
digitalWrite(28, LOW);

  for (int i = 0; i < len; i++)
    Serial.print(screen_send[i]);
  printf("\n");
}
 

Device 2:

Code: [Select]
#include "SimbleeCOM.h"

char screen_send[] = {'S', 'U', 'C', 'C', 'E', 'S', 'S'};

void setup() {

    Serial.begin(9600);
  SimbleeCOM.begin();
}

void loop() {
  //SimbleeCOM.send(initi, sizeof(initi));
  SimbleeCOM.send(screen_send, sizeof(screen_send));

}

void SimbleeCOM_onReceive(unsigned int esn, const char *sensor, int len, int rssi)
{

  for (int i = 0; i < len; i++)
    Serial.print(sensor[i]);
  printf("\n");
}



tolson

  • Global Moderator
  • *****
  • Posts: 870
  • Karma: +20/-0
    • View Profile
    • Thomas Olson Consulting
Re: Simblee COM Send and Receive
« Reply #1 on: June 12, 2017, 09:30:18 AM »
The _onReceive functions are interrupt callbacks. Get in and get out! You can't have 1 second delays and large print statements. Just set some variable and/or flags in the _onReceive function and then deal with those in the main loop.

LordOddEye

  • RFduino Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Simblee COM Send and Receive
« Reply #2 on: June 13, 2017, 08:00:51 AM »
OK thank you that solved the issue!