小编nor*_*gen的帖子

Mac到蓝牙设备文件传输,简单示例?

我花了两天的时间在谷歌上搜索并阅读了《蓝牙编程指南》,同时试图拼凑一个小型Mac应用程序,该应用程序将从放置文件夹中检索图像并将任何新文件通过蓝牙发送到预定的设备。似乎没有很多好的例子。

我现在可以生成蓝牙服务浏览器并选择设备及其OBEX服务,建立服务并创建连接,但是接下来什么也没有发生。谁能指出我的方向/向我展示一个简单的例子?

随附AppDelegate源代码。谢谢阅读!

#import“ AppDelegate.h”

@implementation AppDelegate

-(void)applicationDidFinishLaunching:(NSNotification *)aNotification {

    IOBluetoothServiceBrowserController *浏览器= [IOBluetoothServiceBrowserController serviceBrowserController:0];
    [浏览器runModal];

    // IOBluetoothSDPServiceRecord
    IOBluetoothSDPServiceRecord * result = [[浏览器getResults] objectAtIndex:0];
    [自我描述:结果];

    如果([[result.device.name substringToIndex:8] isEqualToString:@“ Polaroid”]){
        打印机= result.device;
        serviceRecord =结果;
        [self testPrint];
    }
    其他{
        NSLog(@“%@不是有效的设备”,result.device.name);
    }
}

-(void)testPrint {
     currentFilePath = @“ / Users / oyvind / Desktop / _DSC8797.jpg”;
    [self sendFile:currentFilePath];
}

-(void)sendFile:(NSString *)filePath {
    IOBluetoothOBEXSession * obexSession = [[IOBluetoothOBEXSession alloc] initWithSDPServiceRecord:serviceRecord];

    if(obexSession!= nil)
    {
        NSLog(@“已建立OBEX会话”);

        OBEXFileTransferServices * fst = [OBEXFileTransferServices withOBEXSession:obexSession];
        OBEXDelegate * obxd = [[[OBEXDelegate …

macos cocoa bluetooth objective-c iobluetooth

5
推荐指数
1
解决办法
2289
查看次数

如何使用mocha监视,编译和测试依赖于save的coffeescript

我正在开发一个使用coffeescript进行开发和测试的项目.我在节点中使用mocha的--watch标志运行测试,这样我可以在进行更改时自动运行测试.

虽然这在某种程度上起作用,但只有./test/test.*.coffee文件在保存时才会重新编译.这是我的目录结构:

/src/coffee
-- # Dev files go here
/test/
-- # Test files go here
Run Code Online (Sandbox Code Playgroud)

mocha观察者响应/ src和/ test目录中的文件更改,但只要重新编译/ test目录中的文件,连续测试就会受到严重影响.如果我退出并重新启动观察程序进程,则还会重新编译源文件.我如何让mocha让咖啡编译器在每次运行时运行在测试文件中作为依赖项列出的开发文件?

tdd unit-testing mocha.js node.js coffeescript

3
推荐指数
1
解决办法
7928
查看次数