Gamepad & WSN

Tag Archives: 物联网

蓝牙HCI根据OpCode计算OCF、OGF源代码

Author:Gamepader    IN:Network    Tags: , , ,     评论: 0    超过223人围观

最近在折腾蓝牙HCI接口,苦于没有人教,自己慢慢,终于能够通上信了(HCI_Reset命令执行成功)。
鉴于不清楚那一百多个蓝牙HCI指令具体用在什么环境,特地买了个USB蓝牙CSR4.0的模块来研究学习(算是下了大本钱了 :))。
用BUS Hound抓到的部分数据如下:

1
2
3
4
5
6
7
8
9
10
11
18.0 CTL 20 00 00 00 00 00 03 00 SEND HCI 5.1.0
18.0 OUT 03 0c 00 ... 5.2.0
18.1 IN 0e 04 01 03 0c 00 ...... 6.1.0
18.0 CTL 20 00 00 00 00 00 03 00 SEND HCI 7.1.0
18.0 OUT 05 10 00 ... 7.2.0
18.1 IN 0e 0b 01 05 10 00 36 01 40 0a 00 08 00 [email protected] 8.1.0
18.0 CTL 20 00 00 00 00 00 03 00 SEND HCI 9.1.0
18.0 OUT 01 10 00 ... 9.2.0
18.1 IN 0e 0c 01 01 10 00 06 bb 22 06 0a 00 bb 22 ........"...." 10.1.0
18.0 CTL 20 00 00 00 00 00 03 00 SEND HCI 11.1.0
18.0 OUT 02 10 00 ... 11.2.0

但是鉴于以下两点,不方便拆分具体的OCF和OGF。

    1.蓝牙HCI命令使用小端格式(Little-Endian)
    2.OGF占6 bits、OCF占10 bits。

想到用一个比较简单的数据结构来实现拆分:

1
2
3
4
5
6
7
8
typedef union _opcode_t_
{
    unsigned int opcod;
    struct {
        unsigned short ocf :10;
        unsigned short ogf :6;
    } op;
} opcode_t;

附上C++程序源代码如下(由于功能简单,代码相对简单,勿喷):
蓝牙HCI根据OpCode计算OCF、OGF源代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdio .h>

typedef union _opcode_t_
{
    unsigned int opcod;
    struct {
        unsigned short ocf :10;
        unsigned short ogf :6;
    } op;
} opcode_t;

opcode_t HCI_OpCode;
unsigned int HCI_OP;

void main(unsigned char argc, unsigned char argv[])
{
    unsigned int* tmp;
    tmp = &HCI_OpCode;
    HCI_OP = 0x1005;

    while(1)
    {
        printf("Input OpCode (In Big-Endian):0x");
        scanf("%x",&HCI_OP);
        if(HCI_OP == 0) break;
        *tmp = HCI_OP;
        printf("OpCode=0x%04X\t",HCI_OpCode.opcod);
        printf("OGF=0x%02X\t",HCI_OpCode.op.ogf);
        printf("OCF=0x%02X\r\n\r\n",HCI_OpCode.op.ocf);
    }
    printf("Thankyou for use,Code by Gamepader.com");
    getch();

    return;
}

附上运行效果图(其实没有什么效果):
HCIOpCode2运行效果图
源代码下载:CalcOpCode.c
编译好的源程序:CalcOpCode.exe
原创文章,欢迎转载,但请注明来源://blog.gamepader.com/archives/2013/05/the-bluetooth-hci-according-opcode-calculated-ocf-ogf-source-code.html

05-14
2013

Sony PS4 DualShock 4 Controller with Eye Camera Can See, Hear and Move with You

Author:Gamepader    IN:手柄    Tags: ,     评论: 0    超过155人围观

In case you missed it, Sony at long last unveiled its PlayStation 4 console during a two-hour press event yesterday, featuring a surprise appearance by Blizzard, which is bringing Diablo III to the PS3 and PS4. You’ll get to play that game (and many others) on Sony’s wireless DualShock 4 controller. Yes, Sony is sticking with the DualShock design that’s become an iconic image of the PlayStation brand, though this newest version features several upgrades.

On the inside, the DualShock 4 features a new highly sensitive six-axis sensor for precise control. Externally, the DualShock 4 looks similar to previous models, though it now comes with a touchpad located on the front of the controller, opening up new gameplay avenues for software developers.

SonyDualShock_4

In addition to the D-Pad and analog sticks, the new controller retains the Triangle, Square, X, and Circle buttons. You’ll notice above that there’s no longer Start and Select buttons, both of which have been integrated into an Options button on the upper-right side.

On the opposite side is a Share button. This will allow gamers to broadcast their gameplay in real-time to friends through Internet streaming services such as Ustream. You’ll also be able to share gaming moments and accomplishments by uploading video gameplay footage to Facebook, all with the touch of the button — no fussing with video formats or conversions.

Below the touchpad in the center is a built-in speaker, which will pipe high-fidelity sound effects from games (don’t worry, your TV and/or home theater speakers will still play in-game sound effects, too).

DualShock_4_Lightbar

The DualShock 4 features a light bar on top with three color LEDs. It illuminates to match the color of characters in a game to offer an easier way to identify players, even when playing side by side, Sony says. It will also change patterns to reflect gameplay scenarios, such as being critically low on health or taking a major blow from an enemy.

PS4_Eye

Adding another element to gameplay, Sony developed a PlayStation 4 Eye camera that’s similar to Microsoft’s Kinect. It has two high-sensitive cameras with wide-angle lenses and 85-degree diagonal angle views. According to Sony, it’s capable of precise detection of depth of space.

“This enables PlayStation 4 Eye to cut out the image of player from background, or to grasp players’ position in front and behind, further broadening the ways to enjoy games,” Sony explains.

There are four microphones incorporated into the PS4 Eye, allowing the device to detect accurate sound and source origination. Gamers will be able to use the Eye to log into their PS4 using face recognition, too.

本文转载自://hothardware.com/News/Sony-PS4-DualShock-4-Controller-and-Eye-Camera-Can-See-Hear-and-Move-with-You/ ,版权归原作者所有。

02-22
2013

智能家居监控中心设计思路-WEB控制台

Author:Gamepader    IN:ARM_Linux, 创意    Tags: , , ,     评论: 0    超过72人围观

初步设想是做一个包含灯光(电源)控制 红外线防盗报警、 摄像头实时监控、 PM2.5检测、 温度探测湿度探测噪声测量等功能于一体的综合式智能家居监控中心。

本监控中心可以实现的功能:

  • 根据光照强度自动控制室内灯光;
  • 房门、窗户布置红外防盗线;
  • 摄像头检测到有动作时自动拍照并上传至网络;
  • 摄像头可以当做网络监控器使用;
  • PM2.5空气浮尘检测;
  • 环境温湿度探测,火灾报警;
  • 环境噪声检测;
  • 有线或者无线方式加入局域网;
  • 可以通过2.4G网络连接处于WSN(Wireless Sensor Network)中的各个传感器;
  • 能够按需添加不同的控制模块与传感器探测模块,如蓝牙模块、超声波模块、控制四驱小车搭载其主体运动等;

给出DEMO版本链接://liyvhg.vicp.net:808/,请“鼠”下留情,不要恶意控制

02-17
2013
loading...