/** * See pcsl_network.h for definition. */ int pcsl_network_init_start(void) { javacall_result res; res = javacall_network_init_start(); return javacall_to_pcsl_result(res); }
/** * Performs platform-specific initialization of the networking system. * * @return PCSL_NET_SUCCESS upon success;\n * PCSL_NET_IOERROR for an error */ int pcsl_network_init(void) { javacall_result res; res = javacall_network_init_start(); while (res == JAVACALL_WOULD_BLOCK) res = javacall_network_init_finish(); switch (res) { case JAVACALL_OK: return PCSL_NET_SUCCESS; case JAVACALL_FAIL: return PCSL_NET_IOERROR; } return PCSL_NET_IOERROR; }
/** * send an SMS message * * Actually * - sends a datagramm to 11101 port, it can be received by JSR205Tool.jar (used in TCK tests) * - writes a message to the console (it is enough for native tests) * The address to send datagram is one of the following: * - 127.0.0.1 if JSR_205_DATAGRAM_HOST environment variable is not send * - JSR_205_DATAGRAM_HOST environment variable value (if set). * * Refer to javacall_sms.h header for complete description. */ int javacall_sms_send( javacall_sms_encoding msgType, const unsigned char* destAddress, const unsigned char* msgBuffer, int msgBufferLen, unsigned short sourcePort, unsigned short destPort) { javacall_handle datagramHandle; javacall_result ok; int pBytesWritten = 0; void *pContext; unsigned char *pAddress; javacall_int64 timeStamp = 0; const char* recipientPhone = destAddress; char* senderPhone = "+1234567"; int encodedSMSLength; char* encodedSMS; char* IP_text = getProp("JSR_205_DATAGRAM_HOST", "127.0.0.1"); //JSR205Tool listens on 11101 port, but sends to 11100 port int smsRemotePortNumber = getIntProp("JSR_205_SMS_OUT_PORT", 11101); javacall_network_init_start(); pAddress = getIPBytes_nonblock(IP_text); encodedSMS = encodeSmsBuffer(msgType, destPort, timeStamp, recipientPhone, senderPhone, msgBufferLen, msgBuffer, &encodedSMSLength); ok = javacall_datagram_open(0, &datagramHandle); if (ok == JAVACALL_OK) { ok = javacall_datagram_sendto_start(datagramHandle, pAddress, smsRemotePortNumber, encodedSMS, encodedSMSLength, &pBytesWritten, &pContext); if (ok != JAVACALL_OK) { javacall_print("Error: SMS sending - datagram blocked.\n"); } } javacall_print("## javacall: SMS sending...\n"); javanotify_sms_send_completed(JAVACALL_SMS_SENDING_RESULT_SUCCESS, 13); return 1; }