As far as I can tell, calling bt_advertise_service() with a 'False' flag should stop advertising a service. But if I run the snippet below, it will start advertising the service, but the service does not get removed after the last call to bt_advertise_service(). (So, if I run this code a few times, it advertises duplicate services with the same name and channel.)
Do other people have this problem? I am running PyS60 1.3.1 final. I am not sure whether this is a problem on other versions.
Thanks very much,
SERVICE_NAME = u"My Service"
s = socket.socket(socket.AF_BT, socket.SOCK_STREAM)
p = socket.bt_rfcomm_get_available_server_channel(s)
print "Advertising service '%s'" % SERVICE_NAME
socket.bt_advertise_service(SERVICE_NAME, s, True, socket.OBEX)
print "Stopping service"
socket.bt_advertise_service(SERVICE_NAME, s, False, socket.OBEX)
print "Closing socket"