mergAccessory ios外部是否仅适用于打印机?

时间:2013-06-05 08:09:14

标签: ios livecode externals

在文档中,我们有以下命令。

command mergAccessoryRead pNameAndProtocol,pLength,pCallcackHandler
command mergAccessoryWrite pNameAndProtocol,pData,pCallcackHandler

他们只使用打印机还是一般可以使用?实例

更新2:我被困在mergAccessoryOpenSession上。我认为此案没有开会。

这是我目前的代码。

global pNameAndProtocol
global pData
on preopenstack

   put "xxxx" into pNameAndProtocol
   put "get xxxx" into pData
end preopenstack

command xxxx

   answer pNameAndProtocol
   answer pData   
   printDocket  


end xxxx

on printDocket
   try
      mergAccessoryOpenSession "xxxx","sessionOpen"
      answer "mergAccessoryOpenSession is called..."
   catch someError
      answer "An error on printDocket " &&someError
   end try
end printDocket

on sessionOpen pNameAndProtocol   
   try
      mergAccessoryWrite "xxxx","get xxxx","writeCompleted"
       answer "mergAccessoryWrite is called..."
   catch someError 
      answer "An error on sessionOpen " &&someError
   end try   
end sessionOpen

on writeCompleted pNameAndProtocol   
   try
      mergAccessoryRead pNameAndProtocol,0,"readCompleted"
      answer "mergAccessoryRead is called..."
   catch someError 
      answer "An error on writeCompleted " &&someError
   end try

end writeCompleted

on readCompleted pNameAndProtocol,pData   
      answer "Completed..."   
end readCompleted

1 个答案:

答案 0 :(得分:1)

它们适用于任何蓝牙或附加的硬件配件。您只需要从制造商那里获得协议文档。该演示打印到迷你蓝牙打印机。

on printDocket
   mergAccessoryOpenSession "p25i|com.bluebamboo.p25i","sessionOpen"
end printDocket

on sessionOpen pNameAndProtocol
   mergAccessoryWrite pNameAndProtocol,"UfwàD"&fld "write","writeCompleted"
end sessionOpen

on writeCompleted pNameAndProtocol
   mergAccessoryRead pNameAndProtocol,0,"readCompleted"
end writeCompleted

on readCompleted pNameAndProtocol,pData
   if byte 5 of pData = numToByte(3) and byte 6 of pData = numToByte(0) then
      answer "print complete"
      mergAccessoryCloseSession pName
   end if
end readCompleted

修改

经过一段相当长的支持事件,我在这里解决了这个问题。当打开一个答案对话框时,似乎来自外部的回调没有排队,他们只是迷路了,永远不会被执行。因此,当您期望来自外部人员的回调时,请不要使用答案对话框。我在引擎论坛上打开了这个帖子,看看是否有解决方案:http://forums.runrev.com/viewtopic.php?f=66&t=15602