Powerbuilder ORCA API Deploy - sybase

I am trying to deploy my powerbuilder project to EAServer with orca api. But I am gettiing error -21 PBORCA_CBBUILDERROR (Deployment failed with errors). Also, callback function(BuildErrProc) is not being called. How can I overcome this problem? BTW I am using WindowsXP-32bit, Powerbuilder 11.2, EAServer 5.5, QT-4.8.0 opensource vs2010.
void __stdcall BuildErrProc(LPVOID lpUserData) {
PPBORCA_BLDERR blderr = (PPBORCA_BLDERR)lpUserData;
QString s;
s = QString::fromStdWString(blderr->lpszMessageText);
QMessageBox::information(0,"",s);
}
int WINAPI BuildProject(QString currentApplLibName,QString currentApplName,QString projectLibName,QString projectName,QStringList libraryNames)
{
PBORCA_BLDPROC fpBuildErrProc;
PPBORCA_BLDERR pBldErrData;
fpBuildErrProc = (PBORCA_BLDPROC) BuildErrProc;
pBldErrData = (PPBORCA_BLDERR) new PBORCA_BLDERR;
memset(pBldErrData, 0x00, sizeof(PBORCA_BLDERR));
HPBORCA hORCASession;
hORCASession = SessionOpen();
printf("Setting library list..\n");
LPTSTR* pLibNames = new LPTSTR[libraryNames.size()];
for(int i=0;i<libraryNames.size();i++) {
pLibNames[i]=(LPTSTR)libraryNames.at(i).utf16();
}
int r = PBORCA_SessionSetLibraryList(hORCASession, pLibNames, libraryNames.size());
if(r==0) {
printf("Library list OK.\n");
QMessageBox::information(0,"",currentApplName);
r = PBORCA_SessionSetCurrentAppl(hORCASession,(LPTSTR)currentApplLibName.utf16(),(LPTSTR)currentApplName.utf16());
if(r==0) {
printf("Setting current appl OK.\n");
r = PBORCA_BuildProject(hORCASession,(LPTSTR)projectLibName.utf16(),(LPTSTR)projectName.utf16(),fpBuildErrProc,pBldErrData);
if (r==0) {
printf("Building current prj OK.\n");
} else {
printf("Build FAILURE:%d\n",r);
}
} else {
printf("Current appl FAILURE.\n");
}
} else {
printf("Library list FAILURE:%d\n",r);
}
SessionClose(hORCASession);
return r;
}

I resolved it. Library list was wrong. When I set correct lib list it built the project successfully.

Related

Firmware over the air algorithm

I'm doing firmware over the air update, but I don't know how long will it take to download the firmware and upgrade the device. So what I have tried is to go into infinite loop while(1) and check if the firmware is finished upgrading. That fcked up the devices on the street... The other option is to do timeout but for how long? It's unpredictable.
The question is, how to ensure realiability and do it correctly?
Here is what I have tried:
signed char wait_commands(vu32 timeout, char*command, const char *result_command, int valueToCheck)
{
char *result = NULL;
timer_1sec = 0;
while(timer_1sec < timeout)
{
if( GSMGetString(tempdata, 5) == OK)
{
result = strstr(tempdata, command);
if ( result != NULL)
{
int value;
if ( result_command != NULL)
{
if( valueToCheck != -1)
{
if (sscanf(result, result_command, &value) > 0)
{
if (value != valueToCheck)
{
return FEHLER;
}
else
{
return OK;
}
}
}
}
else
{
return OK;
}
}
}
}
return FEHLER;
}
u8 isUpdated(void)
{
char *currentFirmwareVersion = "BG96MAR02A07M1G_01.019.01.019";
while (GSMCommand("+QGMR", tempdata, 20) != AT_OK)
;
if (strncmp(tempdata, currentFirmwareVersion, strlen(currentFirmwareVersion))==0)
{
isBG96Updated = 1;
}
else
{
isBG96Updated = 0;
}
return isBG96Updated;
}
signed char updateBG96FirmwareVersion(vu32 timeout)
{
char *url = "\"http://10.10.169.1/dfota/upgrade.bin\"";
char command[150] = {0};
signed char res = FEHLER;
if(isUpdated())
return OK;
sprintf(command, "AT+QFOTADL=%s", url);
PutStringUART(UART_GSM, command);
PutCharUART(UART_GSM, '\r');
res = wait_commands(timeout, "\"FOTA\",\"HTTPSTART\"", NULL, -1);
res = wait_commands(timeout, "\"FOTA\",\"END\"", "\"FOTA\",\"END\",%d", 0);
return res;
}
I have no experience with the Quectel BG96 chip, specifically, but it appears to support DFOTA, and there is also an official guide that you can view/download here.
This guide contains the AT commands necessary to upgrade the firmware over-the-air. Plus, I think it may clarify your doubts about the upgrade procedure.

IBM Watson IoT - Unable to get response from topic with parameters using ESP8266

