Skip to content

Commit 98a5430

Browse files
committed
New H36 protocol - 1 ID
1 parent 56fa7e7 commit 98a5430

8 files changed

+155
-5
lines changed

Lua_scripts/MultiChan.txt

+1
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,4 @@
227227
98,0,Kyosho3,ASF,0
228228
100,0,YuXiang,Std,0,Lock,Rate,Land,Manual,Flip,Mode,Pitch
229229
102,0,JIABAILE,Std,1,Speed,Light,Flash
230+
103,0,H36,Std,1,Flip,HLess,RTH

Multiprotocol/H36_nrf24l01.ino

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/*
2+
This project is free software: you can redistribute it and/or modify
3+
it under the terms of the GNU General Public License as published by
4+
the Free Software Foundation, either version 3 of the License, or
5+
(at your option) any later version.
6+
7+
Multiprotocol is distributed in the hope that it will be useful,
8+
but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
GNU General Public License for more details.
11+
12+
You should have received a copy of the GNU General Public License
13+
along with Multiprotocol. If not, see <http://www.gnu.org/licenses/>.
14+
*/
15+
#if defined(H36_NRF24L01_INO)
16+
17+
#include "iface_xn297.h"
18+
19+
#define FORCE_H36_ORIGINAL_ID
20+
21+
#define H36_PAYLOAD_SIZE 13
22+
#define H36_RF_NUM_CHANNELS 4
23+
#define H36_BIND_PACKET_PERIOD 10285
24+
#define H36_BIND_COUNT 648 //3sec
25+
26+
enum {
27+
H36_DATA1=0,
28+
H36_DATA2,
29+
H36_DATA3,
30+
H36_DATA4,
31+
};
32+
33+
static void __attribute__((unused)) H36_send_packet()
34+
{
35+
if(IS_BIND_DONE && phase == H36_DATA1)
36+
{
37+
hopping_frequency_no++;
38+
hopping_frequency_no&=3;
39+
XN297_Hopping(hopping_frequency_no);
40+
}
41+
42+
packet[0] = 0x2E; // constant?
43+
memcpy(&packet[2],rx_tx_addr,3);
44+
if(IS_BIND_IN_PROGRESS)
45+
{//Bind
46+
memcpy(&packet[5],hopping_frequency,4);
47+
memset(&packet[9], 0x00, 3);
48+
packet[12] = 0xED; // constant?
49+
bind_counter--;
50+
if(bind_counter == 0)
51+
BIND_DONE;
52+
}
53+
else
54+
{//Normal
55+
packet[5] = convert_channel_8b(THROTTLE);
56+
packet[6] = convert_channel_8b(RUDDER);
57+
packet[7] = convert_channel_8b(ELEVATOR);
58+
packet[8] = convert_channel_8b(AILERON);
59+
packet[9] = GET_FLAG(CH6_SW, 0x02) //Headless
60+
|GET_FLAG(CH7_SW, 0x04); //RTH(temporary)
61+
packet[10] = 0x20; //Trim A centered(0x20)
62+
packet[11] = CH5_SW?0x60:0x20; //Flip(0x40)|Trim E centered(0x20)
63+
packet[12] = 0xA0; //High(0x80)/Low(0x40) rates|Trim R centered(0x20)?
64+
}
65+
//crc
66+
packet[1]=0xAA;
67+
for(uint8_t i=5;i<12;i++)
68+
packet[1] ^= packet[i];
69+
//Send
70+
XN297_SetPower();
71+
XN297_SetTxRxMode(TX_EN);
72+
XN297_WritePayload(packet, H36_PAYLOAD_SIZE);
73+
#ifdef DEBUG_SERIAL
74+
debug("H%d P",hopping_frequency_no);
75+
for(uint8_t i=0; i < H36_PAYLOAD_SIZE; i++)
76+
debug(" %02X", packet[i]);
77+
debugln();
78+
#endif
79+
}
80+
81+
static void __attribute__((unused)) H36_initialize_txid()
82+
{
83+
rx_tx_addr[0] = rx_tx_addr[3];
84+
calc_fh_channels(4);
85+
#ifdef FORCE_H36_ORIGINAL_ID
86+
memcpy(rx_tx_addr,(uint8_t *)"\x00\x11\x00",3);
87+
memcpy(hopping_frequency,(uint8_t *)"\x36\x3A\x31\x2B",4); //54, 58, 49, 43
88+
#endif
89+
}
90+
91+
static void __attribute__((unused)) H36_RF_init()
92+
{
93+
XN297_Configure(XN297_CRCEN, XN297_SCRAMBLED, XN297_1M);
94+
XN297_SetTXAddr((uint8_t*)"\xCC\x6C\x47\x90\x53", 5);
95+
XN297_RFChannel(50); //Bind channel
96+
}
97+
98+
uint16_t H36_callback()
99+
{
100+
H36_send_packet();
101+
switch(phase)
102+
{
103+
case H36_DATA1:
104+
phase++;
105+
return 1830;
106+
case H36_DATA2:
107+
case H36_DATA3:
108+
phase++;
109+
return 3085;
110+
default://DATA4
111+
#ifdef MULTI_SYNC
112+
telemetry_set_input_sync(18500);
113+
#endif
114+
phase = H36_DATA1;
115+
break;
116+
}
117+
return 10500;
118+
}
119+
120+
void H36_init()
121+
{
122+
BIND_IN_PROGRESS; // Autobind protocol
123+
H36_initialize_txid();
124+
H36_RF_init();
125+
phase = H36_DATA1;
126+
hopping_frequency_no = 0;
127+
bind_counter = H36_BIND_COUNT;
128+
}
129+
#endif

