Beispiel #1
0
JNIEXPORT jboolean JNICALL
Java_org_supla_android_lib_SuplaClient_scOpen(JNIEnv* env, jobject thiz, jlong _asc, jint channelid, jint open) {
    
    void *supla_client = supla_client_ptr(_asc);
    
    if ( supla_client )
        return supla_client_open(supla_client, channelid, open) == 1 ? JNI_TRUE : JNI_FALSE;
    
    return JNI_FALSE;
};
int main(int argc, char* argv[]) {

	void *client_loop_t = NULL;

	if ( clientcfg_init(argc, argv) == 0 ) {
		clientcfg_free();
		return EXIT_FAILURE;
	}

	st_mainloop_init();
	st_hook_signals();

	// CLIENT LOOP
	void *sclient = NULL;
	client_loop_t = sthread_simple_run(client_loop, (void*)&sclient, 0);

	// MAIN LOOP

	while(st_app_terminate == 0) {

		if ( kbhit() > 0 ) {
            switch(getch()) {
            case '0':
            	supla_client_open(sclient, 151, 0);
            	break;
            case '1':
            	supla_client_open(sclient, 151, 1);
            	break;
            case '2':
            	supla_client_open(sclient, 151, 2);
            	break;

            case '4':
            	supla_client_open(sclient, 28, 1);
            	break;
            case '5':
            	supla_client_open(sclient, 29, 1);
            	break;
            case '6':
            	supla_client_open(sclient, 30, 1);
            	break;
            }
		}

		st_mainloop_wait(10000);
	}

	// RELEASE BLOCK
	sthread_twf(client_loop_t);
	st_mainloop_free();
	clientcfg_free();

	return EXIT_SUCCESS;

}