I followed the tutorial:
http://redpitaya.readthedocs.io/en/late ... bApps.html
and made an application that stores parameters in a file via js/app.js:
Code: Select all
// sends configuration to backend
var local = {};
local['CALL'] = { value: $('#call').val() };
APP.ws.send(JSON.stringify({ parameters: local }));
To that end I call the method APP.processParamters(receive.parameters) every time a message is received.
Code: Select all
if (receive.parameters) {
//console.log('received params')
APP.processParameters(receive.parameters);
}
The main.cpp looks like that:
Code: Select all
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/sysinfo.h>
#include <sstream>
#include "main.h"
/* -------------------------------- OUT PARAMETERS ------------------------------ */
CStringParameter call("CALL", CBaseParameter::RWSA, "", 10000);
CStringParameter grid("GRID", CBaseParameter::RWSA, "", 10000);
CStringParameter comment("COMMENT", CBaseParameter::RWSA, "", 10000);
CStringParameter wlid("WLID", CBaseParameter::RWSA, "", 10000);
CStringParameter wlpw("WLPW", CBaseParameter::RWSA, "", 10000);
/*
CFloatParameter ppm("PPM", CBaseParameter::RW, 0.0, 0, -100.0, 100.0);
CStringParameter wlid("WSPRLIVE-ID", CBaseParameter::RWSA, "", 10000);
CStringParameter wlpw("WSPRLIVE-PW", CBaseParameter::RWSA, "", 10000);
CStringParameter bands("BANDS", CBaseParameter::RWSA, "", 10000);
*/
const char *rp_app_desc(void)
{
return (const char *)"Red Pitaya SDR WSPR 8-channel receiver.\n";
}
int rp_app_init(void)
{
fprintf(stderr, "Loading sdr_wspr application\n");
// CDataManager::GetInstance()->SetParamInterval(1000);
system("/opt/redpitaya/www/apps/sdr_wspr/start.sh");
return 0;
}
int rp_app_exit(void)
{
fprintf(stderr, "Unloading sdr_wspr application\n");
system("/opt/redpitaya/www/apps/sdr_wspr/stop.sh");
return 0;
}
int rp_set_params(rp_app_params_t *p, int len)
{
return 0;
}
int rp_get_params(rp_app_params_t **p)
{
return 0;
}
int rp_get_signals(float ***s, int *sig_num, int *sig_len)
{
return 0;
}
void UpdateSignals(void){}
void UpdateParams(void){
}
void OnNewParams(void) {
call.Update();
grid.Update();
comment.Update();
wlid.Update();
wlpw.Update();
std::stringstream wsprvars;
wsprvars << "CALL=\"" << call.Value() << "\"" << '\n';
wsprvars << "GRID=\"" << grid.Value() << "\"" << '\n';
wsprvars << "COMMENT=\"" << comment.Value() << "\"" << '\n';
wsprvars << "WLID=\"" << wlid.Value() << "\"" << '\n';
wsprvars << "WLPW=\"" << wlpw.Value() << "\"" << '\n';
system("mount -o rw,remount /opt/redpitaya");
std::string command1 = "echo '" + wsprvars.str() + "' > /opt/redpitaya/www/apps/sdr_wspr/wspr-vars.sh";
system(command1.c_str());
}
Code: Select all
call.Value() = 'PA7T';