--[[
ģƣ绰
ģ鹦ܣԵ绰д
ģ޸ʱ䣺2017.05.23
]]

module(...,package.seeall)
require"pb"

--[[
print
  ӡӿڣļедӡtestǰ׺
  
ֵ
]]
local function print(...)
	_G.print("test",...)
end

--[[
storagecb
  õ绰洢Ļص
  
		resultýtrueΪɹΪʧ
ֵ
]]
local function storagecb(result)
	print("storagecb",result)
	--ɾ1λõĵ绰¼
	pb.deleteitem(1,deletecb)
end

--[[
writecb
  дһ绰¼Ļص
  
		resultдtrueΪɹΪʧ
ֵ
]]
function writecb(result)
	print("writecb",result)
	--ȡ1λõĵ绰¼
	pb.read(1,readcb)
end

--[[
deletecb
  ɾһ绰¼Ļص
  
		resultɾtrueΪɹΪʧ
ֵ
]]
function deletecb(result)
	print("deletecb",result)
	--д绰¼1λ
	pb.writeitem(1,"name1","11111111111",writecb)
end

--[[
readcb
  ȡһ绰¼Ļص
  
		resultȡtrueΪɹΪʧ
		name
		number		
ֵ
]]
function readcb(result,name,number)
	print("readcb",result,name,number)
end


local function ready(result,name,number)
	print("ready",result)
	if result then
		sys.timer_stop(pb.read,1,ready)
		--õ绰洢SMʾsim洢MEʾն˴洢2е1вԼ
		pb.setstorage("SM",storagecb)
		--pb.setstorage("ME",storagecb)
	end
end

--ѭʱֻΪжPBģǷready
sys.timer_loop_start(pb.read,2000,1,ready)
