[Q] New to python program fault - General Questions and Answers

Can anyone help why this PYTHON program will not work
import random
def is_same(target, number):
if target == number:
result= "Win"
elif target > number:
result = "Low"
else:
result="High"
return result
level = input("What level do you want to play? Easy (e), Medium (m) or Hard (h)")
computer_number = random.randint(1,level)
if level== "e":
level=10
elif level== "m":
level= 20
elif level== "h":
level= 30
while level != "e" and level != "m" and level != "h":
level= input("Sorry. You must type in one of the letters 'e','m' or 'h'\ne/m/h:")
print("Hello. \nI Have thought of a number between 1 and 100.")
guess = int(input("Can you guess it?\n"))
correct_guess = is_same(computer_number, guess)
while correct_guess != "Win":
if correct_guess == "Low":
guess = int(input("Sorry you are too low. Try Again.\n"))
else:
guess = int(input("Sorry you are too high. Try again.\n"))
correct_guess = is_same(computer_number, guess)
input("Correct!\nWelldone\n\nPress RETURN to exit")

Related

Audio recording. Error in source code

When I'm trying initialize VoiceRecorder I have error:
error LNK2019: unresolved external symbol VoiceRecorder_Create referenced in function "public: void __cdecl test2Dlg.obj
Ctest2Dlg::OnBnClickedButton3(void)" ([email protected]@@QAAXXZ)
CM_VOICE_RECORDER cmvr;
memset( &(cmvr), 0, sizeof(cmvr));
cmvr.cb = sizeof (CM_VOICE_RECORDER);
cmvr.dwStyle = VRS_NO_MOVE;
cmvr.xPos = -1; //-1 means control is drawn centered to Parent window hwndMain
cmvr.yPos = -1;
cmvr.hwndParent = m_hWnd;
cmvr.id = NULL;
cmvr.lpszRecordFileName = TEXT("\\My Documents\\TestRec.wav");
DeleteFile(L"\\My Docuemnts\\TestRec.wav");
DeleteFile(L"\\My Documents\\~Rec_0.wav");
HWND hwndVoice = VoiceRecorder_Create (&cmvr); //Error in this line
::ShowWindow(hwndVoice, WS_VISIBLE);
::UpdateWindow(hwndVoice);
Help me please

[Q] choose array-elements with certain probability

