Thanks for the response.
What I'm trying to achieve is a website that communicates with the ATmega via /data/.
I have an HTML page with jQuery to send the proper commands (n.n.n.n/data/get & /put/key/value).
Because /data/ is set up as a JSON string I would've assumed this would be part of the intended use for the Bridge class.
As to your questions:
I want to dynamically set the key value (see code below) because I have a lot of LED's, and I want to be able to write to the Bridge within a function. This function will grab the key (pre)defined in my LED data struct, so that I can simply pass the data struct, without having to write a separate function for each of my LED's.
PCWorxLA:
how do you intend to synchronize that the keys are matching on both sides?
The keys are predefined both in the sketch, and on my website. There isn't any ambiguity for the compiler - I've even tried set the struct value to const.
PCWorxLA:
It almost seems to me as if you are trying to (ab)use the bridge mechanism not to exchange data between a sketch and corresponding Python/Lua/C(++) script/program on the Linux side, but instead using it as a (temporary) data storage for your sketch....
I am not building anything on the linino, I'm only using whatever access automatically ensues when you instantiate the Bridge class. If this is wrong/abusive, I'm sorry. This is where some more documentation about Bridge would be great. All I'm trying to do is create an asynchronous communication between my website and my Yun.
PCWorxLA:
Honestly, I am not quite sure what your actual problems and/or what exactly you are trying to achieve.
My problem is that I can't have any sort of a non-constant within my Bridge.get call. This is very frustrating, and means I probably can't finish the project without running out of memory on the Mega. Here's my sketch:
#include "functEval.h"
#include <Bridge.h>
LEDSTRU pin7 = {true, false, false,
true, false, false, false, false, 7
};
LEDSTRU pin8 = {true, false, false,
true, false, false, false, false, 8
};
LEDSTRU pin9 = {true, false, false,
true, false, false, false, false, 9
};
LEDSTRU pin10 = {true, false, false,
true, false, false, false, false, 10
};
LEDSTRU pin11 = {true, false, false,
true, false, false, false, false, 11
};
LEDSTRU pin12 = {true, false, false,
true, false, false, false, false, 12
};
LEDSTRU pin13 = {true, false, false,
true, false, false, false, false, 13
};
char chBuff[10];
bool BlinkTest = false;
String placeholder;
char notherBuff[6];
void setup() {
digitalWrite(13, LOW);
Bridge.begin();
digitalWrite(13, HIGH);
pinMode(13, OUTPUT);
}
void loop() {
pin13.AutoCallOn = true;
checkManual(pin12);
eval(pin12);
}
void checkManual (LEDSTRU& LED) {
placeholder = String(LED.PinNum) + "cmnd";
placeholder.toCharArray(notherBuff, 6);
Bridge.get(notherBuff, chBuff, 9);
if (chBuff[0] == 'M') {
pin13.AutoModeOffReq = true;
}
if (chBuff[0] == 'A') {
pin13.AutoModeOnReq = true;
}
placeholder = String(LED.PinNum);
placeholder.toCharArray(notherBuff, 6);
Bridge.get(notherBuff, chBuff, 9);
if (chBuff[1] == 'N') {
pin13.ManCallOn = true;
}
if (chBuff[1] == 'F') {
pin13.ManCallOff = true;
}
}
void eval(LEDSTRU& LED) {
if (LED.AutoModeOnReq == true) { //if input says listen to automatic processes
LED.AutoManMode = true; //run input from higher logic
LED.AutoModeOnReq = false; //reset bool so it doesn't get stuck
}
if (LED.AutoModeOffReq == true) { //if input says listen to manual
LED.AutoManMode = false; //run input from manual
LED.AutoModeOffReq = false; //reset bool
}
if (LED.AutoManMode == true) { //if we're running input from auto processes
if (LED.AutoCallOn == true) { //if auto says turn on
digitalWrite(LED.PinNum, HIGH); //turn on
LED.LEDon = true; //record status
LED.AutoCallOn = false; //reset bool
}
if (LED.AutoCallOff == true) { //if auto says turn off
digitalWrite(LED.PinNum, LOW); //turn off
LED.LEDon = false; //record status
LED.AutoCallOff = false; //reset bool
}
}
if (LED.AutoManMode == false) { //if we're listening to manual input
if (LED.ManCallOn == true) { //if manual input says turn on
digitalWrite(LED.PinNum, HIGH);//turn on
LED.LEDon = true; //record status
LED.ManCallOn = false; //reset bool
}
if (LED.ManCallOff == true) {//if manual input says turn off
digitalWrite(LED.PinNum, LOW); //turn off
LED.LEDon = false; //record status
LED.ManCallOff = false; //reset bool
}
}
}
This function is the one that is broken.
void checkManual (LEDSTRU& LED) {
placeholder = String(LED.PinNum) + "cmnd";
placeholder.toCharArray(notherBuff, 6);
Bridge.get(notherBuff, chBuff, 9); //This line and the one below throw exceptions no matter what I put there, excepting a " " literal
//and a char array, but I'm having trouble with the char array
if (chBuff[0] == 'M') {
pin13.AutoModeOffReq = true;
}
if (chBuff[0] == 'A') {
pin13.AutoModeOnReq = true;
}
placeholder = String(LED.PinNum);
placeholder.toCharArray(notherBuff, 6);
Bridge.get(notherBuff, chBuff, 9);//This is where I'm having issues, I can't put any value here which isn't a literal
//or a char array. Why?
//Are there any workarounds?
if (chBuff[1] == 'N') {
pin13.ManCallOn = true;
}
if (chBuff[1] == 'F') {
pin13.ManCallOff = true;
}
I also have a .h folder containing my struct, which is totally legal and has worked in other cases.
Any thoughts?
Again, I need a proxy data table for the ATmega & the website to access because #1 - the mega needs to be able to be running processes separately without the interference of waiting for a client, #2 - it should be accessible from multiples webpages at the same time.