void test() { printf("Start test!\n"); cloud_init("localhost:8888"); cloud_print_error(); cloud_list_service(list_service); cloud_print_error(); printf("Create bucket\n"); cloud_create_bucket("test"); cloud_print_error(); cloud_list_service(list_service); cloud_print_error(); printf("Put object\n"); infile = fopen("./README", "rb"); struct stat stat_buf; lstat("./README", &stat_buf); cloud_put_object("test", "helloworld", stat_buf.st_size, put_buffer); fclose(infile); cloud_print_error(); printf("List bucket test:\n"); cloud_list_bucket("test", list_bucket); printf("Get object:\n"); outfile = fopen("/tmp/README", "wb"); cloud_get_object("test", "helloworld", get_buffer); fclose(outfile); cloud_print_error(); printf("Delete object:\n"); cloud_delete_object("test", "helloworld"); cloud_print_error(); printf("List bucket test:\n"); cloud_list_bucket("test", list_bucket); cloud_print_error(); printf("Delete bucket test:\n"); cloud_delete_bucket("test"); cloud_print_error(); printf("List service:\n"); cloud_list_service(list_service); printf("End test!\n"); cloud_destroy(); }
void main() { int rc; char c; char mac[6]; if (cloud_init()) exit(1); printf("Hit <space> to print network interface status and MAC address\n"); printf(" ? to print XBee node table\n"); printf(" a to print memory usage\n"); printf("\nNote: MAC is useful for manually adding device to Device Cloud.\n\n"); _restart: do { rc = cloud_tick(); if (kbhit()) { c = getchar(); if (c == ' ') { ip_print_ifs(); printf("MAC address: %02X%02X%02X:%02X%02X%02X\n", SysIDBlock.macAddr[0], SysIDBlock.macAddr[1], SysIDBlock.macAddr[2], SysIDBlock.macAddr[3], SysIDBlock.macAddr[4], SysIDBlock.macAddr[5] ); } else if (c == '?') sxa_node_table_dump(); else if (c == 'a') _sys_malloc_stats(); } } while (!rc); printf("Final rc = %d\n", rc); if (rc == -NETERR_ABORT) { // RCI reboot request was received. Normally we would use this // to shut down cleanly and reboot the board. printf("Rebooting via exit(0)!\n"); exit(0); } goto _restart; }
int main(int argc, char *argv[]) { // init cloud cloud_init(); // create timer p_tm = create_timer(2, hello, 0); assert(p_tm); start_timer(p_tm); // run cloud cloud_run(0); return 0; }
void main() { int rc; if (cloud_init()) exit(1); // This is where we actually register the cursom do_commands. // Note use of the '#' (enquote) operator to turn the variable // names into strings. [The double macro indirection is required to // get this to work!]. NOTE: this registration must be done after // cloud_init(), since cloud_init() clears the do_command table. #define MKS(x) #x #define MKSTRING(x) MKS(x) cloud_register_target(TARGET_NAME_1, MKSTRING(REQ_VAR_NAME_1), MKSTRING(REPLY_VAR_NAME_1)); cloud_register_target(TARGET_NAME_2, MKSTRING(REQ_VAR_NAME_2), MKSTRING(REPLY_VAR_NAME_2)); cloud_register_target(TARGET_NAME_3, MKSTRING(REQ_VAR_NAME_3), MKSTRING(REPLY_VAR_NAME_3)); _restart: do { rc = cloud_tick(); } while (!rc); printf("Final rc = %d\n", rc); if (rc == -NETERR_ABORT) { // RCI reboot request was received. Normally we would use this // to shut down cleanly and reboot the board. printf("Rebooting via exit(0)!\n"); exit(0); } goto _restart; }
/************************************************************** * FUSE used functions *************************************************************/ /* * Initializes the FUSE file system (cloudfs) by checking if * the mount points are valid, and if all is well, it mounts the * file system ready for usage. * */ void *cloudfs_init(struct fuse_conn_info *conn UNUSED) { cloudfs_debug("init", "start", ""); /* initialize cloud */ S3Status s = cloud_init(system_state->hostname); if (s != S3StatusOK) { cloudfs_debug("init", "fail", ""); } cloud_create_bucket(BUCKET_NAME); /* initialize file storage */ mkdir(resolve_path("/"), 0755); /* initialize file attribute storage */ mkdir(resolve_attr_path("/"), 0755); /* initialize segment cache */ init_segment_cache_layer(); init_segment_hash();