hello,
I'm writing a Android App (java) - but I guess this question is pretty general, and isn't java-specific:
so I have an Array of Elements
and I let a random-number-generator pick one array-element randomly and hand it to me.
now I've also built in a "score"-field into each array Element
so what I want to do now, is that the random-number-generator takes the array's "score" in consideration, and gives me the array-elements with the higher/lower scores with a higher/lower probability
I dont want it to ALWAYS/NEVER give me the elements with the highest/lowest score - just with a higher/lower probability
I hope I could describe my problem in a proper way....
does anybody know how to achieve this?
(as I said, i use java, but i guess code in any language - or even pseudo-code would help me out)
*bump*
anybody?
Try this, it's in C# but it's pretty close to Java.
You cannot directly weight the random function so you have to use a different method.
By applying a weight to each item in the array, then using a random function to select using the weighting values, the results of the selection can be swayed.
The weighting values are relative to each other.
Using the values in the code, 'B' should turn up about three times more often than 'A'
The only object that may need some explanation is Random:
http://msdn.microsoft.com/en-us/library/system.random(v=VS.80).aspx
Code:
using System;
namespace RandomWeighting
{
class Program
{
static void Main(string[] args)
{
char[] Select = new char[10] {'A','B','C','D','E','F','G','H','I','J'};
int[] Weight = new int[10] {10,30,25,60,20,70,10,80,20,30};
int[] WeightSum = new int[10];
int i,j,k;
Random Rnd = new Random();
WeightSum[0]=Weight[0];
for (i = 1; i < 10; i++)
WeightSum[i] = WeightSum[i - 1] + Weight[i];
for (j = 0; j < 70; j++)
{
k = Rnd.Next(WeightSum[9]);
for (i = 0; k > WeightSum[i]; i++) ;
Console.Write(Select[i]);
}
Console.WriteLine();
}
}
}
Output:
Code:
HEFIBHHCCFBCAEFFDHACHBEJHHFDFIDFEDFFCHHDJBIDJEHHFHCJJJBHJGBDDGFDDFHHHB
Note the low density of A and G as opposed to H
It is just a sample at random, but 2 'A's and 7 'B's roughly matches the conjecture above, but over a million selections, the distribution is as follows:
Code:
A 30664
B 84187
C 70648
D 168481
E 56529
F 197311
G 28145
H 225764
I 56613
J 81658
If your code changes values in the Weight array then the WeightSum array must be recalculated.
wow, thats a lot!
The only thing I dont understand about the code is this line:
k = Rnd.Next(WeightSum[9]);
for (i = 0; k > WeightSum; i++) ;
what exactly happens here?
what kind of a for-loop is this?
why is there no body?
and strangely, while debugging this line, i noticed that the value of i jumps to some random number in this line - and I have no idea why and how
------
by the way: I've already tried it out, it works pretty good.
although I noticed that the first element always gets picked ALOT, no matter how low the weight.
I think thats a flaw in the algorithm
After the following code:
Code:
for (i = 1; i < 10; i++)
WeightSum[i] = WeightSum[i - 1] + Weight[i];
The WeightSum array contains the following values:
Code:
[0] 10
[1] 40
[2] 65
[3] 125
[4] 145
[5] 215
[6] 225
[7] 305
[8] 325
[9] 355
The Random.Next() function that takes a single integer as an argument is defined as:
-------- Courtesy of MS VS .NET Help ------
public virtual int Next(int maxValue)
Parameters maxValue Type: System.Int32
The exclusive upper bound of the random number to be generated. maxValue must be greater than or equal to zero.
Return Value Type: System.Int32
A 32-bit signed integer greater than or equal to zero, and less than maxValue; that is, the range of return values ordinarily includes zero but not maxValue. However, if maxValue equals zero, maxValue is returned.
-------------- End of Help ----------------
So, we are asking for a random value between 0 and 354,(element WeightSum[9] above). The following code then finds which is the lowest element of WeightSum which holds a value greater than the one we have been given. When this happens 'i' contains the index to use for the selection.
Code:
for (i = 0; k > WeightSum[i]; i++);
The standard construction of a for loop in C is
for(One or more initialisation statements; Do_While_True Condition; One or more iteration statements)
{
loop processing code;
}
If there is nothing to do in the loop body, you don't need it, and you can replace it with the ';' at the end of the for statement. In effect, it is identical to the following code:-
Code:
i=0;
while(k > WeightSum[i])
{
i++;
}
As regards the first element being picked more than the others, have a look at the distribution table in post #3. It is what you would expect for the values given. I assume the difference is either the Random function in Java or some different implementation between C# and Java.
You may have to change some of the code slightly, i.e. change the for() loop to the while() loop above and step though it in the Java debugger to get to the root of the problem.
You can't debug a for loop followed by an immediate ';' The entire for loop is executed to completion when you use debug and try and step through it. To debug it place a dummy statement in the for loop. A breakpoint may now be set on this line.
Code:
int i,z;
for (i = 0; k > WeightSum[i]; i++)
{
z=0;
}
ActionScript and Javascript versions ...
Thanks for the great write-up! In case anyone is interested, I've adapted this into a javascript and ActionScript class. If anyone is interested, I've attached the code. For a more in-depth post, check out blog.teamthinklabs.com.
Cheers!
Kipp Ashford
Art Director
Seven2 Interactive

[DEV] Overclock device! Need a team to work. Work finished.

