import camera, e32, socket, appuifw def cn(x):return x.decode("utf8") PHOTO = u"e:\Images\bt_photo_send.jpg" def send_photo(): try: address, services = socket.bt_obex_discover() except: appuifw.note(cn("蓝牙传送不可用"), "error") return if u'OBEX Object Push' in services: channel = services[cn('蓝牙传送照片')] socket.bt_obex_send_file(address, channel, PHOTO) appuifw.note(cn("照片已发送"), "info") else: appuifw.note(cn("蓝牙传送不可用"), "error") def take_photo(): photo = camera.take_photo() canvas.blit(photo, scale = 1) photo.save(PHOTO) def quit(): app_lock.signal() canvas = appuifw.Canvas() appuifw.app.body = canvas appuifw.app.exit_key_handler = quit appuifw.app.title = cn("蓝牙发送照片") appuifw.app.menu = [(cn("拍照"), take_photo),(cn("发送照片"), send_photo)] app_lock = e32.Ao_lock() app_lock.wait()