小编pek*_*u33的帖子

嗅探/记录您自己的Android蓝牙流量

我最近买了通过蓝牙与Android手机/平板电脑连接的中文设备.由于没有适用于windows/linux的应用程序,我想创建一个供个人使用的应用程序.

通常手机连接到设备并交换一些数据.我将PC连接到设备并查看串行调试器并进行管理以发现协议(仅限一种方式).电话仅向设备发送一个命令.但是这次我无法找出它包含的内容.

有没有软件可以让我查看通过蓝牙发送的数据?我试过反编译应用程序,但它看起来真的很不友好.

谢谢.

android reverse-engineering bluetooth

68
推荐指数
2
解决办法
10万
查看次数

为什么shared_timed_mutex在c ++ 14中定义,而shared_mutex在c ++ 17中定义?

C++ 11介绍std::mutex及其扩展版本 - std::timed_mutex.

但是,在c ++ 14中我们有std::shared_timed_mutex,但它的'父',std::shared_mutex将在c ++ 17中添加.

对此有任何合理的解释吗?

如果我不打算使用"定时"功能std::shared_timed_mutex,它会比提议更糟糕(更慢,消耗更多资源)std::shared_mutex吗?

c++ std c++14 c++17

22
推荐指数
1
解决办法
3200
查看次数

在打印时将每页上的自定义页脚粘贴到底部

我想要打印30页,其中一些数据位于顶部,一些数据位于底部.我的代码看起来像:

<...>



<div style="page-break-after: always">
    <div>This should be on top1</div>
    <div>This should be on bottom1</div>
</div>
<div style="page-break-after: always">
    <div>This should be on top2</div>
    <div>This should be on bottom2</div>
</div>


<etc>
Run Code Online (Sandbox Code Playgroud)

我尝试了一切:

  • 位置:相对(无变化),绝对(仅限第一页页脚),固定(仅限最后一页)
  • 将html,body,每个div高度设置为100%.没有想法我为什么要这样做.没有改变什么

也许有办法强制我的浏览器(FF)将div粘贴到页面底部

html css

14
推荐指数
2
解决办法
3万
查看次数

如何将click事件绑定到角度为2的整个组件(aka:host)

我有一个ContainerComponent包含一些孩子的容器组件ChildComponent,用*ngFor生成

ContainerComponent 模板:

<div class="child" *ngFor="let child of children">
    <child [child]="child"></child>
</div>
Run Code Online (Sandbox Code Playgroud)

ChildComponent 模板:

<h2>{{child.name}}</h2>
<h2>{{child.data}}</h2>
Run Code Online (Sandbox Code Playgroud)