Hi there, many of you would know me.
I am back after a short while, well actually I am here just to help you guys with overclocking. Neither do I have any resource such as high end cpu or hdd space to compile a kernel nor do I have a stable galaxy y as of NOW.
Now all the mathematics and programming geniuses, I need you all here. I am inviting all the developers who can ACTUALLY help. No questions from someone who has just started or something like that. For them I suggest you read a lot about processors first.
The overclock that developers till now have achieved as you all know, DOES NOT INCREASE MFLOPS.
After studying a lot about the arm11 processors. I know that the freq values we set are only the freq which are visible to users in apps. They are just registered so that users can view them as working.
ONLY PROCEED BELOW IF YOU KNOW ABOUT PROGRAMMING.
People who know about programming but not about ARM architecture visit this link : http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0328e/CHDEHCAB.html
Now there are two critical values which define the val, they are m_set and n_set.
The freq table that we create is just an imposture to the real clock. If you study msm boards then you'll notice they feed in the values as *speed->clk=x 000 (converts to mhz). We don't have a clock-21553.c in that manner.
Rather we have this.
long bcm21553_uart_find_m_n(unsigned long freq_val, long *m_set, long *n_set)
{
long factor = 0; /* = m/n */
long eq_2_val = MAX_UART_M_VAL + MAX_UART_N_VAL;
long n_val = 0;
long long n_iter = 0;
long long m_iter = 0;
long long left = 0;
long long right = 0;
long long diff = 0;
long long least_diff = 0;
long long least_diff_m_iter = 1;
long long least_diff_n_iter = 1;
long long val = 0;
long ret_val;
/* Formula : Freq = (156MHz * n) / m. */
if (freq_val > FREQ_MHZ(156)) { /* Can't have freq greater than 156MHz. */
return -EINVAL;
} else if (freq_val == FREQ_MHZ(156)) {
*m_set = *n_set = 1;
return FREQ_MHZ(156);
}
*m_set = 0;
*n_set = 0;
factor = FREQ_MHZ(156) / freq_val;
/* range of m : 0 <= m <= 0x1ff */
/* range of n : 0 <= n <= 0x1ff */
/* Equation 1 : factor = m /n. */
/* so m = (factor * n). */
/* Equation 2 : m + n <= 0x1ff + 0x1ff. */
/* m + n <= (2 * 0x1ff) ; Let's call (2 * 0x1ff) as eq_2_val. */
/* so m + n <= eq_2_val. */
/* Substiture eq1 in eq2. */
/* (factor * n) + n <= eq_2_val. */
/* taking n common : */
/* (factor + 1) * n <= eq_2_val. */
/* so n <= eq_2_val / (factor + 1). <==== This is a very important conclusion. */
/* Now the logic is to iterate(iter) till n, and
* find a value of m, where m = 156MHz * iter / val. */
n_val = eq_2_val / (factor + 1);
pr_info("n_val = %ld, eq_2_val = %ld, factor = %ld\n", n_val, eq_2_val,
factor);
n_iter = 0;
diff = 1;
least_diff = 0xffffffff;
val = freq_val;
while ((n_iter <= n_val) && (diff != 0)) {
n_iter++;
left = FREQ_MHZ(156) * n_iter;
m_iter = 0;
while ((m_iter <= MAX_UART_M_VAL) && (diff != 0)) {
m_iter++;
right = val * m_iter;
/* Always left side must be greater than right. So diff has to be positive. */
diff = left - right;
if ((diff > 0) && (diff < least_diff)) {
least_diff = diff;
least_diff_m_iter = m_iter;
least_diff_n_iter = n_iter;
}
/* pr_info("n_iter = %lld, m_iter = %lld, left = %lld, \
right = %lld, diff = %lld, least_diff = %lld, \
least_diff_m_iter = %lld, \
least_diff_n_iter = %lld\n",
n_iter, m_iter, left, right, diff, least_diff,
least_diff_m_iter, least_diff_n_iter); */
}
}
/* if diff == 0, it means we found a perfect, m, and n value. */
if (diff == 0) {
/* pr_info("We found the correct, m, n values. \
m = %lld, n= %lld\n", m_iter, n_iter); */
*m_set = m_iter;
*n_set = n_iter;
return val;
} else {
/* This means we didn't find a good m,n value. */
*m_set = least_diff_m_iter;
*n_set = least_diff_n_iter;
ret_val = (((FREQ_MHZ(156) / *m_set)) * *n_set);
/* pr_info("Didn't find a perfect m, n value, but will given \
the nearest possible value. m = %lld, n = %lld, \
freq = %ld\n", least_diff_m_iter,
least_diff_n_iter, ret_val) ; */
return ret_val;
}
}
NO SPAMMING IN THIS THREAD.
Stakes were high, time was taken but finally the work is completed, goal achieved.
Now might be a good time to say that we are a COMMUNITY, we help each other to make one device better.
Also could be a good time to take a new initiative, to take up something new as a project.
Reserved.
Trying something new and good.
Uhm maybe you should put that part in code.
Only reported programmers will be considered in the team.
REAL PROGRAMMERS WHO WANT TO JOIN, please post here and do not pm me.
By far the team is :
Master_Key
Mohamed.Anwar
hell_lock
ZakooZ
......
------R-------E------S-----E-----R------V------E------D-------P-----O---S---T------------B---Y--------S-----H-------A--------N--------E
bY
ShAnE
Looks promising
While I do know a decent bit about programming I don't know much about how CPUs work if you know what I mean
But I'll try to have a look at that
Re: [DEV] {WIP} Overclock device! Need a team to work.
Im in.
Sent from my GT-S5360 using XDA
hell_lock said:
Im in.
Sent from my GT-S5360 using XDA
Click to expand...
Click to collapse
+me
---------- Post added at 05:17 PM ---------- Previous post was at 04:34 PM ----------
What I got so far is
factor => 1
FREQ_MHZ(156)*n_iter - (val*m_iter) == 0
n_val => 255.5
am I correct ?
Btw : we need better format of these codes sometimes I get lost
Mohamed.Anwar said:
+me
---------- Post added at 05:17 PM ---------- Previous post was at 04:34 PM ----------
What I got so far is
factor => 1
FREQ_MHZ(156)*n_iter - (val*m_iter) == 0
n_val => 255.5
am I correct ?
Btw : we need better format of these codes sometimes I get lost
Click to expand...
Click to collapse
n_val for FREQ_MHZ(156) is (2*eq_2_val)/(m/n+1) = (2*0x1ff)/(1/1+1) = 0x1ff = 511
You can find proper highlighting and formatting here
How does the frequency translate to the real world freq? I'm assuming FREQ_MHZ(156) is either 832mhz or 1248mhz...
Somewhat interestingly, 0x1ff is 11111111 in binary... So wouldn't any number & 0x1ff equal the number?
Edit: Seems like it's made to return the first byte of a (4-byte) int... I think
Tested and it returns the last byte in little endian ordering
ZakooZ said:
n_val for FREQ_MHZ(156) is (2*eq_2_val)/(m/n+1) = (2*0x1ff)/(1/1+1) = 0x1ff = 511
You can find proper highlighting and formatting here
How does the frequency translate to the real world freq? I'm assuming FREQ_MHZ(156) is either 832mhz or 1248mhz...
Somewhat interestingly, 0x1ff is 11111111 in binary... So wouldn't any number & 0x1ff equal the number?
Edit: Seems like it's made to return the first byte of a (4-byte) int... I think
Tested and it returns the last byte in little endian ordering
Click to expand...
Click to collapse
Sorry forgot the 2 in 2*0x1ff
Anyway... changing the val and ret_val would be useless... As only n and m are put in memory
regVal = (u32) n_set & 0x1FF;
writel(regVal, ADDR_CLKPWR_CLK_UARTB_N);
regVal = (u32) m_set & 0x1FF;
writel(regVal, ADDR_CLKPWR_CLK_UARTB_M);
^ either first of last byte of the n and m values are put in memory. (Don't know the difference between UART A B and C)
Seems like ret_val returns the closest possible frequency if the m and n values aren't "good"
What we need to change is n and m... And apparently the highest they can be is 1
Need to know what calls bcm21553_uart_set_rate() and what "val" values it uses... Supposedly a modified value of the real (832mhz,etc) frequencies
Technically we could call it with FREQ_MHZ(156) and see what happens... but that's pretty dangerous
Re: [DEV] {WIP} Overclock device! Need a team to work.
ZakooZ said:
Anyway... changing the val and ret_val would be useless... As only n and m are put in memory
regVal = (u32) n_set & 0x1FF;
writel(regVal, ADDR_CLKPWR_CLK_UARTB_N);
regVal = (u32) m_set & 0x1FF;
writel(regVal, ADDR_CLKPWR_CLK_UARTB_M);
^ either first of last byte of the n and m values are put in memory. (Don't know the difference between UART A B and C)
Seems like ret_val returns the closest possible frequency if the m and n values aren't "good"
What we need to change is n and m... And apparently the highest they can be is 1
Need to know what calls bcm21553_uart_set_rate() and what "val" values it uses... Supposedly a modified value of the real (832mhz,etc) frequencies
Technically we could call it with FREQ_MHZ(156) and see what happens... but that's pretty dangerous
Click to expand...
Click to collapse
FREQ_MHZ(156) = exact 156 000 000 Hz. You can check it by putting it in the arm11_set_rate function. Instead of putting appspll*2/3 directly put FREQ_MHZ(832) and you'll get the same result.
Yeap. If exact match aren't found then ret val is used.
Most developers were thinking of adding 1024 mhz, this won't be a perfect n and m value.
To actually set the 1024 we need to get to know the iteration more.
Set rate uses the values from get rate. The arm 11 freq developers set till now was in some other static function which did not actually change the clock.
Sent from my GT-S5360 using xda app-developers app
I used this post to dump information I was getting and save it in somewhere that is not in the middle of thousands of lines of code... So It's a bit messy
I've been doing some searching and it looks like all thing referencing find_n_m() are only defined and never actually used to set any frequencies... So I don't know if that's the way to go... It may still use n and m values but calculated elsewhere
bcm21553_arm11_set_rate() and bcm21553_arm11_round_rate()
People have been using these for frequencies for a long time, it works for 156mhz and 624mhz which is interesting... Why wouldn't it work for freqs over 832mhz?
bcm21553_arm11_set_rate() imports a *clk pointer but never uses it... All it does is set the mode for the frequency with bcm215xx_set_armahb_mode()... I'm not discussing it now as im inspecting other parts
bcm21553_arm11_round_rate(clk *clk, long desired_val) also imports *clk but never uses it. It returns bcm21553_generic_round_rate(desired_val,arm11_freq,2);
I don't know where they get desired_val, but that's important for the return
arm11_freq is the frequencies developers defined
2 is the count of arm11_freq arrays... could use sizeof(arm11_freq)/sizeof(u32) i suppose
Code:
int bcm21553_arm11_set_rate(struct clk *clk, unsigned long val)
{
u32 mode;
u32 arm11_freq[2];
u32 apps_pll_freq = bcm21553_apps_pll_get_rate();
arm11_freq[0] = FREQ_MHZ(312);
arm11_freq[1] = (apps_pll_freq*2)/3;
/*we support only two modes - 0xC & 0xF*/
if (val == arm11_freq[0])
{
mode = 0x0C;
}
else if (val == arm11_freq[1])
{
mode = 0x0F;
} else
{
return -EINVAL;
}
//writel(mode, ADDR_CLKPWR_CLK_ARMAHB_MODE);
bcm215xx_set_armahb_mode(mode);
return 0;
}
long bcm21553_arm11_round_rate(struct clk *clk, unsigned long desired_val)
{
u32 arm11_freq[2];
u32 apps_pll_freq = bcm21553_apps_pll_get_rate();
/*we support only two freq - 312Mhz & appPll/1.5*/
arm11_freq[0] = FREQ_MHZ(312);
arm11_freq[1] = (apps_pll_freq*2)/3;
return (long)bcm21553_generic_round_rate(desired_val,
arm11_freq,
2);
}
Code:
u32 bcm21553_generic_round_rate(u32 desired_val, const u32 *supportedFreqList,
u8 count)
{
u32 i = 0;
const u32 *ppossible_freqs = supportedFreqList;
u32 closest_freq = 0xFFFFFFFF; /* Set it to some highest value. */
u32 greatest_freq_in_array = 0;
while (i < count) {
if (desired_val == *ppossible_freqs) {
return desired_val;
} else {
if ((*ppossible_freqs > desired_val)
&& (*ppossible_freqs <= closest_freq)) {
closest_freq = *ppossible_freqs;
}
if (*ppossible_freqs > greatest_freq_in_array) {
greatest_freq_in_array = *ppossible_freqs;
}
}
i++;
ppossible_freqs++;
}
/* This means that desired_val is greater than the maximum possible values */
if (closest_freq == 0xFFFFFFFF) {
/* This means the desired_val is greater than the greatest element */
/* So lets return with the greatest freq in array. */
return greatest_freq_in_array;
} else {
return closest_freq;
}
}
It seems that people are just giving a list of the supported frequencies, but those are not the desired frequency that this last function tries to search for... maybe it wont search for anything higher than 832mhz, it will always return something lower
Meanwhile arm11_set_rate doesn't seem to be connected to this at all, and arm11_round_rate seems to be returning the frequencies to some place that gives them a desired frequency
Anyway I can't seem to find any implementation of bcm215xx_set_armahb_mode(), only a "extern void bcm215xx_set_armahb_mode(u32 mode);" line Looks like it's implemented in Assembly! Fun! Either that is normal for low level stuff or broadcom wants to "encrypt" us out of how this works
I'll edit this post later because at the moment I don't feel like looking at this
Re: [DEV] {WIP} Overclock device! Need a team to work.
Yeap exactly!
There are values not used and there are values which we seem not to find.
The max n and m values have a different variable name which is defined at the start of file before any function is run.
It is somewhat
#Define variable name
This is used no where except this line where it is defined.
The set rate and get rate of arm 11 are just values which developer wants to get registered. The clock does not go above 832. If you use mode 0xD max value you get at 1248 is 832 mips. Mode 0xE 1248 set then 1248 mips. Mode 0xF 1248 set then 1665 mips.
I suppose the set rate only makes array and nothing else. To set above 832, theres still some part untouched.
Sent from my GT-S5360 using xda app-developers app
If you ctrl+F in /common, the only references to bcm21553_arm11_round_rate() and bcm21553_arm11_set_rate() are in clock-21553.c
How the f is that possible... They have to be called somewhere, even if it's just to get the fake rates
Re: [DEV] {WIP} Overclock device! Need a team to work.
Need testers for testing kernel.
Need a developer who can pack the z image I providE.
Any help would be appreciated.
Sent from my GT-S5360 using xda app-developers app
Re: [DEV] {WIP} Overclock device! Need a team to work.
Master_Key said:
Need testers for testing kernel.
Need a developer who can pack the z image I providE.
Any help would be appreciated.
Sent from my GT-S5360 using xda app-developers app
Click to expand...
Click to collapse
Contact hell_lock
I can test it
Sent from my GT-S5360 using xda premium
Re: [DEV] {WIP} Overclock device! Need a team to work.
I can test it...
Sent from my GT-S5360 using xda app-developers app
hears like a nice projekt,i test too when needet.
Master_Key said:
Need testers for testing kernel.
Need a developer who can pack the z image I providE.
Any help would be appreciated.
Sent from my GT-S5360 using xda app-developers app
Click to expand...
Click to collapse
I can pack it

non-static variable

Hello,
I got this error https://gerrit.omnirom.org/#/c/3918/11/packages/SystemUI/src/com/android/systemui/quicksettings/BatteryTile.java
frameworks/base/packages/SystemUI/src/com/android/systemui/quicksettings/BatteryTile.java:117: non-static variable SHOW_100_PERCENT cannot be referenced from a static context
boolean batteryHasPercent = BatteryMeterView.SHOW_100_PERCENT;
SOLUTION
int batteryStyle = Settings.System.getIntForUser(mContext.getContentResolver(),
Settings.System.STATUS_BAR_BATTERY, 0, UserHandle.USER_CURRENT);
boolean batteryHasPercent = batteryStyle == BatteryMeterView.BATTERY_STYLE_PERCENT;

SMS AT commands doesnt work on my android device C++ | Bluetooth | winsock

Hi there!
I'm creating windows application in C++, which connect's PC with mobile via bluetooth and winsock. Allow's you to call and send messages from mobile via computer.
I'm using AT command's to tell mobile what i want to do. Pair with mobile device and force a call with At command
ATD+420******;
works perfect, but all commands for handling SMS like
AT+CMGL, AT+CMGF, AT+CMGS etc.
return's ERROR.
Here is code which connects PC with mobile via bluetooth and socket:
SOCKADDR_BTH RemoteEndPoint;
RemoteEndPoint.port = 0;
RemoteEndPoint.addressFamily = AF_BTH;
RemoteEndPoint.btAddr = m_foundDevices[m_deviceIndex].Address.ullLong;
RemoteEndPoint.serviceClassId = HandsfreeServiceClass_UUID;
int BTHAddrLength = sizeof(RemoteEndPoint);
// Create the socket.
if ((m_localSocket = socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM)) == INVALID_SOCKET)
{
// handle error.
}
// Connect the socket.
if ((iResult = connect(m_localSocket, (SOCKADDR *)&RemoteEndPoint, sizeof(RemoteEndPoint))) == INVALID_SOCKET)
{
// handle error.
}
Notice line
Hide Copy Code
RemoteEndPoint.serviceClassId = HandsfreeServiceClass_UUID
I think the problem is here, becouse u cant send sms from Handsfree, but when i use another UUID, it doesnt even pair with mobile.
=== Here is just for info, how am i sending and receiving data from mobile ===
char recvbuf[DEFAULT_BUFLEN] = "";
const char *sendbuf = "AT+CMGL\r";
int len = (int)strlen(sendbuf);
if ((iResult = send(m_localSocket, sendbuf, len, MSG_OOB)) == SOCKET_ERROR)
{
// handle error. return ~0
}
if ((iResult = recv(m_localSocket, recvbuf, recvbuflen, 0)) == SOCKET_ERROR)
{
// handle error. return ~0
}
// Here recvbuf == "\r\nERROR\r\n"
Thank you for any advices! If you have any question's about problem, i'll kindly explain.
Regards,
Ferina.

Categories

Resources