Multiprotocol/Multi.txt

+1
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,4 @@
9898
99,XK2
9999
100,YuXiang
100100
102,JIABAILE
101+
103,H36

Multiprotocol/Multi_Protos.ino

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const char STR_DM002[] ="DM002";
5555
const char STR_CABELL[] ="Cabell";
5656
const char STR_ESKY150[] ="Esky150";
5757
const char STR_ESKY150V2[] ="EskyV2";
58+
const char STR_H36[] ="H36";
5859
const char STR_H8_3D[] ="H8 3D";
5960
const char STR_CORONA[] ="Corona";
6061
const char STR_CFLIE[] ="CFlie";
@@ -349,6 +350,9 @@ const mm_protocol_definition multi_protocols[] = {
349350
#if defined(GW008_NRF24L01_INO)
350351
{PROTO_GW008, STR_GW008, NO_SUBTYPE, 0, OPTION_NONE, 0, 0, SW_NRF, GW008_init, GW008_callback },
351352
#endif
353+
#if defined(H36_NRF24L01_INO)
354+
{PROTO_H36, STR_H36, NO_SUBTYPE, 0, OPTION_NONE, 0, 0, SW_NRF, H36_init, H36_callback },
355+
#endif
352356
#if defined(H8_3D_NRF24L01_INO)
353357
{PROTO_H8_3D, STR_H8_3D, STR_SUBTYPE_H83D, 4, OPTION_NONE, 0, 0, SW_NRF, H8_3D_init, H8_3D_callback },
354358
#endif

Multiprotocol/Multiprotocol.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define VERSION_MAJOR 1
2020
#define VERSION_MINOR 3
2121
#define VERSION_REVISION 4
22-
#define VERSION_PATCH_LEVEL 24
22+
#define VERSION_PATCH_LEVEL 25
2323

2424
#define MODE_SERIAL 0
2525

@@ -130,6 +130,7 @@ enum PROTOCOLS
130130
PROTO_YUXIANG = 100, // =>NRF24L01
131131
PROTO_PINECONE = 101, // =>CC2500 & NRF24L01
132132
PROTO_JIABAILE = 102, // =>NRF24L01
133+
PROTO_H36 = 103, // =>NRF24L01
133134

134135
PROTO_NANORF = 126, // =>NRF24L01
135136
PROTO_TEST = 127, // =>CC2500

Multiprotocol/Validate.h

+2
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@
321321
#undef FY326_NRF24L01_INO
322322
#undef GW008_NRF24L01_INO
323323
#undef H8_3D_NRF24L01_INO
324+
#undef H36_NRF24L01_INO
324325
#undef HISKY_NRF24L01_INO
325326
#undef HONTAI_NRF24L01_INO
326327
#undef JIABAILE_NRF24L01_INO
@@ -423,6 +424,7 @@
423424
#undef GW008_NRF24L01_INO
424425
#undef HONTAI_NRF24L01_INO
425426
#undef H8_3D_NRF24L01_INO
427+
#undef H36_NRF24L01_INO
426428
#undef JJRC345_NRF24L01_INO
427429
#undef KN_NRF24L01_INO
428430
#undef LOLI_NRF24L01_INO

Multiprotocol/_Config.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,10 @@
240240
#define FX_NRF24L01_INO
241241
#define FY326_NRF24L01_INO
242242
#define GW008_NRF24L01_INO
243+
#define H36_NRF24L01_INO
244+
#define H8_3D_NRF24L01_INO
243245
#define HISKY_NRF24L01_INO
244246
#define HONTAI_NRF24L01_INO
245-
#define H8_3D_NRF24L01_INO
246247
#define JIABAILE_NRF24L01_INO
247248
#define JJRC345_NRF24L01_INO
248249
#define KN_NRF24L01_INO
@@ -702,6 +703,7 @@ const PPM_Parameters PPM_prot[14*NBR_BANKS]= {
702703
GD_V2
703704
PROTO_GW008
704705
NONE
706+
PROTO_H36
705707
PROTO_H8_3D
706708
H8_3D
707709
H20H

Protocols_Details.md

+13-3
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ CFlie|38|CFlie||||||||NRF24L01|
103103
[FY326](Protocols_Details.md#FY326---20)|20|FY326|FY319|||||||NRF24L01|
104104
[GD00X](Protocols_Details.md#GD00X---47)|47|GD_V1*|GD_V2*|||||||NRF24L01|XN297L
105105
[GW008](Protocols_Details.md#GW008---32)|32|||||||||NRF24L01|XN297
106+
[H36](Protocols_Details.md#H36---103)|H36|||||||||NRF24L01|XN297
106107
[H8_3D](Protocols_Details.md#H8_3D---36)|36|H8_3D|H20H|H20Mini|H30Mini|||||NRF24L01|XN297
107108
[Height](Protocols_Details.md#HEIGHT---53)|53|5ch|8ch|||||||A7105|
108109
[Hisky](Protocols_Details.md#HISKY---4)|4|Hisky|HK310|||||||NRF24L01|
@@ -1839,15 +1840,24 @@ CH1|CH2|CH3|CH4|CH5
18391840
---|---|---|---|---
18401841
A|E|T|R|FLIP
18411842

1843+
## H36 - *103*
1844+
Autobind protocol
1845+
1846+
Model: JJRC H36 (JR-NH010R9 board)
1847+
1848+
CH1|CH2|CH3|CH4|CH5|CH6|CH7
1849+
---|---|---|---|---|---|---
1850+
A|E|T|R|FLIP|HEADLESS|RTH
1851+
18421852
## H8_3D - *36*
18431853
Autobind protocol
18441854

18451855
### Sub_protocol H8_3D - *0*
18461856
Models: Eachine H8 mini 3D,Eachine E10, JJRC H20/H22/H11D
18471857

1848-
CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13
1849-
---|---|---|---|---|---|---|---|---
1850-
FLIP|LIGTH|PICTURE|VIDEO|OPT1|OPT2|CAL1|CAL2|GIMBAL
1858+
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13
1859+
---|---|---|---|---|---|---|---|---|---|---|---|---
1860+
A|E|T|R|FLIP|LIGTH|PICTURE|VIDEO|OPT1|OPT2|CAL1|CAL2|GIMBAL
18511861

18521862
JJRC H20: OPT1=Headless, OPT2=RTH
18531863

0 commit comments

Comments
 (0)