对于ChildComponent,我定义了一个样式表,我可以使用:host(https://angular.io/docs/ts/latest/guide/component-styles.html)访问整个组件主体

有了这个,我创建了以下样式ChildComponent:

:host
{
    display: block;

    width: 400px;
    height: 300px;
}
Run Code Online (Sandbox Code Playgroud)

现在我想在每个ChildComponent(整个组件)上绑定(单击)事件并在ChildComponent类中捕获它.要做到这一点,我必须在某事物上设置(click)="method"属性.

但是,在谈论事件时,我不会:主持人的事情.

我不想绑定ContainerComponent.

一种可能的解决方案是将整个组件包装在div中并将事件绑定到此div,但是我正在寻找一种更优雅的方式.

javascript angular

10
推荐指数
1
解决办法
8574
查看次数

如何将 Box&lt;dyn Error + Sync + Send&gt; 转换为 Box&lt;dyn Error&gt;

在我的程序中,一些操作是在辅助线程上执行的,它们的结果:Result<(), Box<dyn Error>>被发送回主线程。这对于错误有Send要求是非常合理的,因此实际类型是Result<(), Box<dyn Error + Send>>. 我还添加Sync了能够使用Box from方法(仅针对普通或同步 + 发送实现)。但是在单线程上确定结果后,我想放弃这个要求。

例子:

use std::error::Error;

fn test1() -> Result<(), Box<dyn Error + Sync + Send>> {
    return Err("test1".into());
}
fn test2() -> Result<(), Box<dyn Error>> {
    test1()?;
    return Ok(());
}
fn main() {
    let test2_result = test2();
    println!("test2_result: {:#?}", test2_result);
}
Run Code Online (Sandbox Code Playgroud)

最后我实际上以:

   Compiling playground v0.0.1 (/playground)
error[E0277]: the size for values of type `dyn std::error::Error + std::marker::Send + std::marker::Sync` cannot be …
Run Code Online (Sandbox Code Playgroud)

rust

7
推荐指数
1
解决办法
1735
查看次数

创建unordered_set的unordered_set

我想创建一个容器,用于存储唯一的整数集.

我想创造类似的东西

std::unordered_set<std::unordered_set<unsigned int>>
Run Code Online (Sandbox Code Playgroud)

但是g ++不允许我这样做并说:

invalid use of incomplete type 'struct std::hash<std::unordered_set<unsigned int> >'
Run Code Online (Sandbox Code Playgroud)

我想要实现的是拥有独特的无符号整数集.

我怎样才能做到这一点?

c++ hash c++11

6
推荐指数
2
解决办法
2079
查看次数

具有void返回类型和模板化参数的std :: function

我有一个

template<class R>
class MyClass
{
    public:
        typedef std::function<void (const R)> ...;
};
Run Code Online (Sandbox Code Playgroud)

在我尝试使用MyClass <void>之前一切正常.

在这种情况下,编译器将typedef扩展为

typedef std::function<void (void)> ...;
Run Code Online (Sandbox Code Playgroud)

而且不想合作.

如果void用作R参数,我希望typedef的行为如下:

typedef std::function<void ()> ...;
Run Code Online (Sandbox Code Playgroud)

由于类非常大,我更喜欢type_traits和enable_if-like,而不是为void创建特化.

c++ templates

4
推荐指数
1
解决办法
836
查看次数

没有默认构造函数和已删除的复制构造函数初始化的对象的类成员数组

我有一个名为'Container'的类,其中必须存储三个(在编译时已知)DontCopyMe类的对象.DontCopyMe类具有非默认构造函数和已删除的复制构造函数.如何初始化Containter?

示例代码:

#include <string>

class DontCopyMe
{
    public:
        DontCopyMe(const unsigned int SomeInt, const std::string & SomeString): SomeInt(SomeInt), SomeString(SomeString)
        {
        }
        DontCopyMe(const DontCopyMe &) = delete;
        DontCopyMe & operator = (const DontCopyMe &) = delete;
        DontCopyMe(DontCopyMe &&) = delete;
        DontCopyMe & operator = (DontCopyMe &&) = delete;

    private:
        const unsigned int SomeInt;
        const std::string SomeString;
};

class Container
{
    public:
        Container(): Array{{1, "A"}, {2, "B"}, {3, "C"}}
        {

        }

    private:
        DontCopyMe Array[3];
};

int main()
{
    Container C;
    return 0;
} …
Run Code Online (Sandbox Code Playgroud)

c++ c++11

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

有没有办法创建一个异步流生成器来产生重复调用函数的结果?

我想构建一个收集天气更新并将它们表示为流的程序。我想get_weather()在一个无限循环中调用,在finishstart之间有 60 秒的延迟。

简化版本如下所示:

async fn get_weather() -> Weather { /* ... */ }

fn get_weather_stream() -> impl futures::Stream<Item = Weather> {
    loop {
        tokio::timer::delay_for(std::time::Duration::from_secs(60)).await;
        let weather = get_weather().await;
        yield weather; // This is not supported
        // Note: waiting for get_weather() stops the timer and avoids overflows.
    }
}
Run Code Online (Sandbox Code Playgroud)

有没有办法轻松做到这一点?

超过 60 秒tokio::timer::Interval时使用将不起作用get_weather()

fn get_weather_stream() -> impl futures::Stream<Item = Weather> {
    tokio::timer::Interval::new_with_delay(std::time::Duration::from_secs(60))
        .then(|| get_weather())
}
Run Code Online (Sandbox Code Playgroud)

如果发生这种情况,下一个功能将立即启动。我想在上一次get_weather()开始和下一次get_weather()开始之间保持 …

asynchronous rust async-await rust-tokio

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