From several days I searched for this problem:
I want to do a connected device (IoT) using Watson IoT Platform and ESP32 (or similar). This device have some relays on board.
On Watson dashboard I created the device type, the physical/logical interface, I connected the ESP with the platform.
I created a custom action on the dashboard that has a param to identify the relay that I want to switch (switch2) and also a simple custom action (switch) without param.
The problem is that if I generate the action without the param (switch) I see the callback print, if I generate the action with a param (switch2) nothing happens.
I tried also to use the built-in Watson action "firmware update/download", if I use firmware download (that want some params such as uri, version, etc.) nothing happens, if I use firmware update (that don't want params), I see the callback of subscription.
Here you can see the code arduino like for the ESP
// --------------- HEADERS -------------------
#include <Arduino_JSON.h>
#include <EEPROM.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
#include <ESPmDNS.h>
#include <PubSubClient.h> //https://github.com/knolleary/pubsubclient/releases/tag/v2.3
WebServer server(80);
char wifi_ssid[100] = "xxxxxx";
char wifi_psw[200] = "xxxxxxx";
// ----- Watson IBM parameters
#define ORG "xxxx"
#define DEVICE_TYPE "Relay"
#define DEVICE_ID "xxxx"
#define TOKEN "xxxxxxxxxxxxxxxx"
char ibmServer[] = ORG ".messaging.internetofthings.ibmcloud.com";
char authMethod[] = "use-token-auth";
char token[] = TOKEN;
char clientId[] = "d:" ORG ":" DEVICE_TYPE ":" DEVICE_ID;
const char switchTopic[] = "iotdm-1/mgmt/custom/switch-actions-v1/switch2";
const char testTopic[] = "iotdm-1/mgmt/custom/switch-actions-v1/switch"; //"iot-2/cmd/+/fmt/+";
const char observeTopic[] = "iotdm-1/observe";
const char publishTopic[] = "iot-2/evt/status/fmt/json";
const char responseTopic[] = "iotdm-1/response";
const char deviceResponseTopic[] = "iotdevice-1/response";
const char manageTopic[] = "iotdevice-1/mgmt/manage";
const char updateTopic[] = "iotdm-1/mgmt/initiate/firmware/update";
void callback(char* topic, byte* payload, unsigned int payloadLength);
WiFiClient wifiClient;
PubSubClient client(ibmServer, 1883, callback, wifiClient);
bool outputEnable = false;
bool oldOutputEnable = false;
void setup() {
// put your setup code here, to run once:
//Init la porta seriale ed aspetta che si avii
Serial.begin(115200);
while(!Serial) {
delay(1);
}
setupWiFi();
}
void loop() {
// put your main code here, to run repeatedly:
if (!client.loop()) {
mqttConnect();
initManagedDevice();
}
delay(100);
}
// WiFi Settings
void setupWiFi() {
bool state = false;
Serial.println("---- Setup WiFi ----");
Serial.println(wifi_ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(wifi_ssid, wifi_psw);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
mqttConnect();
initManagedDevice();
publishStatus();
Serial.println("");
Serial.print("Connected to ");
Serial.println(wifi_ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
// IBM IoT
void mqttConnect() {
if (!!!client.connected()) {
Serial.print("Reconnecting MQTT client to "); Serial.println(ibmServer);
while (!!!client.connect(clientId, authMethod, token)) {
Serial.print(".");
delay(500);
}
Serial.println();
}
}
void initManagedDevice() {
if (client.subscribe("iotdm-1/response")) {
Serial.println("subscribe to responses OK");
} else {
Serial.println("subscribe to responses FAILED");
}
if (client.subscribe("iotdm-1/device/update")) {
Serial.println("subscribe to update OK");
} else {
Serial.println("subscribe to update FAILED");
}
if (client.subscribe(observeTopic)) {
Serial.println("subscribe to observe OK");
} else {
Serial.println("subscribe to observe FAILED");
}
if (client.subscribe(switchTopic)) {
Serial.println("subscribe to switch OK");
} else {
Serial.println("subscribe to switch FAILED");
}
if (client.subscribe(testTopic)) {
Serial.println("subscribe to Test OK");
} else {
Serial.println("subscribe to Test FAILED");
}
JSONVar root;
JSONVar d;
JSONVar supports;
supports["deviceActions"] = true;
supports["firmwareActions"] = true;
supports["switch-actions-v1"] = true;
d["supports"] = supports;
root["d"] = d;
char buff[300] = "";
JSON.stringify(root).toCharArray(buff, 300);
Serial.println("publishing device metadata:"); Serial.println(buff);
if (client.publish(manageTopic, buff)) {
Serial.println("device Publish ok");
} else {
Serial.print("device Publish failed:");
}
}
void callback(char* topic, byte* payload, unsigned int payloadLength) {
Serial.print("callback invoked for topic: "); Serial.println(topic);
if (strcmp (responseTopic, topic) == 0) {
return; // just print of response for now
}
if (strcmp (updateTopic, topic) == 0) {
handleUpdate(payload);
}
if (strcmp(switchTopic, topic) == 0) {
handleRemoteSwitch(payload);
}
if(strcmp(observeTopic, topic) == 0) {
handleObserve(payload);
}
}
void sendSuccessResponse(const char* reqId) {
JSONVar payload;
payload["rc"] = 200;
payload["reqId"] = reqId;
char buff[300] = "";
JSON.stringify(payload).toCharArray(buff, 300);
if (client.publish(deviceResponseTopic, buff)) {
Serial.println("Success sended");
} else {
Serial.print("Success failed:");
}
}
void publishStatus() {
String payload = "{\"relayStatus\":";
payload += outputEnable;
payload += "}";
Serial.print("Sending payload: "); Serial.println(payload);
if (client.publish(publishTopic, (char*) payload.c_str())) {
Serial.println("Publish OK");
} else {
Serial.println("Publish FAILED");
}
}
void handleUpdate(byte* payload) {
Serial.println("handle Update");
}
void handleObserve(byte* payload) {
JSONVar request = JSON.parse((char*)payload);
JSONVar d = request["d"];
JSONVar fields = d["fields"];
const char* field = fields[0]["field"];
if(strcmp(field, "mgmt.firmware") == 0) {
Serial.println("Upadete the firmware");
sendSuccessResponse(request["reqId"]);
} else {
Serial.println("Unmanaged observe");
Serial.println(request);
}
}
void handleRemoteSwitch(byte* payload) {
Serial.println("handle remote switching");
//invertedSwitch = !invertedSwitch;
outputEnable = !outputEnable;
JSONVar request = JSON.parse((char*)payload);
const char* id = request["reqId"];
sendSuccessResponse(id);
}
Thanks to everyone that wants to try to help me.
After several days I solved the issue, I post here de response for someone with the same problem:
The problem is the PubSubClient library, that accept only 128 bytes response message (including header). The Watson IBM produce longer response message than 128 bytes.
To change the buffer size for the response message, you need to modify the PubSubClient.h file at line
#define MQTT_MAX_PACKET_SIZE 128
And change the 128 byte with bigger number (eg. 1024).

UCI C API - How to set multiple options by running a single program only once

I want to set multiple options at the same time using UCI C API.
I tried using below code but this sets only one option at a time.
But how to set multiple options and sections at the same time?
#include <uci.h>
#include <stdio.h>
int main() {
uci_context* ctx = uci_alloc_context();
if (!ctx) {
printf("failed to alloc uci ctx\n");
return 1;
}
uci_ptr config;
char section_name[] = "your_package.your_section";
if (uci_lookup_ptr(ctx, &config, section_name, true) != UCI_OK || !config.s) {
printf("failed to find the specified section\n");
return 1;
}
config.option = "new_option_name";
config.value = "new_option_value";
if (uci_set(ctx, &config) != UCI_OK) {
printf("failed to set new option\n");
return 1;
}
if (uci_commit(ctx, &config.p, false) != UCI_OK) {
printf("failed to commit changes\n");
return 1;
}
return 0;
}

Add an option under a specific section using UCI's C API

How can I add a NEW option under a specific section in an UCI config file? I would like to achieve that programmatically using the C API. Can someone put an example here ?
#include <uci.h>
#include <stdio.h>
int main() {
uci_context* ctx = uci_alloc_context();
if (!ctx) {
printf("failed to alloc uci ctx\n");
return 1;
}
uci_ptr config;
char section_name[] = "your_package.your_section";
if (uci_lookup_ptr(ctx, &config, section_name, true) != UCI_OK || !config.s) {
printf("failed to find the specified section\n");
return 1;
}
config.option = "new_option_name";
config.value = "new_option_value";
if (uci_set(ctx, &config) != UCI_OK) {
printf("failed to set new option\n");
return 1;
}
if (uci_commit(ctx, &config.p, false) != UCI_OK) {
printf("failed to commit changes\n");
return 1;
}
return 0;
}

Error with Fork and NodeJS

I'm trying to use NodeJS with a C program to http://en.wikipedia.org/wiki/Setvbuf for JS files using Fork().
My program.c :
int readTabStr(int k)
{
char * tabString[] = {"p1.js","p2.js","p3.js","p4.js"};
int taille = sizeof(tabString)/sizeof(char);
int i;
for(i=0; i<taille; i++)
{
if (fork() == 0)
{
execlp("node","node", tabString[i], NULL);
}
else
{
wait(NULL);
}
}
return 0;
}
I'm using this JS file to launch the C file:
var FFI = require("../../lib/ffi");
var test = new FFI.Library("./readTab", {
"readTabStr": ["int", ["int" ]]
});
var resultat = test.readTabStr(0);
The problem is that after executing the p1.js, p2.js, p3.jsn p4.js. I get 4 error messages :
node.js:116
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module '/home/fighter/Documents/ffi/kerrighed/execlp/��$[]�U
`enter code here`��E��E��U��S������1�'
at Function._resolveFilename (module.js:299:11)
at Function._load (module.js:245:25)
at Array.<anonymous> (module.js:402:10)
at EventEmitter._tickCallback (node.js:108:26)
Any ideas?
Solved,
The problem was
int taille = sizeof(tabString)/sizeof(char);
I should do :
int taille = sizeof(tabString)/sizeof(char*);
Thanks anyway.

Resources