i am having this problem related to function implementation. my program is about sending an unread sms string to a bluetooth module and after sending the strings of sms messages it will mark the unread messages as read then move to a sms notification function that will notify me is there is an incoming sms messages after that the unread message will be sent to the bluetooth module as string again and mark the unread message as read. this is the problem after sending the sms string it does not do the function of marking the sms as read anymore hope somebody will help me here.

here is the flow of program that must be implemented:
Bluetooth>send unread sms string to BT>mark read>sms notification[if there is incoming sms]>send unread sms string to BT>mark read> then the cycle goes but i have a problem succeeding mark read.

here is the code:

import appuifw
import socket
import e32
import inbox,string
from time import ctime
import codecs
import os
import e32
from appuifw import *
import bluetooth

inb = inbox.Inbox()
sms_ids = inb.sms_messages()
msgs = []
msg_unread = []
msg_read = []


def bt_connect():
global sock
sock=socket.socket(socket.AF_BT,socket.SOCK_STREAM)
target=''
if not target:
address,services=socket.bt_discover()
print "Discovered: %s, %s"%(address,services)
if len(services)>1:
import appuifw
choices=services.keys()
choices.sort()
choice=appuifw.popup_menu([unicode(services[x])+": "+x
for x in choices],u'Choose port:')
target=(address,services[choices[choice]])
else:
target=(address,services.values()[0])
print "Connecting to "+str(target)
sock.connect(target)
print "OK."

bt_sendtext()

def bt_sendtext():
global sock

box=inbox.Inbox()
id=box.sms_messages()

for item in id:
if box.unread(item):
j=box.address(item)
d=(u'from '+j+' ')[:160]
print d
b=box.content(item)
c=(b+'\0')[:160]
print c
sock.send(d)
sock.send(c)

markread()

smsnoti()

def markread():
inb = inbox.Inbox()
sms_ids = inb.sms_messages()
for id in :
msgs.append(inb.content(id))

def setreadunread(message, status):
global msgs
i = 0
for msg in msgs:
if message == msg:
if status == 1:
inb.set_unread(sms_ids,1)
else:
inb.set_unread(sms_ids,0)
i = i+1

def get_readandunreadmessages_inlist():
global msg_unread
global msg_read
msg_unread = []
msg_read = []
for id in sms_ids:
if inb.unread(id):
msg_unread.append(inb.content(id))
else:
msg_read.append(inb.content(id))


def setmessageread():
global msg_unread
get_readandunreadmessages_inlist()
try:
i=0
while (i != msg_unread):
setreadunread(msg_unread, 0)
i=i+1
except IndexError, e:
print "Done"

def showmessagestatus():
global sms_ids
for id in sms_ids:
print inb.content(id)[:20]
print inb.unread(id)


def smsnoti():
def message(msgid):
box = inbox.Inbox()
bt_sendtext()
app_lock.signal()

box = inbox.Inbox()
box.bind(message)

app_lock = e32.Ao_lock()
app_lock.wait()

appuifw.app.title = u"bt mob to PC"
bt_connect()

Recommended Answers

All 4 Replies

Post with code tags again, indentation lost.

here is the code pls help me

I recommend that you place print statements in various places in your code, so that you can find the actual place of the issue. It may not be the function that is not working, it could be one of your if() statements or whatever. Work through your code, so that you can work out if you actually get to the right place in the code.

Hope this makes sense
SgtMe

Well thanks very much i was able to do it...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.