Import app manager, samples and test-tools
This commit is contained in:
@ -71,7 +71,7 @@ uint16 htons(uint16 value)
|
||||
uint16 ret;
|
||||
if (is_little_endian()) {
|
||||
ret = value;
|
||||
swap16(&ret);
|
||||
swap16((uint8 *)&ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "attr-container.h"
|
||||
#include "attr_container.h"
|
||||
#include "request.h"
|
||||
#include "shared_utils.h"
|
||||
#include "wasm_app.h"
|
||||
@ -138,9 +138,9 @@ static bool register_url_handler(const char *url,
|
||||
|
||||
// tell app mgr to route this url to me
|
||||
if (reg_type == Reg_Request)
|
||||
wasm_register_resource(url);
|
||||
wasm_register_resource((int32)url);
|
||||
else
|
||||
wasm_sub_event(url);
|
||||
wasm_sub_event((int32)url);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -242,7 +242,7 @@ void api_send_request(request_t * request, response_handler_f response_handler,
|
||||
}
|
||||
}
|
||||
|
||||
wasm_post_request(buffer, size);
|
||||
wasm_post_request((int32)buffer, size);
|
||||
|
||||
free_req_resp_packet(buffer);
|
||||
}
|
||||
@ -329,7 +329,7 @@ void api_response_send(response_t *response)
|
||||
if (buffer == NULL)
|
||||
return;
|
||||
|
||||
wasm_response_send(buffer, size);
|
||||
wasm_response_send((int32)buffer, size);
|
||||
free_req_resp_packet(buffer);
|
||||
}
|
||||
|
||||
@ -339,11 +339,11 @@ bool api_publish_event(const char *url, int fmt, void *payload, int payload_len)
|
||||
{
|
||||
int size;
|
||||
request_t request[1];
|
||||
init_request(request, url, COAP_EVENT, fmt, payload, payload_len);
|
||||
init_request(request, (char *)url, COAP_EVENT, fmt, payload, payload_len);
|
||||
char * buffer = pack_request(request, &size);
|
||||
if (buffer == NULL)
|
||||
return false;
|
||||
wasm_post_request(buffer, size);
|
||||
wasm_post_request((int32)buffer, size);
|
||||
|
||||
free_req_resp_packet(buffer);
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
#include "native_interface.h"
|
||||
#include "shared_utils.h"
|
||||
#include "attr-container.h"
|
||||
#include "attr_container.h"
|
||||
#include "request.h"
|
||||
#include "sensor.h"
|
||||
#include "timer_wasm_app.h"
|
||||
|
||||
@ -31,7 +31,7 @@ sensor_t sensor_open(const char* name, int index,
|
||||
sensor_event_handler_f sensor_event_handler,
|
||||
void *user_data)
|
||||
{
|
||||
uint32 id = wasm_sensor_open(name, index);
|
||||
uint32 id = wasm_sensor_open((int32)name, index);
|
||||
if (id == -1)
|
||||
return NULL;
|
||||
|
||||
@ -66,7 +66,7 @@ bool sensor_config_with_attr_container(sensor_t sensor, attr_container_t *cfg)
|
||||
char *buffer = (char *)cfg;
|
||||
int len = attr_container_get_serialize_length(cfg);
|
||||
|
||||
return wasm_sensor_config_with_attr_container(sensor->handle, buffer, len);
|
||||
return wasm_sensor_config_with_attr_container(sensor->handle, (int32)buffer, len);
|
||||
}
|
||||
|
||||
bool sensor_config(sensor_t sensor, int interval, int bit_cfg, int delay)
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
#ifndef _AEE_SENSOR_H_
|
||||
#define _AEE_SENSOR_H_
|
||||
|
||||
#include "attr-container.h"
|
||||
#include "attr_container.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "attr-container.h"
|
||||
#include "attr_container.h"
|
||||
|
||||
typedef union jvalue {
|
||||
bool z;
|
||||
@ -794,7 +794,7 @@ void attr_container_dump(const attr_container_t *attr_cont)
|
||||
break;
|
||||
case ATTR_TYPE_INT64:
|
||||
bh_memcpy_s(&value.j, sizeof(uint64_t), p, sizeof(uint64_t));
|
||||
attr_container_printf(", type: int64, value: 0x%llx\n", value.j);
|
||||
attr_container_printf(", type: int64, value: 0x%llx\n", (long long unsigned int)(value.j));
|
||||
p += 8;
|
||||
break;
|
||||
case ATTR_TYPE_BYTE:
|
||||
@ -109,7 +109,10 @@ request_t * unpack_request(char * packet, int size, request_t * request)
|
||||
request->sender = ntohl(*((uint32*) (packet + 8)));
|
||||
request->payload_len = payload_len;
|
||||
request->url = REQUEST_PACKET_URL(packet);
|
||||
request->payload = packet + REQUEST_PACKET_URL_OFFSET + url_len;
|
||||
if (payload_len > 0)
|
||||
request->payload = packet + REQUEST_PACKET_URL_OFFSET + url_len;
|
||||
else
|
||||
request->payload = NULL;
|
||||
|
||||
return request;
|
||||
}
|
||||
@ -150,7 +153,10 @@ response_t * unpack_response(char * packet, int size, response_t * response)
|
||||
response->mid = ntohl(*((uint32*) (packet + 4)));
|
||||
response->reciever = ntohl(*((uint32*) (packet + 8)));
|
||||
response->payload_len = payload_len;
|
||||
response->payload = packet + RESPONSE_PACKET_FIX_PART_LEN;
|
||||
if (payload_len > 0)
|
||||
response->payload = packet + RESPONSE_PACKET_FIX_PART_LEN;
|
||||
else
|
||||
response->payload = NULL;
|
||||
|
||||
return response;
|
||||
}
|
||||
@ -238,7 +244,7 @@ response_t * clone_response(response_t * response)
|
||||
response_t * set_response(response_t * response, int status, int fmt,
|
||||
const char *payload, int payload_len)
|
||||
{
|
||||
response->payload = payload;
|
||||
response->payload = (void *)payload;
|
||||
response->payload_len = payload_len;
|
||||
response->status = status;
|
||||
response->fmt = fmt;
|
||||
@ -384,11 +390,9 @@ char * find_key_value(char * buffer, int buffer_len, char * key, char * value,
|
||||
int value_len, char delimiter)
|
||||
{
|
||||
char * p = buffer;
|
||||
int i = 0;
|
||||
int remaining = buffer_len;
|
||||
int key_len = strlen(key);
|
||||
|
||||
char * item_start = p;
|
||||
while (*p != 0 && remaining > 0) {
|
||||
while (*p == ' ' || *p == delimiter) {
|
||||
p++;
|
||||
|
||||
@ -17,10 +17,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "lib-export.h"
|
||||
#include "lib_export.h"
|
||||
|
||||
#ifdef WASM_ENABLE_BASE_LIB
|
||||
#include "base-lib-export.h"
|
||||
#include "base_lib_export.h"
|
||||
#endif
|
||||
|
||||
static NativeSymbol extended_native_symbol_defs[] = {
|
||||
@ -17,7 +17,7 @@
|
||||
#ifndef _BASE_LIB_EXPORT_H_
|
||||
#define _BASE_LIB_EXPORT_H_
|
||||
|
||||
#include "attr-container.h"
|
||||
#include "attr_container.h"
|
||||
#include "native_interface.h"
|
||||
|
||||
#endif /* end of _BASE_LIB_EXPORT_H_ */
|
||||
@ -15,11 +15,11 @@
|
||||
*/
|
||||
|
||||
#include "native_interface.h"
|
||||
#include "app-manager-export.h"
|
||||
#include "app_manager_export.h"
|
||||
#include "coap_ext.h"
|
||||
#include "wasm-export.h"
|
||||
#include "wasm_export.h"
|
||||
|
||||
extern void module_request_handler(request_t *request, uint32 register_id);
|
||||
extern void module_request_handler(request_t *request, void *user_data);
|
||||
|
||||
bool wasm_response_send(int32 buffer_offset, int size)
|
||||
{
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
#include "runtime_timer.h"
|
||||
#include "app-manager-export.h"
|
||||
#include "app_manager_export.h"
|
||||
#include "module_wasm_app.h"
|
||||
#include "bh_list.h"
|
||||
#include "bh_thread.h"
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
#include "runtime_sensor.h"
|
||||
#include "app-manager-export.h"
|
||||
#include "app_manager_export.h"
|
||||
#include "module_wasm_app.h"
|
||||
#include "bh_thread.h"
|
||||
#include "bh_time.h"
|
||||
@ -168,7 +168,7 @@ uint32 wasm_sensor_open(int32 name_offset, int instance)
|
||||
|
||||
memset(client, 0, sizeof(sensor_client_t));
|
||||
client->client_id = mod_id;
|
||||
client->client_callback = wasm_sensor_callback;
|
||||
client->client_callback = (void *)wasm_sensor_callback;
|
||||
client->interval = s->default_interval;
|
||||
client->next = s->clients;
|
||||
s->clients = client;
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
#define LIB_EXTENSION_RUNTIME_SENSOR_H_
|
||||
|
||||
#include "bh_platform.h"
|
||||
#include "attr-container.h"
|
||||
#include "attr_container.h"
|
||||
struct _sys_sensor;
|
||||
typedef struct _sys_sensor* sensor_obj_t;
|
||||
|
||||
|
||||
@ -18,9 +18,9 @@
|
||||
#include "bh_queue.h"
|
||||
#include "bh_thread.h"
|
||||
#include "runtime_sensor.h"
|
||||
#include "attr-container.h"
|
||||
#include "attr_container.h"
|
||||
#include "module_wasm_app.h"
|
||||
#include "wasm-export.h"
|
||||
#include "wasm_export.h"
|
||||
|
||||
/*
|
||||
*
|
||||
@ -99,11 +99,10 @@ static attr_container_t * read_test_sensor(void * sensor)
|
||||
|
||||
static bool config_test_sensor(void * s, void * config)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void * thread_sensor_check(void * arg)
|
||||
static void thread_sensor_check(void * arg)
|
||||
{
|
||||
while (1) {
|
||||
int ms_to_expiry = check_sensor_timers();
|
||||
@ -120,6 +119,8 @@ static void cb_wakeup_thread()
|
||||
vm_cond_signal(&cond);
|
||||
}
|
||||
|
||||
void set_sensor_reshceduler(void (*callback)());
|
||||
|
||||
void init_sensor_framework()
|
||||
{
|
||||
// init the mutext and conditions
|
||||
@ -138,7 +139,7 @@ void init_sensor_framework()
|
||||
|
||||
wasm_register_cleanup_callback(sensor_cleanup_callback);
|
||||
|
||||
vm_thread_create(&tid, thread_sensor_check, NULL,
|
||||
vm_thread_create(&tid, (void *)thread_sensor_check, NULL,
|
||||
BH_APPLET_PRESERVED_STACK_SIZE);
|
||||
|
||||
}
|
||||
|
||||
@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "wasm-native.h"
|
||||
#include "wasm-export.h"
|
||||
#include "wasm_native.h"
|
||||
#include "wasm_export.h"
|
||||
#include "wasm_log.h"
|
||||
#include "wasm_platform_log.h"
|
||||
|
||||
@ -903,7 +903,9 @@ wasm_native_func_lookup(const char *module_name, const char *func_name)
|
||||
|
||||
while (func_def < func_def_end) {
|
||||
if (!strcmp(func_def->module_name, module_name)
|
||||
&& !strcmp(func_def->func_name, func_name))
|
||||
&& (!strcmp(func_def->func_name, func_name)
|
||||
|| (func_def->func_name[0] == '_'
|
||||
&& !strcmp(func_def->func_name + 1, func_name))))
|
||||
return (void*) (uintptr_t) func_def->func_ptr;
|
||||
func_def++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user