@@ -42,6 +42,9 @@ Multiprotocol is distributed in the hope that it will be useful,
4242#define FX_QF012_PACKET_PERIOD 12194
4343#define FX_QF012_RX_PAYLOAD_SIZE 3
4444
45+ #define FX_BM26_BIND_CHANNEL 40
46+ #define FX_BM26_PACKET_PERIOD 14066
47+
4548// #define FORCE_FX620_ID
4649// #define FORCE_FX9630_ID
4750// #define FORCE_QIDI_ID
@@ -90,6 +93,12 @@ static void __attribute__((unused)) FX_send_packet()
9093 packet[1 ] = convert_channel_8b (AILERON);
9194 packet[2 ] = 0xFF - convert_channel_8b (ELEVATOR);
9295 packet[3 ] = convert_channel_8b (RUDDER);
96+ if ( sub_protocol == FX_BM26 ) // BM26 Ail, Elev, Rud range between 0x00-0x3F-0x7F
97+ {
98+ packet[1 ] >>= 1 ;
99+ packet[2 ] >>= 1 ;
100+ packet[3 ] >>= 1 ;
101+ }
93102 val = trim_ch==0 ? 0x20 : (convert_channel_8b (trim_ch + CH6) >> 2 ); // no trim on Throttle
94103 packet[4 ] = val; // Trim for channel x 0C..20..34
95104 packet[5 ] = (trim_ch << 4 ) // channel x << 4
@@ -103,6 +112,22 @@ static void __attribute__((unused)) FX_send_packet()
103112 else if (sub_protocol == FX_QF012)
104113 packet[5 ] |= GET_FLAG (CH7_SW, 0x40 ) // QF012 invert flight
105114 | GET_FLAG (CH8_SW, 0x80 ); // QF012 Restore fine tunning midpoint
115+ else if ( sub_protocol == FX_BM26 )
116+ {
117+ if ( packet_count == 0 || packet_count > 3 ) {
118+ packet[5 ] = 0x00 ;
119+ packet_count = 0 ;
120+ }
121+ else packet[5 ] += 0x40 ;
122+ packet_count++;
123+ // BM26 P51=>0:beginner(6G), 1:mid(3D), 2:expert(Gyro off)
124+ packet[5 ] |= (Channel_data[CH6] < CHANNEL_MIN_COMMAND ? 0x08 : (Channel_data[CH6] > CHANNEL_MAX_COMMAND ? 0x0C : 0x0A ));
125+
126+ packet[6 ] = (Channel_data[CH5] > CHANNEL_MAX_COMMAND ? 0x20 : 0x00 ) // 6G Roll
127+ | (Channel_data[CH7] > CHANNEL_MAX_COMMAND ? 0x00 : 0x08 ) // Light control switch, default on
128+ | (Channel_data[CH8] > CHANNEL_MAX_COMMAND ? 0x00 : 0x10 ) // Turn signal switch, default on
129+ | (Channel_data[CH9] > CHANNEL_MAX_COMMAND ? 0x01 : 0x00 ); // Gyro Calibration
130+ }
106131 }
107132 else // FX816 & FX620
108133 {
@@ -164,6 +189,8 @@ static void __attribute__((unused)) FX_send_packet()
164189 val = val ^ 0xFF ;
165190 packet[last_packet_idx]=val;
166191
192+ if ( IS_BIND_IN_PROGRESS && sub_protocol == FX_BM26 ) packet[7 ] = packet[6 ];
193+
167194 // Debug
168195 #if 0
169196 for(uint8_t i=0;i<packet_length;i++)
@@ -194,6 +221,13 @@ static void __attribute__((unused)) FX_RF_init()
194221 packet_period = FX620_BIND_PACKET_PERIOD;
195222 packet_length = FX620_PAYLOAD_SIZE;
196223 }
224+ else if (sub_protocol == FX_BM26)
225+ {
226+ XN297_SetTXAddr ((uint8_t *)" \x12\x34\x10\x10 " , 4 );
227+ XN297_RFChannel (FX_BM26_BIND_CHANNEL);
228+ packet_period = FX_BM26_PACKET_PERIOD;
229+ packet_length = FX9630_PAYLOAD_SIZE;
230+ }
197231 else // FX9630 & FX_Q560 & FX_QF012
198232 {
199233 XN297_SetTXAddr ((uint8_t *)" \x56\x78\x90\x12 " , 4 );
@@ -229,7 +263,7 @@ static void __attribute__((unused)) FX_initialize_txid()
229263 else // FX9630 & FX_Q560 & FX_QF012
230264 {
231265 // ??? Need to find out how the first RF channel is calculated ???
232- hopping_frequency[0 ] = 0x13 ;
266+ hopping_frequency[0 ] = sub_protocol == FX_BM26? 0x0C : 0x13 ;
233267 // Other 2 RF channels are sent during the bind phase so they can be whatever
234268 hopping_frequency[1 ] = RX_num & 0x0F + 0x1A ;
235269 hopping_frequency[2 ] = rx_tx_addr[3 ] & 0x0F + 0x38 ;
@@ -245,7 +279,8 @@ static void __attribute__((unused)) FX_initialize_txid()
245279 // memcpy(rx_tx_addr,(uint8_t*)"\x38\xC7\x6D\x8D", 4);
246280 // memcpy(hopping_frequency,"\x0D\x20\x3A", FX9630_NUM_CHANNELS);
247281 #endif
248- }
282+ // BM26 rx_tx_addr: "\x17\x03\x00\x00", hopping_frequency: 0x0C,0x30,0x43(12,48,67)
283+ }
249284}
250285
251286uint16_t FX_callback ()
@@ -288,9 +323,9 @@ uint16_t FX_callback()
288323 debug (" RX" );
289324 if (XN297_ReadPayload (packet_in, FX_QF012_RX_PAYLOAD_SIZE))
290325 {// Good CRC
291- // packets: A5 00 11 -> A5 01 11
292326 telemetry_link = 1 ;
293- v_lipo1 = packet_in[1 ] ? 60 :81 ; // low voltage 3.7V
327+ if ( sub_protocol == FX_BM26 ) v_lipo1 = packet_in[0 ] < packet_in[2 ]? 60 :81 ; // packets: AA 00 55 -> 55 00 AA
328+ else v_lipo1 = packet_in[1 ] ? 60 :81 ; // packets: A5 00 11 -> A5 01 11 // low voltage 3.7V
294329 #if 0
295330 for(uint8_t i=0; i < FX_QF012_RX_PAYLOAD_SIZE; i++)
296331 debug(" %02X", packet_in[i]);
@@ -328,6 +363,7 @@ void FX_init()
328363 FX_RF_init ();
329364 hopping_frequency_no = 0 ;
330365 bind_counter=FX_BIND_COUNT;
366+ packet_count = 0 ;
331367 #ifdef FX_HUB_TELEMETRY
332368 RX_RSSI = 100 ; // Dummy value
333369 phase = FX_DATA;
0 commit comments